50 #ifndef __SERIALIZE_HH__
51 #define __SERIALIZE_HH__
75 template <
typename DataType,
typename BitUnion>
85 template <
typename DataType,
typename BitUnion>
96 template <
typename DataType,
typename BitUnion>
106 const T *param,
unsigned size);
118 const std::set<T> ¶m);
122 T *param,
unsigned size);
143 #define SERIALIZE_SCALAR(scalar) paramOut(cp, #scalar, scalar)
145 #define UNSERIALIZE_SCALAR(scalar) paramIn(cp, #scalar, scalar)
146 #define UNSERIALIZE_OPT_SCALAR(scalar) optParamIn(cp, #scalar, scalar)
149 #define SERIALIZE_ENUM(scalar) paramOut(cp, #scalar, (int)scalar)
151 #define UNSERIALIZE_ENUM(scalar) \
154 paramIn(cp, #scalar, tmp); \
155 scalar = static_cast<decltype(scalar)>(tmp); \
158 #define SERIALIZE_ARRAY(member, size) \
159 arrayParamOut(cp, #member, member, size)
161 #define UNSERIALIZE_ARRAY(member, size) \
162 arrayParamIn(cp, #member, member, size)
164 #define SERIALIZE_CONTAINER(member) \
165 arrayParamOut(cp, #member, member)
167 #define UNSERIALIZE_CONTAINER(member) \
168 arrayParamIn(cp, #member, member)
170 #define SERIALIZE_EVENT(event) event.serializeSection(cp, #event);
172 #define UNSERIALIZE_EVENT(event) \
174 event.unserializeSection(cp, #event); \
175 eventQueue()->checkpointReschedule(&event); \
178 #define SERIALIZE_OBJ(obj) obj.serializeSection(cp, #obj)
179 #define UNSERIALIZE_OBJ(obj) obj.unserializeSection(cp, #obj)
181 #define SERIALIZE_OBJPTR(objptr) paramOut(cp, #objptr, (objptr)->name())
183 #define UNSERIALIZE_OBJPTR(objptr) \
186 objParamIn(cp, #objptr, sptr); \
187 objptr = dynamic_cast<decltype(objptr)>(sptr); \
334 static std::stack<std::string>
path;
354 bool find(
const std::string §ion,
const std::string &entry,
357 bool findObj(
const std::string §ion,
const std::string &entry,
361 bool entryExists(
const std::string §ion,
const std::string &entry);
379 static std::string
setDir(
const std::string &base_name);
385 static std::string
dir();
391 #endif // __SERIALIZE_HH__
static void unserializeGlobals(CheckpointIn &cp)
void pushName(const char *name)
const std::string & name()
static std::stack< std::string > path
SimObjectResolver & objNameResolver
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
static std::string currentDirectory
void arrayParamOut(CheckpointOut &cp, const std::string &name, const T *param, unsigned size)
ScopedCheckpointSection()=delete
Base class to wrap object resolving functionality.
ScopedCheckpointSection(CP &cp, const std::string &name)
void unserializeSection(CheckpointIn &cp, const std::string &name)
bool find(const std::string §ion, const std::string &entry, std::string &value)
void debug_serialize(const std::string &cpt_dir)
void objParamIn(CheckpointIn &cp, const std::string &name, SimObject *¶m)
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
virtual void serialize(CheckpointOut &cp) const =0
Serialize an object.
~ScopedCheckpointSection()
void nameOut(CheckpointOut &cp)
Basic support for object serialization.
std::ostream CheckpointOut
bool sectionExists(const std::string §ion)
void paramOut(CheckpointOut &cp, const std::string &name, const T ¶m)
static const std::string & currentSection()
Get the fully-qualified name of the active section.
void nameOut(CheckpointIn &cp)
bool entryExists(const std::string §ion, const std::string &entry)
bool findObj(const std::string §ion, const std::string &entry, SimObject *&value)
virtual void unserialize(CheckpointIn &cp)=0
Unserialize an object.
ScopedCheckpointSection(CP &cp, const char *name)
Scoped checkpoint section helper class.
bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m, bool warn=true)
Abstract superclass for simulation objects.
This class represents the contents of a ".ini" file.
static const char * baseFilename
ScopedCheckpointSection & operator=(const ScopedCheckpointSection &)=delete
CheckpointIn(const std::string &cpt_dir, SimObjectResolver &resolver)
void arrayParamIn(CheckpointIn &cp, const std::string &name, T *param, unsigned size)
void paramIn(CheckpointIn &cp, const std::string &name, T ¶m)
static std::string setDir(const std::string &base_name)
static void serializeAll(const std::string &cpt_dir)
void serializeSection(CheckpointOut &cp, const std::string &name) const