00001 // eoAged.h 00002 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00003 00004 //----------------------------------------------------------------------------- 00005 // eoAge.h 00006 // (c) GeNeura Team, 1998 00007 /* 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 Contact: todos@geneura.ugr.es, http://geneura.ugr.es 00023 */ 00024 //----------------------------------------------------------------------------- 00025 00026 #ifndef EOAGED_H 00027 #define EOAGED_H 00028 00029 //----------------------------------------------------------------------------- 00030 00031 #include <iostream> // istream, ostream 00032 #include <std::string> // para std::string 00033 00034 using namespace std; 00035 00036 //----------------------------------------------------------------------------- 00037 // eoAge 00038 //----------------------------------------------------------------------------- 00039 00046 template <class Object> 00047 class eoAged: public Object 00048 { 00049 public: 00051 eoAged( const Object& _o): Object( _o ), age(0) {}; 00052 00054 eoAged( const eoAged& _a): Object( _a ), age( _a.age ) {}; 00055 00057 virtual ~eoAged() {}; 00058 00059 00061 unsigned long Age() const {return age;} 00062 00064 const eoAged& operator ++ () { age++; return *this;} 00065 00074 virtual std::string className() const { return std::string("eoAged")+Object::className(); }; 00075 00081 virtual void readFrom(istream& _is) { 00082 Object::readFrom( _is ); 00083 _is >> age; 00084 } 00085 00086 00091 virtual void printOn(ostream& _os) const{ 00092 Object::printOn( _os ); 00093 _os << age; 00094 } 00096 00097 private: 00098 00103 eoAged(): Object(), age(0) {}; 00104 00105 unsigned long age; 00106 }; 00107 00108 #endif EOAGE_H 00109