Made sure the constructor for insts use ExtMachInst rather than MachInst, since other...
[gem5.git] / src / sim / builder.hh
index 8d08461557624ca4803b0717ffa0e8afb2232c30..aa0e3d17c613ea61d56e24f9256834ee67e72330 100644 (file)
@@ -55,14 +55,8 @@ class SimObject;
 //
 class SimObjectBuilder : public ParamContext
 {
-  private:
-    // The corresponding node in the configuration hierarchy.
-    // (optional: may be null if the created object is not in the
-    // hierarchy)
-    ConfigNode *configNode;
-
   public:
-    SimObjectBuilder(ConfigNode *_configNode);
+    SimObjectBuilder(const std::string &_iniSection);
 
     virtual ~SimObjectBuilder();
 
@@ -77,9 +71,6 @@ class SimObjectBuilder : public ParamContext
     // configuration hierarchy node label and position)
     virtual const std::string &getInstanceName() { return iniSection; }
 
-    // return the configuration hierarchy node for this context.
-    virtual ConfigNode *getConfigNode() { return configNode; }
-
     // Create the actual SimObject corresponding to the parameter
     // values in this context.  This function is overridden in derived
     // classes to call a specific constructor for a particular
@@ -125,7 +116,7 @@ class SimObjectClass
     // for the object (specified by the second string argument), and
     // an optional config hierarchy node (specified by the third
     // argument).  A pointer to the new SimObjectBuilder is returned.
-    typedef SimObjectBuilder *(*CreateFunc)(ConfigNode *configNode);
+    typedef SimObjectBuilder *(*CreateFunc)(const std::string &iniSection);
 
     static std::map<std::string,CreateFunc> *classMap;
 
@@ -137,7 +128,8 @@ class SimObjectClass
 
     // create SimObject given name of class and pointer to
     // configuration hierarchy node
-    static SimObject *createObject(IniFile &configDB, ConfigNode *configNode);
+    static SimObject *createObject(IniFile &configDB,
+                                   const std::string &iniSection);
 
     // print descriptions of all parameters registered with all
     // SimObject classes
@@ -156,15 +148,15 @@ class OBJ_CLASS##Builder : public SimObjectBuilder                \
 
 #define END_DECLARE_SIM_OBJECT_PARAMS(OBJ_CLASS)               \
                                                                 \
-    OBJ_CLASS##Builder(ConfigNode *configNode);                        \
+    OBJ_CLASS##Builder(const std::string &iniSection);          \
     virtual ~OBJ_CLASS##Builder() {}                           \
                                                                 \
     OBJ_CLASS *create();                                       \
 };
 
 #define BEGIN_INIT_SIM_OBJECT_PARAMS(OBJ_CLASS)                        \
-OBJ_CLASS##Builder::OBJ_CLASS##Builder(ConfigNode *configNode) \
-    : SimObjectBuilder(configNode),
+    OBJ_CLASS##Builder::OBJ_CLASS##Builder(const std::string &iSec) \
+    : SimObjectBuilder(iSec),
 
 
 #define END_INIT_SIM_OBJECT_PARAMS(OBJ_CLASS)                  \
@@ -176,9 +168,9 @@ OBJ_CLASS *OBJ_CLASS##Builder::create()
 
 #define REGISTER_SIM_OBJECT(CLASS_NAME, OBJ_CLASS)             \
 SimObjectBuilder *                                             \
-new##OBJ_CLASS##Builder(ConfigNode *configNode)                        \
+new##OBJ_CLASS##Builder(const std::string &iniSection)          \
 {                                                              \
-    return new OBJ_CLASS##Builder(configNode);                 \
+    return new OBJ_CLASS##Builder(iniSection);                 \
 }                                                              \
                                                                 \
 SimObjectClass the##OBJ_CLASS##Class(CLASS_NAME,               \
@@ -187,5 +179,45 @@ SimObjectClass the##OBJ_CLASS##Class(CLASS_NAME,           \
 /* see param.hh */                                             \
 DEFINE_SIM_OBJECT_CLASS_NAME(CLASS_NAME, OBJ_CLASS)
 
+/* Macros that use the namespace for sinic... yuk. */
+#define BEGIN_DECLARE_SIM_OBJECT_PARAMS_WNS(NAME_SPACE, OBJ_CLASS)             \
+class NAME_SPACE##OBJ_CLASS##Builder : public SimObjectBuilder         \
+{                                                              \
+  public:
+
+#define END_DECLARE_SIM_OBJECT_PARAMS_WNS(NAME_SPACE, OBJ_CLASS)               \
+                                                                \
+    NAME_SPACE##OBJ_CLASS##Builder(const std::string &iniSection);          \
+    virtual ~NAME_SPACE##OBJ_CLASS##Builder() {}                               \
+                                                                \
+    NAME_SPACE::OBJ_CLASS *create();                                   \
+};
+
+#define BEGIN_INIT_SIM_OBJECT_PARAMS_WNS(NAME_SPACE, OBJ_CLASS)                        \
+    NAME_SPACE::OBJ_CLASS##Builder::OBJ_CLASS##Builder(const std::string &iSec) \
+    : SimObjectBuilder(iSec),
+
+
+#define END_INIT_SIM_OBJECT_PARAMS_WNS(NAME_SPACE, OBJ_CLASS)                  \
+{                                                              \
+}
+
+#define CREATE_SIM_OBJECT_WNS(NAME_SPACE, OBJ_CLASS)                           \
+NAME_SPACE::OBJ_CLASS *NAME_SPACE##OBJ_CLASS##Builder::create()
+
+#define REGISTER_SIM_OBJECT_WNS(NAME_SPACE, CLASS_NAME, OBJ_CLASS)             \
+SimObjectBuilder *                                             \
+new##NAME_SPACEi##OBJ_CLASS##Builder(const std::string &iniSection)          \
+{                                                              \
+    return new NAME_SPACE##OBJ_CLASS##Builder(iniSection);                     \
+}                                                              \
+                                                                \
+SimObjectClass the##NAME_SPACE##OBJ_CLASS##Class(CLASS_NAME,           \
+                                     new##NAME_SPACE##OBJ_CLASS##Builder);     \
+                                                                \
+/* see param.hh */                                             \
+DEFINE_SIM_OBJECT_CLASS_NAME(CLASS_NAME, NAME_SPACE##OBJ_CLASS)
+
+
 
 #endif // __BUILDER_HH__