diff options
Diffstat (limited to 'sim')
-rw-r--r-- | sim/main.cc | 4 | ||||
-rw-r--r-- | sim/sim_object.cc | 20 | ||||
-rw-r--r-- | sim/sim_object.hh | 2 |
3 files changed, 26 insertions, 0 deletions
diff --git a/sim/main.cc b/sim/main.cc index 6f6143506..aecc171ed 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -355,6 +355,10 @@ main(int argc, char **argv) echoCommandLine(argc, argv, *outputStream); ParamContext::showAllContexts(*configStream); + // Any objects that can't connect themselves until after construction should + // do so now + SimObject::connectAll(); + // Do a second pass to finish initializing the sim objects SimObject::initAll(); diff --git a/sim/sim_object.cc b/sim/sim_object.cc index f34e17fe6..151ba68a7 100644 --- a/sim/sim_object.cc +++ b/sim/sim_object.cc @@ -88,6 +88,11 @@ SimObject::SimObject(const string &_name) } void +SimObject::connect() +{ +} + +void SimObject::init() { } @@ -151,6 +156,21 @@ SimObject::regAllStats() } // +// static function: call connect() on all SimObjects. +// +void +SimObject::connectAll() +{ + SimObjectList::iterator i = simObjectList.begin(); + SimObjectList::iterator end = simObjectList.end(); + + for (; i != end; ++i) { + SimObject *obj = *i; + obj->connect(); + } +} + +// // static function: call init() on all SimObjects. // void diff --git a/sim/sim_object.hh b/sim/sim_object.hh index 59d9daf45..5db62dd51 100644 --- a/sim/sim_object.hh +++ b/sim/sim_object.hh @@ -78,7 +78,9 @@ class SimObject : public Serializable, protected StartupCallback // initialization pass of all objects. // Gets invoked after construction, before unserialize. virtual void init(); + virtual void connect(); static void initAll(); + static void connectAll(); // register statistics for this object virtual void regStats(); |