EvolvingObjects
|
00001 /* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 ----------------------------------------------------------------------------- 00004 eoExternalEO.h 00005 Definition of an object that allows an external struct to be inserted in EO 00006 00007 (c) Maarten Keijzer (mkeijzer@mad.scientist.com) and GeNeura Team, 1999, 2000 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00023 Contact: todos@geneura.ugr.es, http://geneura.ugr.es 00024 */ 00025 00026 #ifndef eoExternalEO_h 00027 #define eoExternalEO_h 00028 00029 #include <EO.h> // EO 00030 00039 template <class Fit, class External> 00040 class eoExternalEO : public EO<Fit>, virtual public External 00041 { 00042 public : 00043 00044 eoExternalEO() 00045 : External(), EO<Fit>() 00046 {} 00047 00049 eoExternalEO(const External& ext) 00050 : EO<Fit>(), External(ext) 00051 {} 00052 00053 eoExternalEO(std::istream& is, const External& ext) 00054 : EO<Fit>(), External(ext) 00055 { readFrom(is); } 00056 00060 virtual void readFrom(std::istream& _is) 00061 { 00062 EO<Fit>::readFrom(_is); 00063 _is >> static_cast<External&>(*this); 00064 } 00065 00070 virtual void printOn(std::ostream& _os) const 00071 { 00072 EO<Fit>::printOn(_os); 00073 _os << static_cast<const External&>(*this); 00074 } 00075 00076 }; 00083 template <class F, class External> 00084 std::ostream& operator<<(std::ostream& os, const eoExternalEO<F, External>& eo) 00085 { 00086 eo.printOn(os); 00087 return os; 00088 } 00089 00093 template <class F, class External> 00094 std::istream& operator>>(std::istream& is, eoExternalEO<F, External>& eo) 00095 { 00096 eo.readFrom(is); 00097 return is; 00098 } 00099 00100 #endif