Go to the documentation of this file.
45 #ifndef __SERIALIZE_HH__
46 #define __SERIALIZE_HH__
89 bool find(
const std::string §ion,
const std::string &entry,
92 bool findObj(
const std::string §ion,
const std::string &entry,
95 bool entryExists(
const std::string §ion,
const std::string &entry);
120 static std::string
setDir(
const std::string &base_name);
132 static std::string
dir();
319 static std::stack<std::string>
path;
370 os << ((
sizeof(storage) == 1) ?
371 static_cast<unsigned int>(storage) : storage);
402 os << (
unsigned int)value;
443 os << (value ?
"true" :
"false");
488 fatal(
"Can't unserialize '%s:%s'\n", section,
name);
508 T ¶m,
bool warn =
true)
514 warn(
"optional parameter %s:%s not present\n", section,
name);
551 if (param.size() > 0)
554 while (it != param.end()) {
568 const std::set<T> ¶m)
570 typename std::set<T>::const_iterator it = param.begin();
573 if (param.size() > 0)
576 while (it != param.end()) {
590 const T *param,
unsigned size)
595 for (
unsigned i = 1;
i < size; ++
i) {
616 T *param,
unsigned size)
620 if (!
cp.find(section,
name, str)) {
621 fatal(
"Can't unserialize '%s:%s'\n", section,
name);
635 "Array size mismatch on %s:%s (Got %u, expected %u)'\n",
636 section,
name, tokens.size(), size);
645 std::string
err(
"could not parse \"");
654 param[
i] = scalar_value;
667 if (!
cp.find(section,
name, str)) {
668 fatal(
"Can't unserialize '%s:%s'\n", section,
name);
681 param.resize(tokens.size());
690 std::string
err(
"could not parse \"");
699 param[
i] = scalar_value;
712 if (!
cp.find(section,
name, str)) {
713 fatal(
"Can't unserialize '%s:%s'\n", section,
name);
723 std::string
err(
"could not parse \"");
732 param.push_back(scalar_value);
745 if (!
cp.find(section,
name, str)) {
746 fatal(
"Can't unserialize '%s:%s'\n", section,
name);
756 std::string
err(
"could not parse \"");
765 param.insert(scalar_value);
790 #define SERIALIZE_SCALAR(scalar) paramOut(cp, #scalar, scalar)
797 #define UNSERIALIZE_SCALAR(scalar) paramIn(cp, #scalar, scalar)
804 #define UNSERIALIZE_OPT_SCALAR(scalar) optParamIn(cp, #scalar, scalar)
813 #define SERIALIZE_ENUM(scalar) paramOut(cp, #scalar, (int)scalar)
820 #define UNSERIALIZE_ENUM(scalar) \
823 paramIn(cp, #scalar, tmp); \
824 scalar = static_cast<decltype(scalar)>(tmp); \
832 #define SERIALIZE_ARRAY(member, size) \
833 arrayParamOut(cp, #member, member, size)
840 #define UNSERIALIZE_ARRAY(member, size) \
841 arrayParamIn(cp, #member, member, size)
848 #define SERIALIZE_CONTAINER(member) \
849 arrayParamOut(cp, #member, member)
856 #define UNSERIALIZE_CONTAINER(member) \
857 arrayParamIn(cp, #member, member)
864 #define SERIALIZE_EVENT(event) event.serializeSection(cp, #event);
871 #define UNSERIALIZE_EVENT(event) \
873 event.unserializeSection(cp, #event); \
874 eventQueue()->checkpointReschedule(&event); \
882 #define SERIALIZE_OBJ(obj) obj.serializeSection(cp, #obj)
889 #define UNSERIALIZE_OBJ(obj) obj.unserializeSection(cp, #obj)
896 #define SERIALIZE_OBJPTR(objptr) paramOut(cp, #objptr, (objptr)->name())
903 #define UNSERIALIZE_OBJPTR(objptr) \
906 objParamIn(cp, #objptr, sptr); \
907 objptr = dynamic_cast<decltype(objptr)>(sptr); \
910 #endif // __SERIALIZE_HH__
void nameOut(CheckpointOut &cp)
void tokenize(vector< string > &v, const string &s, char token, bool ignore)
#define fatal(...)
This implements a cprintf based fatal() function.
Base class to wrap object resolving functionality.
bool to_bool(const std::string &value, bool &retval)
Turn a string representation of a boolean into a boolean value.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
SimObjectResolver & objNameResolver
CheckpointIn(const std::string &cpt_dir, SimObjectResolver &resolver)
~ScopedCheckpointSection()
Basic support for object serialization.
void arrayParamOut(CheckpointOut &os, const std::string &name, const std::vector< T > ¶m)
bool sectionExists(const std::string §ion)
This class represents the contents of a ".ini" file.
void unserializeSection(CheckpointIn &cp, const std::string &name)
bool findObj(const std::string §ion, const std::string &entry, SimObject *&value)
void paramIn(CheckpointIn &cp, const std::string &name, T ¶m)
This function is used for restoring parameters from a checkpoint.
static std::string setDir(const std::string &base_name)
Set the current directory.
void arrayParamIn(CheckpointIn &cp, const std::string &name, T *param, unsigned size)
Extract values stored in the checkpoint, and assign them to the provided array container.
bool find(const std::string §ion, const std::string &entry, std::string &value)
ScopedCheckpointSection(CP &cp, const std::string &name)
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void nameOut(CheckpointIn &cp)
bool to_number(const std::string &value, VecPredRegContainer< NumBits, Packed > &p)
Helper functions used for serialization/de-serialization.
bool parseParam(const std::string &s, T &value)
void showParam(CheckpointOut &os, const T &value)
virtual void serialize(CheckpointOut &cp) const =0
Serialize an object.
void debug_serialize(const std::string &cpt_dir)
void pushName(const char *name)
static const char * baseFilename
static void unserializeGlobals(CheckpointIn &cp)
bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m, bool warn=true)
This function is used for restoring optional parameters from the checkpoint.
const std::string _cptDir
ScopedCheckpointSection(CP &cp, const char *name)
This is the constructor for Scoped checkpoint section helper class.
const std::string & name()
virtual void unserialize(CheckpointIn &cp)=0
Unserialize an object.
static std::string dir()
Get the current checkout directory name.
const std::string getCptDir()
bool entryExists(const std::string §ion, const std::string &entry)
static void serializeAll(const std::string &cpt_dir)
Serializes all the SimObjects.
std::ostream CheckpointOut
ScopedCheckpointSection & operator=(const ScopedCheckpointSection &)=delete
static const std::string & currentSection()
Gets the fully-qualified name of the active section.
void objParamIn(CheckpointIn &cp, const std::string &name, SimObject *¶m)
void serializeSection(CheckpointOut &cp, const std::string &name) const
void paramOut(CheckpointOut &os, const std::string &name, const T ¶m)
This function is used for writing parameters to a checkpoint.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
static std::string currentDirectory
static std::stack< std::string > path
ScopedCheckpointSection()=delete
typename BitfieldBackend::BitUnionBaseType< T >::Type BitUnionBaseType
Abstract superclass for simulation objects.
Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17