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
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00070 virtual ~SimEngine()
00071 { };
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
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