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, '''
// The remaining enum values are *not* valid indices for Trace::flags.
// 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:

View file

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

View file

@ -40,7 +40,7 @@
using namespace std;
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
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
SimObject::initAll();
@ -462,8 +455,6 @@ doExitCleanup()
cout.flush();
ParamContext::cleanupAllContexts();
// print simulation stats
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, InitPhase _initPhase)
ParamContext::ParamContext(const string &_iniSection)
: iniFilePtr(NULL), // initialized on call to parseParams()
iniSection(_iniSection), paramList(NULL),
initPhase(_initPhase)
iniSection(_iniSection), paramList(NULL)
{
// 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;
}
//
// 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
parseTime(const std::vector<int> &time, struct tm *tm)
{

View file

@ -50,12 +50,6 @@ class SimObject;
//
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:
// .ini file (database) for parameter lookup... initialized on call
@ -78,31 +72,10 @@ class ParamContext : protected StartupCallback
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.
/// @param _iniSection Name of .ini section corresponding to this context.
/// @param _initPhase Initialization phase (see InitPhase).
ParamContext(const std::string &_iniSection,
InitPhase _initPhase = DefaultInitPhase);
ParamContext(const std::string &_iniSection);
virtual ~ParamContext() {}
// 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
// prefix to create unique names in resolveSimObject()
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);
};