changeset 6c21ab852ed2 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=6c21ab852ed2
description:
sim: Add a checkpoint function to test for entries
When loading a checkpoint, it's sometimes desirable to be able to test
whether an entry within a secion exists. This is currently done
automatically in the UNSERIALIZE_OPT_SCALAR macro, but it isn't
possible to do for arrays, containers, or enums. Instead of adding
even more macros, add a helper function (CheckpointIn::entryExists())
that tests for the presence of an entry.
Change-Id: I4b4646b03276b889fd3916efefff3bd552317dbc
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
diffstat:
src/base/inifile.cc | 11 +++++++++++
src/base/inifile.hh | 6 ++++++
src/sim/serialize.cc | 6 ++++++
src/sim/serialize.hh | 2 ++
4 files changed, 25 insertions(+), 0 deletions(-)
diffs (65 lines):
diff -r 49cbf4bb0d36 -r 6c21ab852ed2 src/base/inifile.cc
--- a/src/base/inifile.cc Thu Sep 29 01:06:52 2016 -0400
+++ b/src/base/inifile.cc Tue Oct 04 11:22:16 2016 +0100
@@ -230,6 +230,17 @@
}
bool
+IniFile::entryExists(const string §ionName, const string &entryName) const
+{
+ Section *section = findSection(sectionName);
+
+ if (!section)
+ return false;
+ else
+ return section->findEntry(entryName);
+}
+
+bool
IniFile::sectionExists(const string §ionName) const
{
return findSection(sectionName) != NULL;
diff -r 49cbf4bb0d36 -r 6c21ab852ed2 src/base/inifile.hh
--- a/src/base/inifile.hh Thu Sep 29 01:06:52 2016 -0400
+++ b/src/base/inifile.hh Tue Oct 04 11:22:16 2016 +0100
@@ -184,6 +184,12 @@
bool find(const std::string §ion, const std::string &entry,
std::string &value) const;
+ /// Determine whether the entry exists within named section exists
+ /// in the .ini file.
+ /// @return True if the section exists.
+ bool entryExists(const std::string §ion,
+ const std::string &entry) const;
+
/// Determine whether the named section exists in the .ini file.
/// Note that the 'Section' class is (intentionally) not public,
/// so all clients can do is get a bool that says whether there
diff -r 49cbf4bb0d36 -r 6c21ab852ed2 src/sim/serialize.cc
--- a/src/sim/serialize.cc Thu Sep 29 01:06:52 2016 -0400
+++ b/src/sim/serialize.cc Tue Oct 04 11:22:16 2016 +0100
@@ -693,6 +693,12 @@
}
bool
+CheckpointIn::entryExists(const string §ion, const string &entry)
+{
+ return db->entryExists(section, entry);
+}
+
+bool
CheckpointIn::find(const string §ion, const string &entry, string &value)
{
return db->find(section, entry, value);
diff -r 49cbf4bb0d36 -r 6c21ab852ed2 src/sim/serialize.hh
--- a/src/sim/serialize.hh Thu Sep 29 01:06:52 2016 -0400
+++ b/src/sim/serialize.hh Tue Oct 04 11:22:16 2016 +0100
@@ -359,6 +359,8 @@
bool findObj(const std::string §ion, const std::string &entry,
SimObject *&value);
+
+ bool entryExists(const std::string §ion, const std::string &entry);
bool sectionExists(const std::string §ion);
// The following static functions have to do with checkpoint
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev