eoSym.h

00001 /*          
00002  *             Copyright (C) 2005 Maarten Keijzer
00003  *
00004  *          This program is free software; you can redistribute it and/or modify
00005  *          it under the terms of version 2 of the GNU General Public License as 
00006  *          published by the Free Software Foundation. 
00007  *
00008  *          This program is distributed in the hope that it will be useful,
00009  *          but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *          GNU General Public License for more details.
00012  *
00013  *          You should have received a copy of the GNU General Public License
00014  *          along with this program; if not, write to the Free Software
00015  *          Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016  */
00017 
00018 #ifndef EOSYM_H_
00019 #define EOSYM_H_
00020 
00021 #include <EO.h>
00022 #include <Sym.h>
00023 #include <FunDef.h>
00024 
00025 
00026 template <class Fitness>
00027 class EoSym : public EO<Fitness>, public Sym {
00028 
00029     public:
00030         
00031         void set(const Sym& sym) {
00032             EO<Fitness>::invalidate();
00033             static_cast<Sym*>(this)->operator=(sym);
00034         }
00035 
00036         Sym& get()      { return static_cast<Sym&>(*this); };
00037         Sym get() const { return static_cast<Sym&>(*this); };
00038         
00039         virtual void printOn(std::ostream& os) const;
00040         virtual void readFrom(std::istream& is);
00041 };
00042 
00043 
00044 template <class Fitness>
00045 void EoSym<Fitness>::printOn(std::ostream& os) const {
00046     EO<Fitness>::printOn(os);
00047     os << ' ';
00048     write_raw(os, *this);
00049 }
00050 
00051 template <class Fitness>
00052 void EoSym<Fitness>::readFrom(std::istream& is) {
00053     EO<Fitness>::readFrom(is);
00054     read_raw(is, *this); 
00055 }
00056 
00057 template <class Fitness>
00058 inline std::ostream& operator<<(std::ostream& os, const EoSym<Fitness>& f) { f.printOn(os); return os; }
00059 template <class Fitness>
00060 inline std::istream& operator>>(std::istream& is, EoSym<Fitness>& f) { f.readFrom(is); return is; }
00061 
00062 
00063 #endif
00064 
00065 

Generated on Thu Oct 19 05:06:38 2006 for EO by  doxygen 1.3.9.1