SimEngine.h

Go to the documentation of this file.
00001 #ifndef SIMENGINE_H_
00002 #define SIMENGINE_H_
00003 
00004 #include "globaldefinitions.h"
00005 #include "SpikeScheduler.h"
00006 #include "SimObjectPool.h"
00007 
00008 
00009 #include <string>
00010 using std::string;
00011 
00012 #include <boost/format.hpp>
00013 
00014 #include <iostream>
00015 using std::cout;
00016 using std::endl;
00017 using std::cerr;
00018 
00019 
00020 class SimNetwork;
00021 
00023 class SimEngine
00024 {
00025 public:
00026 
00027     class ID
00028     {
00029     public:
00030         explicit ID( nodeid_t n ) : node(n), engine(0) { };
00031         explicit ID( nodeid_t n, engineid_t e ) : node(n), engine(e) { };        
00032         explicit ID() : node(0), engine(0) { };
00033         
00034         nodeid_t node;
00035         engineid_t engine;
00036         static const ID Invalid;
00037         static const ID Zero;
00038         bool operator==(const ID& other) const
00039         {
00040             return ( this->engine == other.engine ) &&
00041                    ( this->node == other.node ) ;
00042         }
00043 
00044         bool operator!=(const ID& other) const
00045         {
00046             return ( this->engine != other.engine ) ||
00047                    ( this->node != other.node ) ;
00048         }
00049 
00050         string toString() const { return str ( boost::format("(n=%1%,e=%2%)") % node % engine ); };
00051     };
00052 
00054     SimEngine(int id, SpikeScheduler &ss, SimNetwork &net);
00055 
00056     /* Copy constructor
00057     SimEngine(const SimEngine& src) :
00058             default_steps_per_cycle(src.default_steps_per_cycle),
00059             eid(src.eid), spikeScheduler(src.spikeScheduler),
00060             simParam(src.simParam)
00061     { };
00062 
00063     SimEngine& operator=(const SimEngine& src)
00064     {
00065         *this = src;
00066         return *this;
00067     }; */
00068 
00070     virtual ~SimEngine()
00071     { /* NOOP */ };
00072 
00074     virtual void reset()=0;
00075 
00076 
00078 
00081     virtual void initialize() = 0;
00082 
00083 
00085 
00087     virtual void advance(int nSteps=1) = 0;
00088 
00089     virtual void advanceSeveralStepsWithinACycle(int nsteps) = 0;
00090 
00091     virtual void finalizeCycle()  = 0;
00092 
00093 
00095     virtual void advanceOneFullCycle() = 0;
00096 
00098 
00101     //virtual void addObject( SimObject *obj, SimObject::ID &id) = 0;
00102 
00103     virtual void addObject( SimObjectFactory const& objFactory, SimObject::ID &id ) = 0;
00104 
00105     virtual void mount( const SimObjectFactory &objFactory, const SimObject::ID &mountpoint, SimObject::ID &gid ) = 0;
00106 
00107     virtual void insert( const SimObjectFactory &objFactory, const SimObject::ID &container, SimObject::ID &gid ) = 0;
00108 
00110     virtual SimObject *getObject(const SimObject::ID &id) = 0;
00111 
00112     inline engineid_t getLocalEid() const { return eid; };
00113 
00114     inline SpikeScheduler *getSpikeScheduler() const { return &spikeScheduler; };
00115 
00116     virtual void seed( vector<uint32> const& noiseSeed )=0;
00117     virtual void seed( uint32 noiseSeed )=0;
00118     virtual void noiseRandEngineOutput( vector<uint32> & r ){};
00119     
00120 protected:
00121 
00122     int default_steps_per_cycle;
00123 
00125     engineid_t eid;
00126 
00128     SpikeScheduler &spikeScheduler;
00129 
00130     friend class SimObject;
00131     SimNetwork &network;
00132 
00133 };
00134 
00135 ostream& operator<<(ostream &s, const SimEngine::ID &id);
00136 
00137 #endif /* SIMENGINE_H_ */

Generated on Wed Jul 9 16:34:38 2008 for PCSIM by  doxygen 1.5.5