Get rid of the stand alone ParamContext since all of the

relevant stuff has now been moved to python.

--HG--
extra : convert_revision : 608e5ffd0e2b33949a2b183117216f136cfa4484
This commit is contained in:
Nathan Binkert 2007-02-18 09:31:25 -08:00
parent ee93b48314
commit 4e7f8c0885
6 changed files with 11 additions and 182 deletions

View file

@ -253,7 +253,7 @@ def gen_hh(filename):
print >>hhfile, ''' print >>hhfile, '''
// The remaining enum values are *not* valid indices for Trace::flags. // The remaining enum values are *not* valid indices for Trace::flags.
// They are "compound" flags, which correspond to sets of base // They are "compound" flags, which correspond to sets of base
// flags, and are used only by TraceParamContext::setFlags(). // flags, and are used by changeFlag.
''', ''',
for flag in compoundFlags: for flag in compoundFlags:

View file

@ -653,15 +653,13 @@ class SimObject(object):
instanceDict[self.path()] = self instanceDict[self.path()] = self
if hasattr(self, 'type') and not isinstance(self, ParamContext): if hasattr(self, 'type'):
print 'type=%s' % self.type print 'type=%s' % self.type
child_names = self._children.keys() child_names = self._children.keys()
child_names.sort() child_names.sort()
np_child_names = [c for c in child_names \ if len(child_names):
if not isinstance(self._children[c], ParamContext)] print 'children=%s' % ' '.join(child_names)
if len(np_child_names):
print 'children=%s' % ' '.join(np_child_names)
param_names = self._params.keys() param_names = self._params.keys()
param_names.sort() param_names.sort()
@ -711,8 +709,7 @@ class SimObject(object):
def startDrain(self, drain_event, recursive): def startDrain(self, drain_event, recursive):
count = 0 count = 0
# ParamContexts don't serialize if isinstance(self, SimObject):
if isinstance(self, SimObject) and not isinstance(self, ParamContext):
count += self._ccObject.drain(drain_event) count += self._ccObject.drain(drain_event)
if recursive: if recursive:
for child in self._children.itervalues(): for child in self._children.itervalues():
@ -720,7 +717,7 @@ class SimObject(object):
return count return count
def resume(self): def resume(self):
if isinstance(self, SimObject) and not isinstance(self, ParamContext): if isinstance(self, SimObject):
self._ccObject.resume() self._ccObject.resume()
for child in self._children.itervalues(): for child in self._children.itervalues():
child.resume() child.resume()
@ -782,9 +779,6 @@ class SimObject(object):
for c in self.children: for c in self.children:
c.outputDot(dot) c.outputDot(dot)
class ParamContext(SimObject):
pass
# Function to provide to C++ so it can look up instances based on paths # Function to provide to C++ so it can look up instances based on paths
def resolveSimObject(name): def resolveSimObject(name):
obj = instanceDict[name] obj = instanceDict[name]
@ -793,7 +787,7 @@ def resolveSimObject(name):
# __all__ defines the list of symbols that get exported when # __all__ defines the list of symbols that get exported when
# 'from config import *' is invoked. Try to keep this reasonably # 'from config import *' is invoked. Try to keep this reasonably
# short to avoid polluting other namespaces. # short to avoid polluting other namespaces.
__all__ = ['SimObject', 'ParamContext'] __all__ = ['SimObject']
# see comment on imports at end of __init__.py. # see comment on imports at end of __init__.py.
import proxy import proxy

View file

@ -40,7 +40,7 @@
using namespace std; using namespace std;
SimObjectBuilder::SimObjectBuilder(const std::string &_iniSection) SimObjectBuilder::SimObjectBuilder(const std::string &_iniSection)
: ParamContext(_iniSection, NoAutoInit) : ParamContext(_iniSection)
{ {
} }

View file

@ -272,13 +272,6 @@ connectPorts(SimObject *o1, const std::string &name1, int i1,
void void
finalInit() finalInit()
{ {
// Parse and check all non-config-hierarchy parameters.
ParamContext::parseAllContexts(inifile);
ParamContext::checkAllContexts();
// Echo all parameter settings to stats file as well.
ParamContext::showAllContexts(*configStream);
// Do a second pass to finish initializing the sim objects // Do a second pass to finish initializing the sim objects
SimObject::initAll(); SimObject::initAll();
@ -462,8 +455,6 @@ doExitCleanup()
cout.flush(); cout.flush();
ParamContext::cleanupAllContexts();
// print simulation stats // print simulation stats
Stats::dump(); Stats::dump();
} }

View file

@ -583,30 +583,10 @@ SimObjectBaseParam::parse(const string &s, vector<SimObject *>&value)
// //
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
list<ParamContext *> *ParamContext::ctxList = NULL; ParamContext::ParamContext(const string &_iniSection)
ParamContext::ParamContext(const string &_iniSection, InitPhase _initPhase)
: iniFilePtr(NULL), // initialized on call to parseParams() : iniFilePtr(NULL), // initialized on call to parseParams()
iniSection(_iniSection), paramList(NULL), iniSection(_iniSection), paramList(NULL)
initPhase(_initPhase)
{ {
// Put this context on global list for initialization
if (initPhase != NoAutoInit) {
if (ctxList == NULL)
ctxList = new list<ParamContext *>();
// keep list sorted by ascending initPhase values
list<ParamContext *>::iterator i = ctxList->begin();
list<ParamContext *>::iterator end = ctxList->end();
for (; i != end; ++i) {
if (initPhase <= (*i)->initPhase) {
// found where we want to insert
break;
}
}
// (fall through case: insert at end)
ctxList->insert(i, this);
}
} }
@ -695,97 +675,6 @@ ParamContext::printErrorProlog(ostream &os)
os << "Parameter error in section [" << iniSection << "]: " << endl; os << "Parameter error in section [" << iniSection << "]: " << endl;
} }
//
// static method: call parseParams() on all registered contexts
//
void
ParamContext::parseAllContexts(IniFile &iniFile)
{
if (!ctxList)
return;
list<ParamContext *>::iterator iter;
for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
ParamContext *pc = *iter;
pc->parseParams(iniFile);
}
}
//
// static method: call checkParams() on all registered contexts
//
void
ParamContext::checkAllContexts()
{
if (!ctxList)
return;
list<ParamContext *>::iterator iter;
for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
ParamContext *pc = *iter;
pc->checkParams();
}
}
//
// static method: call showParams() on all registered contexts
//
void
ParamContext::showAllContexts(ostream &os)
{
if (!ctxList)
return;
list<ParamContext *>::iterator iter;
for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
ParamContext *pc = *iter;
os << "[" << pc->iniSection << "]" << endl;
pc->showParams(os);
os << endl;
}
}
//
// static method: call cleanup() on all registered contexts
//
void
ParamContext::cleanupAllContexts()
{
if (!ctxList)
return;
list<ParamContext *>::iterator iter;
for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
ParamContext *pc = *iter;
pc->cleanup();
}
}
//
// static method: call describeParams() on all registered contexts
//
void
ParamContext::describeAllContexts(ostream &os)
{
if (!ctxList)
return;
list<ParamContext *>::iterator iter;
for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
ParamContext *pc = *iter;
os << "[" << pc->iniSection << "]\n";
pc->describeParams(os);
os << endl;
}
}
void void
parseTime(const std::vector<int> &time, struct tm *tm) parseTime(const std::vector<int> &time, struct tm *tm)
{ {

View file

@ -50,12 +50,6 @@ class SimObject;
// //
class ParamContext : protected StartupCallback class ParamContext : protected StartupCallback
{ {
private:
// static list of all ParamContext objects, built as a side effect
// of the ParamContext constructor
static std::list<ParamContext *> *ctxList;
protected: protected:
// .ini file (database) for parameter lookup... initialized on call // .ini file (database) for parameter lookup... initialized on call
@ -78,31 +72,10 @@ class ParamContext : protected StartupCallback
public: public:
/// 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. /// Constructor.
/// @param _iniSection Name of .ini section corresponding to this context. /// @param _iniSection Name of .ini section corresponding to this context.
/// @param _initPhase Initialization phase (see InitPhase). /// @param _initPhase Initialization phase (see InitPhase).
ParamContext(const std::string &_iniSection, ParamContext(const std::string &_iniSection);
InitPhase _initPhase = DefaultInitPhase);
virtual ~ParamContext() {} virtual ~ParamContext() {}
// add a parameter to the context... called from the parameter // add a parameter to the context... called from the parameter
@ -135,24 +108,6 @@ class ParamContext : protected StartupCallback
// generate the name for this instance of this context (used as a // generate the name for this instance of this context (used as a
// prefix to create unique names in resolveSimObject() // prefix to create unique names in resolveSimObject()
virtual const std::string &getInstanceName() { return iniSection; } virtual const std::string &getInstanceName() { return iniSection; }
// Parse all parameters registered with all ParamContext objects.
static void parseAllContexts(IniFile &iniFile);
// Check all parameters registered with all ParamContext objects.
// (calls checkParams() on each)
static void checkAllContexts();
// Print all parameter values on indicated ostream.
static void showAllContexts(std::ostream &os);
// Clean up all registered ParamContext objects. (calls cleanup()
// on each)
static void cleanupAllContexts();
// print descriptions of all parameters registered with all
// ParamContext objects
static void describeAllContexts(std::ostream &os);
}; };