Merge zizzer:/bk/m5 into zeep.eecs.umich.edu:/z/saidi/work/m5
[gem5.git] / sim / param.hh
index fb2c9dd447d28e0d320c42b3f66db933f74f096b..ac57afa311208e07373c53e2482d95d900c2c649 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2002-2003 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <vector>
 
 #include "sim/configfile.hh"
+#include "sim/startup.hh"
 
 // forward decls
 class BaseParam;
 class SimObject;
-struct stat_sdb_t;
 
 //
 // The context of a parameter definition... usually a subclass of
 // SimObjectBuilder (which derives from ParamContext), but abstracted
 // here to support more global simulator control parameters as well.
 //
-class ParamContext
+class ParamContext : protected StartupCallback
 {
   private:
 
@@ -75,11 +75,30 @@ class ParamContext
 
   public:
 
-    // Second arg, if set to true, says don't put on paramContextList
-    // (i.e. don't automatically parse params).  Used by derived
-    // SimObjectBuilder class, where parsing is done in
-    // SimObject::create()
-    ParamContext(const std::string &_iniSection, bool noAutoParse = false);
+    /// Initialization phases for ParamContext objects.
+    enum InitPhase {
+        NoAutoInit = -1,       ///< Don't initialize at all... params
+                                /// will be parsed later (used by
+                                /// SimObjectBuilder, which parses
+                                /// params in SimObject::create().
+        OutputInitPhase = 0,   ///< Output stream initialization
+        TraceInitPhase = 1,    ///< Trace context initialization:
+                                /// depends on output streams, but
+                                /// needs to come before others so we
+                                /// can use tracing in other
+                                /// ParamContext init code
+        StatsInitPhase = 2,    ///< Stats output initialization
+        DefaultInitPhase = 3   ///< Everything else
+    };
+
+    /// Records the initialization phase for this ParamContext.
+    InitPhase initPhase;
+
+    /// Constructor.
+    /// @param _iniSection Name of .ini section corresponding to this context.
+    /// @param _initPhase Initialization phase  (see InitPhase).
+    ParamContext(const std::string &_iniSection,
+                 InitPhase _initPhase = DefaultInitPhase);
 
     virtual ~ParamContext() {}
 
@@ -754,4 +773,13 @@ SimObjectVectorParam<OBJ_CLASS *>::showType(std::ostream &os) const        \
     os << "vector of " << CLASS_NAME;                                  \
 }
 
+
+//
+// Declarations for low-level parsing & displaying functions.  These
+// are used internally, but should not be used directly by clients of
+// the parameter mechanism, but are declared here so they can be
+// shared with the serialization code (see sim/serialize.cc).
+template <class T> bool parseParam(const std::string &str, T &data);
+template <class T> void showParam(std::ostream &os, const T &data);
+
 #endif // _PARAM_HH