From 2141b13f9d1dd041e0487c3e2949e0e0e3655d32 Mon Sep 17 00:00:00 2001 From: jmerelo Date: Mon, 8 Feb 1999 16:13:26 +0000 Subject: [PATCH] New files added and fixes for VC++ --- eo/src/eoDrawable.h | 47 +++++++++++++++++++++++ eo/src/eoLottery.h | 2 + eo/src/eoOpSelMason.h | 73 ++++++++++++++++++++++++++++++++++++ eo/src/eoOpSelector.h | 2 +- eo/src/eoProportionalOpSel.h | 15 +++++--- eo/win/EO.dsw | 24 ++++++++++++ eo/win/t_opfactory.dsp | 12 +++--- 7 files changed, 162 insertions(+), 13 deletions(-) create mode 100644 eo/src/eoDrawable.h create mode 100644 eo/src/eoOpSelMason.h diff --git a/eo/src/eoDrawable.h b/eo/src/eoDrawable.h new file mode 100644 index 00000000..72885dca --- /dev/null +++ b/eo/src/eoDrawable.h @@ -0,0 +1,47 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoDrawable.h +// (c) GeNeura Team, 1999 +//----------------------------------------------------------------------------- + +#ifndef EODRAWABLE_H +#define EODRAWABLE_H + +//----------------------------------------------------------------------------- + +using namespace std; + +//----------------------------------------------------------------------------- +// eoDrawable +//----------------------------------------------------------------------------- + +/** eoDrawable is a template class that adds a drawing interface to an object.\\ +Requisites for template instantiation are that the object must admit a default ctor +and a copy ctor. The Object must be an eoObject, thus, it must have its methods: className, +eoDrawables can be drawn on any two-dimensional surface; it can be added to any +object with above characteristics. +@see eoObject +*/ +template +class eoDrawable +{ + public: + /// Main ctor from an already built Object. + eoDrawable( const Object& _o): Object( _o ){}; + + /// Copy constructor. + eoDrawable( const eoDrawable& _d): Object( _d ){}; + + /// Virtual dtor. They are needed in virtual class hierarchies + virtual ~eoDrawable() {}; + + + /**Draws the object. It must be redefined in any subclass, itīs impossible + to have a general drawing method + @param _x, _y coorinates */ + virtual void draw( unsigned _x, unsigned _y) = 0; + +}; + +#endif EODRAWABLE_H diff --git a/eo/src/eoLottery.h b/eo/src/eoLottery.h index acd8d60f..f2dcefb6 100644 --- a/eo/src/eoLottery.h +++ b/eo/src/eoLottery.h @@ -6,6 +6,8 @@ #define eoLottery_h //----------------------------------------------------------------------------- + +#include #include // MINFLOAT #include // accumulate diff --git a/eo/src/eoOpSelMason.h b/eo/src/eoOpSelMason.h new file mode 100644 index 00000000..2497433d --- /dev/null +++ b/eo/src/eoOpSelMason.h @@ -0,0 +1,73 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// eoOpSelMason.h +// (c) GeNeura Team, 1999 +//----------------------------------------------------------------------------- + +#ifndef _EOOPSELMASON_H +#define _EOOPSELMASON_H + +//----------------------------------------------------------------------------- +#include + +//----------------------------------------------------------------------------- + +/** EO Mason, or builder, for operator selectors. A builder must allocate memory +to the objects it builds, and then deallocate it when it gets out of scope*/ +template +class eoOpSelMason: public eoFactory > { + +public: + + /// @name ctors and dtors + //{@ + /// constructor + eoOpSelMason( ) {} + + /// destructor + virtual ~eoOpSelMason() {} + //@} + + /** Factory methods: creates an object from an istream, reading from + it whatever is needed to create the object. The format is + opSelClassName\\ + rate 1 operator1\\ + rate 2 operator2\\ + ...\\ + Stores all operators built in a database (#allocMap#), so that somebody + can destroy them later. The Mason is in charge or destroying the operators, + since the built object canīt do it itself. The objects built must be destroyed + from outside, using the #destroy# method + */ + virtual eoOpSelector* make(istream& _is) { + string opSelName; + _is >> opSelName; + eoMonOpFactory selMaker; + // read operator rate and name + while ( _is ) { + float rate; + _is >> rate; + + + // Create an stream + strstream s0; + eoMonOp* op0 = selMaker.make( s0 ); + } + + } + + ///@name eoObject methods + //@{ + /** Return the class id */ + virtual string className() const { return "eoFactory"; } + + /** Read and print are left without implementation */ + //@} + +private: + map*,vector* > > allocMap; +}; + + +#endif _EOFACTORY_H diff --git a/eo/src/eoOpSelector.h b/eo/src/eoOpSelector.h index 65127059..4a8aae68 100644 --- a/eo/src/eoOpSelector.h +++ b/eo/src/eoOpSelector.h @@ -38,7 +38,7 @@ public: modified or whatever @param _id a previously assigned ID @throw runtime_exception if the ID does not exist*/ - virtual eoOp& getOp( ID _id ) = 0; + virtual const eoOp& getOp( ID _id ) = 0; /** Remove an operator from the operator set @param _id a previously assigned ID diff --git a/eo/src/eoProportionalOpSel.h b/eo/src/eoProportionalOpSel.h index 033e6897..7f14581f 100644 --- a/eo/src/eoProportionalOpSel.h +++ b/eo/src/eoProportionalOpSel.h @@ -26,11 +26,11 @@ Operators are represented as pairs (proportion,operator) */ template class eoProportionalOpSel: public eoOpSelector, - public multimap*,greater > + public multimap*,greater > { public: - typedef multimap*,greater > MMF; + typedef multimap*,greater > MMF; /// default ctor eoProportionalOpSel() @@ -43,13 +43,14 @@ public: modified or whatever @param _id a previously assigned ID @throw runtime_error if the ID does not exist*/ - virtual eoOp& getOp( ID _id ) { + virtual const eoOp& getOp( ID _id ) { MMF::iterator i=begin(); ID j = 1; while ( (i++!=end()) && (j++ != _id) ); if ( i == end() ) throw runtime_error( "No such id in eoProportionalOpSel::op\n" ); return *(i->second); + //return i->second; } /** add an operator to the operator set @@ -100,6 +101,7 @@ public: if ( i == end() ) throw runtime_error( "Operator not found in eoProportionalOpSelector" ); return *(i->second); + //return i->second; } /// Methods inherited from eoObject @@ -115,9 +117,10 @@ public: base classes, so you donīt have to worry about, for instance, fitness. @param _s the ostream in which things are written*/ virtual void printOn( ostream& _s ) const{ - for ( MMF::const_iterator i=begin(); i!=end(); i++ ) { - _s << i->first << "\t" << i->second << endl; - } + _s << className() << endl; + for ( MMF::const_iterator i=begin(); i!=end(); i++ ) { + _s << i->first << "\t" << *(i->second )<< endl; + } } diff --git a/eo/win/EO.dsw b/eo/win/EO.dsw index 84d15c9a..8ef52e62 100644 --- a/eo/win/EO.dsw +++ b/eo/win/EO.dsw @@ -39,6 +39,18 @@ Package=<4> ############################################################################### +Project: "t_eobin"=.\t_eobin.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "t_eoid"=.\t_eoid.dsp - Package Owner=<4> Package=<5> @@ -123,6 +135,18 @@ Package=<4> ############################################################################### +Project: "t_lottery"=.\t_lottery.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "t_opfactory"=.\t_opfactory.dsp - Package Owner=<4> Package=<5> diff --git a/eo/win/t_opfactory.dsp b/eo/win/t_opfactory.dsp index 1c3c39b1..21e392ab 100644 --- a/eo/win/t_opfactory.dsp +++ b/eo/win/t_opfactory.dsp @@ -48,8 +48,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "t_opfactory - Win32 Debug" @@ -64,16 +64,16 @@ LINK32=link.exe # PROP Intermediate_Dir "t_opfactory___Win32_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0xc0a /d "_DEBUG" # ADD RSC /l 0xc0a /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 eo.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 eo.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF