Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
biofunction.h
00001 /**************************************************************************
00002  * Copyright (c) 2004-2011 T. M. Murali                                   *
00003  * Copyright (c) 2007-2011 Naveed Massjouni                               *
00004  * Copyright (c) 2009-2011 Christopher L. Poirel                          *
00005  * Copyright (c) 2011 Phillip Whisenhunt                                  *
00006  * Copyright (c) 2011 David Badger                                        *
00007  * Copyright (c) 2010 Clifford Conley Owens III                           *
00008  *                                                                        *
00009  * This file is part of Biorithm.                                         *
00010  *                                                                        *
00011  * Biorithm is free software: you can redistribute it and/or modify       *
00012  * it under the terms of the GNU General Public License as published by   *
00013  * the Free Software Foundation, either version 3 of the License, or      *
00014  * (at your option) any later version.                                    *
00015  *                                                                        *
00016  * Biorithm is distributed in the hope that it will be useful,            *
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00019  * GNU General Public License for more details.                           *
00020  *                                                                        *
00021  * You should have received a copy of the GNU General Public License      *
00022  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00023  *                                                                        *
00024  **************************************************************************/
00025 
00032 // Purpose: a barebones class that specifies a function by id and
00033 // category. I call this file biofunction.h to distinguish it from
00034 // function.h in the C++ standard library.
00035 
00036 #ifndef _BIOFUNCTION_H
00037 #define _BIOFUNCTION_H
00038 
00039 #include <string>
00040 using namespace std;
00041 
00042 
00043 // with so many strings floating around, it is better to define such a
00044 // type. i use it in active-networks.h.
00045 typedef string BioFunctionCategoryType;
00046 
00056 class BioFunction
00057 {
00058 protected:
00059   string _category;
00060   string _id;
00061   string _name;
00062 public:
00063   BioFunction()
00064       : _category(), _id(), _name()
00065     {}
00066 
00067   BioFunction(string cat, string id, string name = "")
00068       : _category(cat), _id(id), _name(name)
00069     {}
00070   BioFunction(const BioFunction& other)
00071       : _category(other._category), _id(other._id), _name(other._name)
00072     {}
00073   
00074   virtual ~BioFunction()
00075     {}
00076 
00077   virtual string getCategory() const
00078     {
00079       return(_category);
00080     }
00081   virtual string getId() const
00082     {
00083       return(_id);
00084     }
00085   
00086   virtual string getName() const
00087     {
00088       return(_name);
00089     }
00090 
00091   bool operator==(const BioFunction &other) const
00092     {
00093       return((_category == other._category) && (_id == other._id));
00094     }
00095   
00096   bool operator!=(const BioFunction &other) const
00097     {
00098       return(!(*this == other));
00099     }
00111   bool operator<(const BioFunction &rhs) const
00112     {
00113       if (getCategory() == rhs.getCategory())
00114         return(getId() < rhs.getId());
00115       return((getCategory() < rhs.getCategory()));
00116     }
00117   
00118 };
00119   
00120 inline ostream &operator<<(ostream &ostr, const BioFunction &function)
00121 {
00122   ostr << function.getId();
00123   if ("" != function.getName())
00124     ostr << ": " << function.getName();
00125   ostr << " (" << function.getCategory() << ") ";
00126   return(ostr);
00127 }
00128 
00129 
00130 
00131 #endif // _BIOFUNCTION_H 
 All Classes Functions Variables Typedefs Friends