Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
info.h
00001 /**************************************************************************
00002  * Copyright (c) 2002-2011 T. M. Murali                                   *
00003  *                                                                        *
00004  * This file is part of Biorithm.                                         *
00005  *                                                                        *
00006  * Biorithm is free software: you can redistribute it and/or modify       *
00007  * it under the terms of the GNU General Public License as published by   *
00008  * the Free Software Foundation, either version 3 of the License, or      *
00009  * (at your option) any later version.                                    *
00010  *                                                                        *
00011  * Biorithm is distributed in the hope that it will be useful,            *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00014  * GNU General Public License for more details.                           *
00015  *                                                                        *
00016  * You should have received a copy of the GNU General Public License      *
00017  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00018  *                                                                        *
00019  **************************************************************************/
00020 
00021 #ifndef _INFO_H
00022 #define _INFO_H
00023 
00024 #include "mystring.h"
00025 
00026 
00027 // abstract base class to associate information with objects.
00028 class MyInfo
00029 {
00030 public:
00031 //   // i don't want MyInfo to be created without any values.
00032 //   MyInfo();
00033   
00034   MyInfo(MyString id = "", MyString sid = "") 
00035       : name(id), shortName(sid)
00036     {}
00037   MyInfo(const MyInfo& info)
00038       : name(info.name), shortName(info.shortName)
00039     {}
00040   
00041   virtual ~MyInfo()
00042     {}
00043   
00044   // return a clone of this. this function is a way of providing a
00045   // virtual constructor for the MyInfo class hierarchy. 
00046   virtual MyInfo* clone() const // = 0;
00047     {
00048       MyInfo* clone = new MyInfo(*this);
00049       return(clone);
00050     }
00051   virtual void setName(const MyString &id)
00052     {
00053       name = id;
00054     }
00055   virtual MyString getName() const
00056     {
00057       return(name);
00058     }
00059   
00060   virtual void setShortName(const MyString &id)
00061     {
00062       shortName = id;
00063     }
00064   virtual MyString getShortName() const
00065     {
00066       return(shortName);
00067     }
00068   
00069   virtual void print(ostream& ostr) const
00070     {
00071       ostr << "Name = " << name << endl;
00072       ostr << "Short name = " << shortName << endl;
00073     }
00074   
00075 
00076 protected:
00077   MyString  name;
00078   MyString  shortName;
00079 };
00080 
00081 
00082 
00083 #endif // _INFO_H 
 All Classes Functions Variables Typedefs Friends