Merge stever@zizzer:/bk/m5 into isabel.reinhardt.house:/z/stever/bk/m5
[gem5.git] / sim / sim_object.cc
index e5506ee8f4dced6903fe2ac62a55b584c68d089c..1ddb15c8267831a4bee34505d3d757141a50e4e5 100644 (file)
 
 #include <assert.h>
 
-#include "sim_object.hh"
-#include "inifile.hh"
-#include "configfile.hh"
-#include "host.hh"
-#include "misc.hh"
-#include "trace.hh"
-#include "sim_stats.hh"
-#include "stats.hh"
+#include "sim/sim_object.hh"
+#include "base/inifile.hh"
+#include "sim/configfile.hh"
+#include "sim/host.hh"
+#include "base/misc.hh"
+#include "base/trace.hh"
+#include "sim/sim_stats.hh"
 
 using namespace std;
 
@@ -63,11 +62,6 @@ SimObject::SimObject(const string &_name)
 //
 // no default statistics, so nothing to do in base implementation
 //
-void
-SimObject::reg_stats(struct stat_sdb_t *sdb)
-{
-}
-
 void
 SimObject::regStats()
 {
@@ -87,7 +81,9 @@ SimObject::printExtraOutput(ostream &os)
 }
 
 //
-// static function: call reg_stats() on all SimObjects.
+// static function:
+//   call regStats() on all SimObjects and then regFormulas() on all
+//   SimObjects.
 //
 void
 SimObject::regAllStats()
@@ -102,7 +98,6 @@ SimObject::regAllStats()
 #ifdef STAT_DEBUG
         cprintf("registering stats for %s\n", (*i)->name());
 #endif
-        (*i)->reg_stats(sim_sdb);
         (*i)->regStats();
     }
 
@@ -126,155 +121,3 @@ SimObject::printAllExtraOutput(ostream &os)
         (*i)->printExtraOutput(os);
    }
 }
-
-///////////////////////////////////////////
-//
-// SimObjectBuilder member definitions
-//
-///////////////////////////////////////////
-
-// override ParamContext::parseParams() to check params based on
-// instance name first.  If not found, then check based on iniSection
-// (as in default ParamContext implementation).
-void
-SimObjectBuilder::parseParams(IniFile &iniFile)
-{
-    iniFilePtr = &iniFile;     // set object member
-
-    ParamList::iterator i;
-
-    for (i = paramList->begin(); i != paramList->end(); ++i) {
-        string string_value;
-
-        if (iniFile.findDefault(instanceName, (*i)->name, string_value)) {
-            (*i)->parse(string_value);
-        }
-        else if (iniFile.findDefault(iniSection, (*i)->name, string_value)) {
-            (*i)->parse(string_value);
-        }
-    }
-}
-
-
-void
-SimObjectBuilder::printErrorProlog(ostream &os)
-{
-    os << "Error creating object '" << getInstanceName()
-       << "' of type '" << simObjClassName
-       << "', section '" << iniSection << "':" << endl;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-//
-// SimObjectClass member definitions
-//
-////////////////////////////////////////////////////////////////////////
-
-// Map of class names to SimObjectBuilder creation functions.  Need to
-// make this a pointer so we can force initialization on the first
-// reference; otherwise, some SimObjectClass constructors may be invoked
-// before the classMap constructor.
-map<string,SimObjectClass::CreateFunc> *SimObjectClass::classMap = NULL;
-
-// SimObjectClass constructor: add mapping to classMap
-SimObjectClass::SimObjectClass(const string &className, CreateFunc createFunc)
-{
-    if (classMap == NULL)
-        classMap = new map<string,SimObjectClass::CreateFunc>();
-
-    if ((*classMap)[className])
-    {
-        cerr << "Error: simulation object class " << className << " redefined"
-             << endl;
-        fatal("");
-    }
-
-    // add className --> createFunc to class map
-    (*classMap)[className] = createFunc;
-}
-
-
-//
-//
-SimObject *
-SimObjectClass::createObject(IniFile &configDB,
-                             const string &configClassName,
-                             const string &objName,
-                             ConfigNode *configNode)
-{
-    // find simulation object class name from configuration class
-    // (specified by 'type=' parameter)
-    string simObjClassName;
-
-    if (!configDB.findDefault(configClassName, "type", simObjClassName)) {
-        cerr << "Configuration class '" << configClassName << "' not found."
-             << endl;
-        abort();
-    }
-
-    // look up className to get appropriate createFunc
-    if (classMap->find(simObjClassName) == classMap->end()) {
-        cerr << "Simulator object class '" << simObjClassName << "' not found."
-             << endl;
-        abort();
-    }
-
-    CreateFunc createFunc = (*classMap)[simObjClassName];
-
-    // call createFunc with config hierarchy node to get object
-    // builder instance (context with parameters for object creation)
-    SimObjectBuilder *objectBuilder = (*createFunc)(configClassName,
-                                                    objName, configNode,
-                                                    simObjClassName);
-
-    assert(objectBuilder != NULL);
-
-    // parse all parameters in context to generate parameter values
-    objectBuilder->parseParams(configDB);
-
-    // now create the actual simulation object
-    SimObject *object = objectBuilder->create();
-
-    assert(object != NULL);
-
-    // echo object parameters to stats file (for documenting the
-    // config used to generate the associated stats)
-    *statStream << "[" << object->name() << "]" << endl;
-    *statStream << "type=" << simObjClassName << endl;
-    objectBuilder->showParams(*statStream);
-    *statStream << endl;
-
-    // done with the SimObjectBuilder now
-    delete objectBuilder;
-
-    return object;
-}
-
-
-//
-// static method:
-//
-void
-SimObjectClass::describeAllClasses(ostream &os)
-{
-    map<string,CreateFunc>::iterator iter;
-
-    for (iter = classMap->begin(); iter != classMap->end(); ++iter) {
-        const string &className = iter->first;
-        CreateFunc createFunc = iter->second;
-
-        os << "[" << className << "]\n";
-
-        // create dummy object builder just to instantiate parameters
-        SimObjectBuilder *objectBuilder = (*createFunc)("", "", NULL, "");
-
-        // now get the object builder to describe ite params
-        objectBuilder->describeParams(os);
-
-        os << endl;
-
-        // done with the object builder now
-        delete objectBuilder;
-    }
-}