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:
@@ -40,7 +40,7 @@
|
||||
using namespace std;
|
||||
|
||||
SimObjectBuilder::SimObjectBuilder(const std::string &_iniSection)
|
||||
: ParamContext(_iniSection, NoAutoInit)
|
||||
: ParamContext(_iniSection)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
115
src/sim/param.cc
115
src/sim/param.cc
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user