SimNetwork.h

Go to the documentation of this file.
00001 #ifndef SIMNETWORK_H_
00002 #define SIMNETWORK_H_
00003 
00004 #include <mpi.h>
00005 
00006 #ifndef SWIG
00007 
00008 #include <iostream>
00009 using std::cerr;
00010 using std::endl;
00011 
00012 #endif
00013 
00014 #include <vector>
00015 
00016 #include <cstdlib>
00017 
00018 #include "SimObject.h"
00019 #include "SimParameter.h"
00020 #include "SimEngine.h"
00021 #include "DistributionStrategy.h"
00022 #include "PCSIMException.h"
00023 #include "SimTime.h"
00024 #include "RandomEngine.h"
00025 #include "init.h"
00026 
00027 class WiringMethodSelector;
00028 class ConnectionIterator;
00029 
00030 class SimNetwork
00031 {
00032 
00033     //
00035 
00036 public:
00037     SimNetwork( MPI::Intracomm &mpiCommunicator, SimParameter sp, DistributionStrategy::DistributionFunction *df );
00038     virtual ~SimNetwork();
00040 
00041     //
00043 
00044 
00045 public:
00047 
00052     void addObject( const SimObjectFactory &model, const SimEngine::ID &engine, SimObject::ID &id )
00053     {
00054         _addObject_( model, engine, id );
00055     }
00056 
00057 protected:
00059     virtual void _addObject_( const SimObjectFactory &model, const SimEngine::ID &engine, SimObject::ID &id )
00060     {}
00061     ;
00062 
00063 public:
00065 
00070     void addObject( const SimObjectFactory &model, SimObject::ID &id )
00071     {
00072         _addObject_( model, id );
00073     }
00074 
00075 protected:
00077     virtual void _addObject_( const SimObjectFactory &model, SimObject::ID &id )
00078     {}
00079     ;
00080 
00081 public:
00083     SimObject::ID::Packed create( const SimObjectFactory &model, const SimEngine::ID &engine );
00084     SimObject::ID::Packed add
00085     ( const SimObjectFactory &model, const SimEngine::ID &engine );
00086 
00088     SimObject::ID::Packed create( const SimObjectFactory &model );
00089     SimObject::ID::Packed add
00090     ( const SimObjectFactory &model );
00091 
00093 
00094     //
00096 
00097 public:
00099     /*
00100      *  \param model A model (factory) which specifis how the instance of the object to be added is created.
00101      *  \param id  The resulting unique identifier (node,engine,type,localid) of the created object.
00102      */
00103     void mount( const SimObjectFactory &model, const SimObject::ID &mountpoint, SimObject::ID &gid );
00104 
00106     SimObject::ID::Packed mount( const SimObjectFactory &model, const SimObject::ID &mountpoint );
00107 
00109     SimObject::ID::Packed mount( const SimObjectFactory &model, const SimObject::ID::Packed &mountpoint );
00110 
00112     SimObject::ID::Vector mount( const SimObjectFactory &model, std::vector<SimObject::ID::Packed> const& mountpoints, bool collect = false );
00113 
00114 protected:
00116 
00120     virtual void _mount_( const SimObjectFactory &model, const SimObject::ID &mountpoint, SimObject::ID &gid )
00121     {}
00122     ;
00123 
00124 public:
00126     /*
00127      *  \param model A model (factory) which specifis how the instance of the object to be added is created.
00128      *  \param id  The resulting unique identifier (node,engine,type,localid) of the created object.
00129      */
00130     void insert( const SimObjectFactory &model, const SimObject::ID &container, SimObject::ID &gid );
00131 
00133     SimObject::ID::Packed insert( const SimObjectFactory &model, const SimObject::ID &container );
00134 
00136     SimObject::ID::Packed insert( const SimObjectFactory &model, const SimObject::ID::Packed &container );
00137 
00138 protected:
00140 
00144     virtual void _insert_( const SimObjectFactory &model, const SimObject::ID &container, SimObject::ID &gid )
00145     {}
00146     ;
00147 
00149 
00150     //
00152 
00153 public:
00155     SimObject::ID::Vector create( SimObjectFactory const& model, std::vector<SimEngine::ID> const& engines );
00156     SimObject::ID::Vector add
00157     ( SimObjectFactory const& model, std::vector<SimEngine::ID> const& engines );
00158 
00160     SimObject::ID::Vector create( SimObjectFactory const& model, unsigned const n);
00161     SimObject::ID::Vector add
00162     ( SimObjectFactory const& model, unsigned const n);
00163 
00165     void setDistributionStrategy( DistributionStrategy::DistributionFunction* distFunc );
00166 
00168 
00169 
00170     //
00172 
00173 public:
00174     void connect( const SimObject::ID &src, const port_t out, const SimObject::ID &dst, const port_t in, const Time &delay );
00175     void connect( const SimObject::ID::Packed &src, const port_t out, const SimObject::ID::Packed &dst, const port_t in, const Time &delay );
00176     void connect( const SimObject::ID &src, const port_t out, const SimObject::ID &dst, const port_t in  );
00177     void connect( const SimObject::ID::Packed &src, const port_t out, const SimObject::ID::Packed &dst, const port_t in  );
00179 
00180     //
00182 
00183 public:
00184     void connect( const SimObject::ID &src, const port_t out, const SimObject::ID &dst, const string in, const Time &delay );
00185     void connect( const SimObject::ID::Packed &src, const port_t out, const SimObject::ID::Packed &dst, const string in, const Time &delay );
00186     void connect( const SimObject::ID &src, const string out, const SimObject::ID &dst, const port_t in, const Time &delay );
00187     void connect( const SimObject::ID::Packed &src, const string out, const SimObject::ID::Packed &dst, const port_t in, const Time &delay );
00188     void connect( const SimObject::ID &src, const string out, const SimObject::ID &dst, const string in, const Time &delay );
00189     void connect( const SimObject::ID::Packed &src, const string out, const SimObject::ID::Packed &dst, const string in, const Time &delay );
00191 
00192 
00193     //
00195 
00196 public:
00197     void connect( const SimObject::ID &src, const SimObject::ID &dst, const Time &delay );
00198     void connect( const SimObject::ID::Packed &src, const SimObject::ID::Packed &dst, const Time &delay );
00199     void connect( const SimObject::ID &src, const SimObject::ID &dst );
00200     void connect( const SimObject::ID::Packed &src, const SimObject::ID::Packed &dst );
00202 
00203     //
00205 
00206 public:
00207     void connect( const SimObject::ID &src, const SimObject::ID &dst, const SimObjectFactory &connObjFactory, SimObject::ID &connID );
00208     SimObject::ID connect( const SimObject::ID &src, const SimObject::ID &dst, const SimObjectFactory &connObjFactory );
00209     SimObject::ID::Packed connect( const SimObject::ID::Packed &src, const SimObject::ID::Packed &dst, const SimObjectFactory &connObjFactory );
00211 
00212     //
00214 
00215 public:
00217     unsigned connect( std::vector<SimObject::ID::Packed> const& src, std::vector<SimObject::ID::Packed> const& dst, const Time &delay);
00219 
00220 
00222 
00223 public:
00225     unsigned connect( std::vector<SimObject::ID::Packed> const& src, std::vector<SimObject::ID::Packed> const& dst, ConnectionIterator & decider);
00227 
00228 
00229     //
00231 
00232 public:
00234     SimObject::ID::Vector connect( std::vector<SimObject::ID::Packed> const& src, std::vector<SimObject::ID::Packed> const& dst, const SimObjectFactory &model, ConnectionIterator & decider, bool collect = false );
00235 
00236     SimObject::ID::Vector connectFast( std::vector<SimObject::ID::Packed> const& sources, std::vector<SimObject::ID::Packed> const& destinations, const SimObjectFactory &model, ConnectionIterator & decider, bool collect = false);
00237 
00238     //
00240     //
00241 public:
00242     SimObject::ID::Packed record(const SimObject::ID::Packed & obj, const SimObjectFactory &recFactory, const port_t rec_port = 0 );
00243     SimObject::ID::Packed record(const SimObject::ID::Packed & obj, const port_t src_port, const SimObjectFactory &recFactory, const port_t rec_port = 0 );
00244     SimObject::ID::Packed record(const SimObject::ID::Packed & obj, const string field, const SimObjectFactory &recFactory, const port_t rec_port = 0);
00245 
00246 protected:
00248 
00257     virtual void _connect_( SimObject::ID const& src, port_t out, const SimObject::ID &dst, port_t in, int delay )
00258     {}
00259     ;
00260 
00262 
00263     //
00265 
00266 
00267 public:
00269     void addSpikeMessage(const SimObject::ID &sender, const port_t out, const SimObject::ID &receiver, const port_t in, const Time &delay )
00270     {
00271         _addSpikeMessage_( sender, out, receiver, in, delay );
00272     };
00273 
00274     void addAnalogMessage(const SimObject::ID &sender, int sender_port, const SimObject::ID &receiver, int recv_port, const Time &delay)
00275     {
00276         _addAnalogMessage_( sender, sender_port, receiver, recv_port, delay );
00277     };
00278 
00279     void addAnalogMessage(const SimObject::ID &sender, int sender_port, const SimObject::ID &receiver, string destfield, const Time &delay)
00280     {
00281         _addAnalogMessage_( sender, sender_port, receiver, destfield, delay );
00282     };
00283 
00284     void addAnalogMessage(const SimObject::ID &sender, string srcfield, const SimObject::ID &receiver, int recv_port, const Time &delay)
00285     {
00286         _addAnalogMessage_( sender, srcfield, receiver, recv_port, delay );
00287     };
00288 
00289     void addAnalogMessage(const SimObject::ID &sender, string srcfield, const SimObject::ID &receiver, string destfield, const Time &delay)
00290     {
00291         _addAnalogMessage_( sender, srcfield, receiver, destfield, delay );
00292     };
00293 
00294 protected:
00295 
00297     virtual void _addSpikeMessage_(const SimObject::ID &sender, const port_t out, const SimObject::ID &receiver, const port_t in, const Time &delay )
00298     {}
00299     ;
00300     virtual void _addAnalogMessage_(const SimObject::ID &sender, int sender_port, const SimObject::ID &receiver, int recv_port, const Time &delay)
00301     {}
00302     ;
00303     virtual void _addAnalogMessage_(const SimObject::ID &sender, int sender_port, const SimObject::ID &receiver, string destfield, const Time &delay)
00304     {}
00305     ;
00306     virtual void _addAnalogMessage_(const SimObject::ID &sender, string srcfield, const SimObject::ID &receiver, int recv_port, const Time &delay)
00307     {}
00308     ;
00309     virtual void _addAnalogMessage_(const SimObject::ID &sender, string srcfield, const SimObject::ID &receiver, string destfield, const Time &delay)
00310     {}
00311     ;
00312 
00314 
00315     //
00317 
00318 
00319 public:
00320 
00322     template< class T >
00323     bool getObject( const SimObject::ID &id, T &p );
00324 
00326     template< class T >
00327     bool getObject( const SimObject::ID::Packed &id, T &p );
00328 
00329     SimObject *object(const SimObject::ID &id);
00330     SimObject *object(const SimObject::ID::Packed &id);
00331 
00332     SimObject *getObject(const SimObject::ID &id)
00333     {
00334         return _getObject_( id );
00335     }
00336 
00337 protected:
00339 
00340     virtual SimObject *_getObject_(const SimObject::ID &id)
00341     {
00342         return NULL;
00343     };
00345 
00347 
00348     //
00350 
00351 
00352 public:
00354     void initialize()
00355     {
00356         _initialize_();
00357     };
00358 
00359 protected:
00360 
00361     virtual void _initialize_()
00362     {}
00363     ;
00364 
00365 public:
00366 
00367     void reset()
00368     {
00369         _reset_();
00370     };
00371 
00372 protected:
00373 
00374     virtual void _reset_()
00375     {}
00376     ;
00377 
00378 public:
00379 
00380     void advance(int nSteps = 1)
00381     {
00382         _advance_( nSteps );
00383     };
00384 
00385     void simulate( const Time &T )
00386     {
00387         _advance_(  T.in_steps( get_dt() ) );
00388     };
00389 
00390     void simulate( double T )
00391     {
00392         _advance_(  int( T / get_dt().in_sec() + 0.5  ) );
00393     };
00394 
00395 protected:
00396 
00397     virtual void _advance_(int nSteps = 1)
00398     {}
00399     ;
00400 
00401 public:
00402 
00403     void set_dt(const Time &dt);
00404 
00405     Time get_dt() const;
00407 
00408 public:
00409 
00411     int mpi_rank()
00412     {
00413         return _mpi_rank;
00414     };
00415 
00417     int mpi_size()
00418     {
00419         return _mpi_size;
00420     };
00421 
00422     unsigned nSpikeMessage()
00423     {
00424         return _nSpikeMessages;
00425     };
00426 
00427     unsigned nAnalogMessages()
00428     {
00429         return _nAnalogMessages;
00430     };
00431 
00432     const SimParameter& simParameter()
00433     {
00434         return simParam;
00435     };
00436 
00437     RandomEngine * getMainConstructRNGEngine()
00438     {
00439         return constructMainRNDEngine;
00440     };
00441 
00442     std::vector< RandomEngine* > & getIncomingConstructRNGEngines()
00443     {
00444         return constructIncomingRNGEngines;
00445     }
00446 
00447     std::vector< RandomEngine* > & getOutgoingConstructRNGEngines()
00448     {
00449         return constructOutgoingRNGEngines;
00450     }
00451 
00452     RandomEngine *  getObjectVariationRNDEngine()
00453     {
00454         return objectVariationRNDEngine;
00455     }
00456 
00457     void seed( uint32 noiseRNGseed )
00458     {
00459         seed_noise_rng( noiseRNGseed );
00460     };
00461 
00462 public:
00464     virtual gl_engineid_t maxLocalEngineID(void) const
00465     {
00466         return 0;
00467     };
00468 
00469 protected:
00470 
00471     virtual void _change_timestep_width_(const Time &old_dt, const Time &new_dt)
00472     {
00473         /* NOOP */
00474     };
00475 
00476     SimParameter simParam;
00477 
00479     DistributionStrategy::DistributionFunction* distributionStrategy;
00480 
00482     int _mpi_rank;
00483 
00485     int _mpi_size;
00486 
00488     bool initialized;
00489 
00491     bool reseted;
00492 
00494     unsigned _nSpikeMessages;
00495 
00497     unsigned _nAnalogMessages;
00498 
00499     virtual uint32 getUniqueSeedOverMpi( uint32 seed );
00500 
00501     uint32 makeSeed( uint32 seed_or_negative );
00502 
00503     virtual void seed_noise_rng( uint32 noiseRNGseed )
00504     {}
00505     ;
00506 
00507     void fillSeedVector( uint32 noiseRNGseed,  std::vector<uint32> &sim_seeds );
00508 
00509     typedef LaggedFibonacci607 simRNGSeedGenerator_t;
00510     simRNGSeedGenerator_t simRNGSeedGenerator;
00511     uint32 getSeedFromGenerator();
00512 
00513     void setupConstructRNGEngines();
00514 
00516     RandomEngine *constructMainRNDEngine;
00517 
00519     RandomEngine *objectVariationRNDEngine;
00520 
00522     std::vector< RandomEngine * > constructIncomingRNGEngines;
00523     std::vector< RandomEngine * > constructOutgoingRNGEngines;
00524 
00525 private:
00526     friend class NoiseRandomEngineTest;
00527     virtual void noiseRandEngineOutput( std::vector<uint32> & r )
00528     {}
00529     ;
00530     WiringMethodSelector *wiringMethods;
00531 
00532 };
00533 
00534 #ifndef SWIG
00535 
00541 inline SimObject::ID::Packed SimNetwork::add
00542 ( const SimObjectFactory &model, const SimEngine::ID &engine )
00543 {
00544     SimObject::ID id;
00545     addObject( model, engine, id );
00546     return id.packed();
00547 }
00548 
00554 inline SimObject::ID::Packed SimNetwork::add
00555 ( const SimObjectFactory &model )
00556 {
00557     SimObject::ID id;
00558     addObject( model, id );
00559     return id.packed();
00560 }
00561 
00562 // Aliases for add
00563 
00564 inline SimObject::ID::Packed SimNetwork::create( const SimObjectFactory &model, const SimEngine::ID &engine )
00565 {
00566     return add
00567            ( model, engine );
00568 }
00569 
00570 inline SimObject::ID::Packed SimNetwork::create( const SimObjectFactory &model )
00571 {
00572     return add
00573            ( model );
00574 }
00575 
00576 inline SimObject::ID::Vector SimNetwork::create( SimObjectFactory const& model, std::vector<SimEngine::ID> const& engines )
00577 {
00578     return add
00579            ( model, engines );
00580 }
00581 
00582 inline SimObject::ID::Vector SimNetwork::create( SimObjectFactory const& model, unsigned const n)
00583 {
00584     return add
00585            ( model, n );
00586 }
00587 
00588 inline void SimNetwork::mount( const SimObjectFactory &model, const SimObject::ID &mountpoint, SimObject::ID &gid )
00589 {
00590     _mount_( model, mountpoint, gid );
00591 }
00592 
00593 
00599 inline SimObject::ID::Packed  SimNetwork::mount( const SimObjectFactory &model, const SimObject::ID &mountpoint )
00600 {
00601     SimObject::ID id;
00602     mount( model, mountpoint, id);
00603     return id.packed();
00604 }
00605 
00611 inline SimObject::ID::Packed  SimNetwork::mount( const SimObjectFactory &model, const SimObject::ID::Packed &mountpoint )
00612 {
00613     SimObject::ID id;
00614     mount( model, *reinterpret_cast<const SimObject::ID*>(&mountpoint), id);
00615     return id.packed();
00616 }
00617 
00618 inline void SimNetwork::insert( const SimObjectFactory &model, const SimObject::ID &container, SimObject::ID &gid )
00619 {
00620     _insert_( model, container, gid );
00621 }
00622 
00628 inline SimObject::ID::Packed SimNetwork::insert( const SimObjectFactory &model, const SimObject::ID &container )
00629 {
00630     SimObject::ID id;
00631     insert( model, container, id);
00632     return id.packed();
00633 }
00634 
00640 inline SimObject::ID::Packed SimNetwork::insert( const SimObjectFactory &model, const SimObject::ID::Packed &container )
00641 {
00642     SimObject::ID id;
00643     insert( model, *reinterpret_cast<const SimObject::ID*>(&container), id);
00644     return id.packed();
00645 }
00646 
00648 
00652 inline void SimNetwork::setDistributionStrategy( DistributionStrategy::DistributionFunction* distFunc )
00653 {
00654     distributionStrategy = distFunc;
00655 }
00656 
00658 
00665 inline void SimNetwork::connect( const SimObject::ID &src, const port_t out, const SimObject::ID &dst, const port_t in, const Time & delay )
00666 {
00667     _connect_( src, out, dst, in, delay.in_steps( get_dt() ) );
00668 }
00669 
00671 
00678 inline void SimNetwork::connect( const SimObject::ID::Packed &src, const port_t out, const SimObject::ID::Packed &dst, const port_t in, const Time & delay )
00679 {
00680     _connect_( *reinterpret_cast<const SimObject::ID*>(&src), out, *reinterpret_cast<const SimObject::ID*>(&dst), in, delay.in_steps( get_dt() ) );
00681 }
00682 
00684 
00690 inline void SimNetwork::connect( const SimObject::ID &src, const port_t out, const SimObject::ID &dst, const port_t in  )
00691 {
00692     _connect_( src, out, dst, in, -1 );
00693 }
00694 
00696 
00702 inline void SimNetwork::connect( const SimObject::ID::Packed &src, const port_t out, const SimObject::ID::Packed &dst, const port_t in  )
00703 {
00704     _connect_( *reinterpret_cast<const SimObject::ID*>(&src), out, *reinterpret_cast<const SimObject::ID*>(&dst), in, -1 );
00705 }
00706 
00708 /*
00709  * \param src The sending object
00710  * \param dst The receiving object
00711  * \param delay Specifies how much the message should be delayed
00712  */
00713 inline void SimNetwork::connect( const SimObject::ID &src, const SimObject::ID &dst, const Time & delay )
00714 {
00715     _connect_( src, 0, dst, 0, delay.in_steps( get_dt() ) );
00716 }
00717 
00719 /*
00720  * \param src The sending object
00721  * \param dst The receiving object
00722  * \param delay Specifies how much the message should be delayed
00723  */
00724 inline void SimNetwork::connect( const SimObject::ID::Packed &src, const SimObject::ID::Packed &dst, const Time & delay )
00725 {
00726     _connect_( *reinterpret_cast<const SimObject::ID*>(&src), 0, *reinterpret_cast<const SimObject::ID*>(&dst), 0, delay.in_steps( get_dt() ) );
00727 }
00728 
00730 
00734 inline void SimNetwork::connect( const SimObject::ID &src, const SimObject::ID &dst )
00735 {
00736     _connect_( src, 0, dst, 0, -1 );
00737 }
00738 
00740 
00744 inline void SimNetwork::connect( const SimObject::ID::Packed &src, const SimObject::ID::Packed &dst )
00745 {
00746     _connect_( *reinterpret_cast<const SimObject::ID*>(&src), 0, *reinterpret_cast<const SimObject::ID*>(&dst), 0, -1 );
00747 }
00748 
00750 
00757 inline void SimNetwork::connect( const SimObject::ID &src, const SimObject::ID &dst, const SimObjectFactory &connector, SimObject::ID &connID )
00758 {
00759     _insert_( connector, dst, connID );
00760     _connect_( src, 0, connID, 0, -1 );
00761 }
00762 
00764 
00771 inline SimObject::ID SimNetwork::connect( const SimObject::ID &src, const SimObject::ID &dst, const SimObjectFactory &connector )
00772 {
00773     SimObject::ID id;
00774     connect( src, dst, connector, id );
00775     return id;
00776 }
00777 
00779 
00786 inline SimObject::ID::Packed SimNetwork::connect( const SimObject::ID::Packed &src, const SimObject::ID::Packed &dst, const SimObjectFactory &connector )
00787 {
00788     SimObject::ID id;
00789     connect( *reinterpret_cast<const SimObject::ID*>(&src), *reinterpret_cast<const SimObject::ID*>(&dst), connector, id );
00790     return id.packed();
00791 }
00792 
00793 
00795 
00802 inline void SimNetwork::connect( const SimObject::ID &src, const port_t out, const SimObject::ID &dest, const string in, const Time &delay )
00803 {
00804     addAnalogMessage(src, out, dest, in, delay);
00805 }
00806 
00808 
00815 inline void SimNetwork::connect( const SimObject::ID::Packed &src, const port_t out, const SimObject::ID::Packed &dest, const string in, const Time &delay )
00816 {
00817     addAnalogMessage(reinterpret_cast<const SimObject::ID&>(src), out, reinterpret_cast<const SimObject::ID&>(dest), in, delay);
00818 }
00819 
00821 
00828 inline void SimNetwork::connect( const SimObject::ID &src, const string out, const SimObject::ID &dest, const port_t in, const Time &delay )
00829 {
00830     addAnalogMessage(src, out, dest, in, delay);
00831 }
00832 
00834 
00841 inline void SimNetwork::connect( const SimObject::ID::Packed &src, const string out, const SimObject::ID::Packed &dest, const port_t in, const Time &delay )
00842 {
00843     addAnalogMessage(reinterpret_cast<const SimObject::ID&>(src), out, reinterpret_cast<const SimObject::ID&>(dest), in, delay);
00844 }
00845 
00847 
00854 inline void SimNetwork::connect( const SimObject::ID &src, const string out, const SimObject::ID &dest, const string in, const Time &delay )
00855 {
00856     addAnalogMessage(src, out, dest, in, delay);
00857 }
00858 
00860 
00867 inline void SimNetwork::connect( const SimObject::ID::Packed &src, const string out, const SimObject::ID::Packed &dest, const string in, const Time &delay )
00868 {
00869     addAnalogMessage(reinterpret_cast<const SimObject::ID&>(src), out, reinterpret_cast<const SimObject::ID&>(dest), in, delay);
00870 }
00871 
00873 
00881 inline SimObject::ID::Packed SimNetwork::record(const SimObject::ID::Packed & obj, const port_t src_port, const SimObjectFactory &recFactory, const port_t rec_port )
00882 {
00883     SimObject::ID obj_id(obj);
00884     SimObject::ID::Packed rec = create( recFactory, SimEngine::ID(obj_id.node, obj_id.eng) );
00885     connect(obj,0,rec,rec_port, Time::sec(0));
00886     return rec;
00887 }
00888 
00890 
00897 inline SimObject::ID::Packed SimNetwork::record( const SimObject::ID::Packed &obj, const SimObjectFactory &recFactory, const port_t rec_port )
00898 {
00899     return record(obj,0,recFactory,rec_port);
00900 }
00901 
00902 
00903 
00905 
00913 inline SimObject::ID::Packed SimNetwork::record(const SimObject::ID::Packed & obj, const string field, const SimObjectFactory &recFactory, const port_t rec_port )
00914 {
00915     SimObject::ID obj_id(obj);
00916     SimObject::ID::Packed rec = create( recFactory, SimEngine::ID(obj_id.node, obj_id.eng) );
00917     connect(obj,field,rec,rec_port, Time::sec(0));
00918     return rec;
00919 }
00920 
00921 
00922 inline void SimNetwork::set_dt(const Time &dt)
00923 {
00924     if( _nSpikeMessages + _nAnalogMessages == 0 ) {
00925         _change_timestep_width_( simParam.dt, dt );
00926         reset();
00927         simParam.dt = dt;
00928     } else {
00929         // TODO: This needs to be inserted. However therefor some of the cppunit tests need to be fixed!
00930         // throw( PCSIM::ConstructionException( "SimNetwork::set_dt", "Time step width can not be changed after set up of connections." ) );
00931     }
00932 }
00933 
00934 
00935 
00936 
00937 inline Time SimNetwork::get_dt() const
00938 {
00939     return simParam.dt;
00940 }
00941 
00942 template< class T >
00943 inline bool SimNetwork::getObject( const SimObject::ID &id, T &p )
00944 {
00945     p = dynamic_cast<T>( _getObject_( id ) );
00946     return ( p != NULL );
00947 }
00948 
00949 template< class T >
00950 inline bool SimNetwork::getObject( const SimObject::ID::Packed &id, T &p )
00951 {
00952     p = dynamic_cast<T>( _getObject_( SimObject::ID( id ) ) );
00953     return ( p != NULL );
00954 }
00955 
00956 inline SimObject *SimNetwork::object(const SimObject::ID::Packed &id)
00957 {
00958     return _getObject_( *reinterpret_cast<const SimObject::ID*>(&id) );
00959 }
00960 
00961 inline SimObject *SimNetwork::object(const SimObject::ID &id)
00962 {
00963     return _getObject_( id );
00964 }
00965 
00966 #endif
00967 
00968 #endif /*SIMNETWORK_H_*/

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