sim: make warning for absent optional parameters optional

This is in support of tag-based checkpoint versioning. It should be
possible to examine an optional parameter in a checkpoint during
unserialization and not have it throw a warning.
This commit is contained in:
Curtis Dunham 2015-09-02 15:19:43 -05:00
parent fe47f0a72f
commit 1ad5b77229
2 changed files with 10 additions and 6 deletions

View file

@ -223,11 +223,12 @@ paramIn(CheckpointIn &cp, const string &name, T &param)
template <class T>
bool
optParamIn(CheckpointIn &cp, const string &name, T &param)
optParamIn(CheckpointIn &cp, const string &name, T &param, bool warn)
{
const string &section(Serializable::currentSection());
string str;
if (!cp.find(section, name, str) || !parseParam(str, param)) {
if (warn)
warn("optional parameter %s:%s not present\n", section, name);
return false;
} else {
@ -384,7 +385,8 @@ objParamIn(CheckpointIn &cp, const string &name, SimObject * &param)
template void \
paramIn(CheckpointIn &cp, const string &name, type & param); \
template bool \
optParamIn(CheckpointIn &cp, const string &name, type & param); \
optParamIn(CheckpointIn &cp, const string &name, type & param, \
bool warn); \
template void \
arrayParamOut(CheckpointOut &os, const string &name, \
type const *param, unsigned size); \

View file

@ -100,13 +100,15 @@ void paramIn(CheckpointIn &cp, const std::string &name,
}
template <class T>
bool optParamIn(CheckpointIn &cp, const std::string &name, T &param);
bool optParamIn(CheckpointIn &cp, const std::string &name, T &param,
bool warn = true);
template <typename DataType, typename BitUnion>
bool optParamIn(CheckpointIn &cp, const std::string &name,
BitfieldBackend::BitUnionOperators<DataType, BitUnion> &p)
BitfieldBackend::BitUnionOperators<DataType, BitUnion> &p,
bool warn = true)
{
return optParamIn(cp, name, p.__data);
return optParamIn(cp, name, p.__data, warn);
}
template <class T>