SingleThreadSimEngine.h

Go to the documentation of this file.
00001 #ifndef SINGLETHREADSIMENGINE_H_
00002 #define SINGLETHREADSIMENGINE_H_
00003 
00004 #include <vector>
00005 #include <boost/random.hpp>
00006 #include <iostream>
00007 using std::cerr;
00008 using std::endl;
00009 
00010 #include "SimObject.h"
00011 #include "SimEngine.h"
00012 #include "SpikeOutputPort.h"
00013 #include "AnalogMessageDispatcher.h"
00014 #include "SimTime.h"
00015 #include "ThreadSpecificRandomEngine.h"
00016 
00017 class SimNetwork;
00018 
00020 class SingleThreadSimEngine : public SimEngine
00021 {
00022 
00023 public:
00024     
00025     SingleThreadSimEngine(int ID, SpikeScheduler &scheduler, AnalogMessageDispatcher &analogMsgDispatcher, SimNetwork &net);
00026 
00027     virtual ~SingleThreadSimEngine();
00028 
00029     SimObjectPool* getPool()
00030     {
00031         return &objPool;
00032     }
00033 
00034     virtual void reset();
00035 
00036     virtual void initialize();
00037 
00038     virtual void advance(int nSteps=1) ;
00039 
00040     virtual void advanceOneFullCycle();
00041 
00042     virtual void advanceSeveralStepsWithinACycle(int nsteps);
00043 
00044     virtual void finalizeCycle();
00045 
00046     virtual void addObject( SimObjectFactory const& objFactory, SimObject::ID &id );
00047 
00048     virtual SimObject *getObject(const SimObject::ID & id);
00049 
00050     virtual void mount( const SimObjectFactory &objFactory, const SimObject::ID &mountpoint, SimObject::ID &gid );
00051     virtual void insert( const SimObjectFactory &objFactory, const SimObject::ID &container, SimObject::ID &gid );
00052 
00054     void two_way_link( const SimObject::ID &o1, const SimObject::ID &o2 );
00055 
00057     void one_way_link( const SimObject::ID &src, const SimObject::ID &dst );
00058 
00060 
00061     virtual void seed( vector<uint32> const& noiseSeed );
00062     virtual void seed( uint32 noiseSeed );
00063     ThreadSpecificRandomEngineType *noiseRandomEngine() const { return noiseRNDEngine; };
00065 
00066     const Time &getSimulationTime() const { return t; };
00067 
00068 
00069 protected:
00070     void addSpikePorts( SimObject *obj, SimObject::ID &id );
00071 
00072 private:
00073 
00075     SpikeReceiverList activeSpikeReceiver;
00076 
00078     Time t;
00079 
00080 
00082     int step;
00083 
00085     bool dtHasChanged;
00086 
00087     bool initialized;
00088 
00090     bool isReset;
00091 
00093     // bool exactSpikeTiming;
00094 
00096     // SimpleRandomNumberGenerator *srng;
00097 
00099     ThreadSpecificRandomEngineType *noiseRNDEngine;
00100 
00102     bool objectListsDirty;
00103 
00105     AnalogMessageDispatcher &analog_msg_dispatcher;
00106 
00108     SimObjectPool objPool;
00109 
00110     // vector< SpikeOutputPort * > spikeOutputPorts;
00111 
00112     unsigned nSpikeOutputPorts;
00113 
00114 
00115     // Old TESTING CODE : IGNORE
00116     //SimObject ** narray;
00117 
00118     //int narray_size;
00119 
00120 };
00121 
00122 inline SimObject *SingleThreadSimEngine::getObject(const SimObject::ID & id)
00123 {
00124     return objPool.getObject(id.type, id.localid);
00125 }
00126 
00127 #endif /* SINGLETHREADSIMENGINE_H_ */

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