New files added and fixes for VC++

This commit is contained in:
jmerelo 1999-02-08 16:13:26 +00:00
commit 2141b13f9d
7 changed files with 162 additions and 13 deletions

47
eo/src/eoDrawable.h Normal file
View file

@ -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 Object>
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

View file

@ -7,6 +7,8 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <functional>
#include <values.h> // MINFLOAT #include <values.h> // MINFLOAT
#include <numeric> // accumulate #include <numeric> // accumulate
#include <eo> // eoPop eoSelect #include <eo> // eoPop eoSelect

73
eo/src/eoOpSelMason.h Normal file
View file

@ -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 <eoOpSelector.h>
//-----------------------------------------------------------------------------
/** 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 eoClass>
class eoOpSelMason: public eoFactory<eoOpSelector<eoClass> > {
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<eoClass>* make(istream& _is) {
string opSelName;
_is >> opSelName;
eoMonOpFactory<eoClass> selMaker;
// read operator rate and name
while ( _is ) {
float rate;
_is >> rate;
// Create an stream
strstream s0;
eoMonOp<IEO>* 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<eoOpSelector<eoClass>*,vector<eoOp<eoClass>* > > allocMap;
};
#endif _EOFACTORY_H

View file

@ -38,7 +38,7 @@ public:
modified or whatever modified or whatever
@param _id a previously assigned ID @param _id a previously assigned ID
@throw runtime_exception if the ID does not exist*/ @throw runtime_exception if the ID does not exist*/
virtual eoOp<EOT>& getOp( ID _id ) = 0; virtual const eoOp<EOT>& getOp( ID _id ) = 0;
/** Remove an operator from the operator set /** Remove an operator from the operator set
@param _id a previously assigned ID @param _id a previously assigned ID

View file

@ -26,11 +26,11 @@ Operators are represented as pairs (proportion,operator)
*/ */
template<class EOT> template<class EOT>
class eoProportionalOpSel: public eoOpSelector<EOT>, class eoProportionalOpSel: public eoOpSelector<EOT>,
public multimap<float,eoOp<EOT>*,greater<float> > public multimap<float,const eoOp<EOT>*,greater<float> >
{ {
public: public:
typedef multimap<float,eoOp<EOT>*,greater<float> > MMF; typedef multimap<float, const eoOp<EOT>*,greater<float> > MMF;
/// default ctor /// default ctor
eoProportionalOpSel() eoProportionalOpSel()
@ -43,13 +43,14 @@ public:
modified or whatever modified or whatever
@param _id a previously assigned ID @param _id a previously assigned ID
@throw runtime_error if the ID does not exist*/ @throw runtime_error if the ID does not exist*/
virtual eoOp<EOT>& getOp( ID _id ) { virtual const eoOp<EOT>& getOp( ID _id ) {
MMF::iterator i=begin(); MMF::iterator i=begin();
ID j = 1; ID j = 1;
while ( (i++!=end()) && (j++ != _id) ); while ( (i++!=end()) && (j++ != _id) );
if ( i == end() ) if ( i == end() )
throw runtime_error( "No such id in eoProportionalOpSel::op\n" ); throw runtime_error( "No such id in eoProportionalOpSel::op\n" );
return *(i->second); return *(i->second);
//return i->second;
} }
/** add an operator to the operator set /** add an operator to the operator set
@ -100,6 +101,7 @@ public:
if ( i == end() ) if ( i == end() )
throw runtime_error( "Operator not found in eoProportionalOpSelector" ); throw runtime_error( "Operator not found in eoProportionalOpSelector" );
return *(i->second); return *(i->second);
//return i->second;
} }
/// Methods inherited from eoObject /// Methods inherited from eoObject
@ -115,8 +117,9 @@ public:
base classes, so you don´t have to worry about, for instance, fitness. base classes, so you don´t have to worry about, for instance, fitness.
@param _s the ostream in which things are written*/ @param _s the ostream in which things are written*/
virtual void printOn( ostream& _s ) const{ virtual void printOn( ostream& _s ) const{
_s << className() << endl;
for ( MMF::const_iterator i=begin(); i!=end(); i++ ) { for ( MMF::const_iterator i=begin(); i!=end(); i++ ) {
_s << i->first << "\t" << i->second << endl; _s << i->first << "\t" << *(i->second )<< endl;
} }
} }

View file

@ -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> Project: "t_eoid"=.\t_eoid.dsp - Package Owner=<4>
Package=<5> 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> Project: "t_opfactory"=.\t_opfactory.dsp - Package Owner=<4>
Package=<5> Package=<5>

View file

@ -65,7 +65,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 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 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 BASE RSC /l 0xc0a /d "_DEBUG"
# ADD RSC /l 0xc0a /d "_DEBUG" # ADD RSC /l 0xc0a /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe