Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Search for

# eoExternalEO.h

    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
    00038 template <class Fit, class External>
    00039 class eoExternalEO : public EO<Fit>, virtual public External
    00040 {
    00041 public :
    00042
    00043     eoExternalEO(void)
    00044         : EO<Fit>(), External()
    00045         {}
    00046
    00048     eoExternalEO(const External& ext)
    00049         : EO<Fit>(), External(ext)
    00050         {}
    00051
    00052     eoExternalEO(std::istream& is, const External& ext)
    00053         : EO<Fit>(), External(ext)
    00054         { readFrom(is); }
    00055
    00059   virtual void readFrom(std::istream& _is)
    00060   {
    00061       EO<Fit>::readFrom(_is);
    00062     _is >> static_cast<External&>(*this);
    00063   }
    00064
    00069   virtual void printOn(std::ostream& _os) const
    00070   {
    00071       EO<Fit>::printOn(_os);
    00072       _os << static_cast<const External&>(*this);
    00073   }
    00074
    00075 };
    00076
    00078 template <class F, class External>
    00079 std::ostream& operator<<(std::ostream& os, const eoExternalEO<F, External>& eo)
    00080 {
    00081     eo.printOn(os);
    00082     return os;
    00083 }
    00084
    00086 template <class F, class External>
    00087 std::istream& operator>>(std::istream& is, eoExternalEO<F, External>& eo)
    00088 {
    00089     eo.readFrom(is);
    00090     return is;
    00091 }
    00092
    00093 #endif