#include <list>
#include <map>
#include <stack>
+#include <set>
#include <vector>
#include "base/bitunion.hh"
-#include "base/types.hh"
+class CheckpointIn;
class IniFile;
class Serializable;
-class CheckpointIn;
class SimObject;
class SimObjectResolver;
-class EventQueue;
typedef std::ostream CheckpointOut;
-/** The current version of the checkpoint format.
- * This should be incremented by 1 and only 1 for every new version, where a new
- * version is defined as a checkpoint created before this version won't work on
- * the current version until the checkpoint format is updated. Adding a new
- * SimObject shouldn't cause the version number to increase, only changes to
- * existing objects such as serializing/unserializing more state, changing sizes
- * of serialized arrays, etc. */
-static const uint64_t gem5CheckpointVersion = 0x000000000000000f;
-
template <class T>
void paramOut(CheckpointOut &cp, const std::string &name, const T ¶m);
}
template <class T>
-bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m);
+bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m,
+ 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>
void arrayParamOut(CheckpointOut &cp, const std::string &name,
const std::list<T> ¶m);
+template <class T>
+void arrayParamOut(CheckpointOut &cp, const std::string &name,
+ const std::set<T> ¶m);
+
template <class T>
void arrayParamIn(CheckpointIn &cp, const std::string &name,
T *param, unsigned size);
void arrayParamIn(CheckpointIn &cp, const std::string &name,
std::list<T> ¶m);
+template <class T>
+void arrayParamIn(CheckpointIn &cp, const std::string &name,
+ std::set<T> ¶m);
+
void
objParamIn(CheckpointIn &cp, const std::string &name, SimObject * ¶m);
do { \
event.unserializeSection(cp, #event); \
eventQueue()->checkpointReschedule(&event); \
- } while(0)
+ } while (0)
#define SERIALIZE_OBJ(obj) obj.serializeSection(cp, #obj)
#define UNSERIALIZE_OBJ(obj) obj.unserializeSection(cp, #obj)
unserializeSection(cp, name.c_str());
}
- /**
- * @{
- * @name Legacy interface
- *
- * Interface for objects that insist on changing their state when
- * serializing. Such state change should be done in drain(),
- * memWriteback(), or memInvalidate() and not in the serialization
- * method. In general, if state changes occur in serialize, it
- * complicates testing since it breaks assumptions about draining
- * and serialization. It potentially also makes components more
- * fragile since they there are no ordering guarantees when
- * serializing SimObjects.
- *
- * @warn This interface is considered deprecated and should never
- * be used.
- */
-
- virtual void serializeOld(CheckpointOut &cp) {
- serialize(cp);
- }
- void serializeSectionOld(CheckpointOut &cp, const char *name);
- void serializeSectionOld(CheckpointOut &cp, const std::string &name) {
- serializeSectionOld(cp, name.c_str());
- }
- /** @} */
-
/** Get the fully-qualified name of the active section */
static const std::string ¤tSection();
- static Serializable *create(CheckpointIn &cp, const std::string §ion);
-
static int ckptCount;
static int ckptMaxCount;
static int ckptPrevCount;
void debug_serialize(const std::string &cpt_dir);
-//
-// An instance of SerializableClass corresponds to a class derived from
-// Serializable. The SerializableClass instance serves to bind the string
-// name (found in the config file) to a function that creates an
-// instance of the appropriate derived class.
-//
-// This would be much cleaner in Smalltalk or Objective-C, where types
-// are first-class objects themselves.
-//
-class SerializableClass
-{
- public:
-
- // Type CreateFunc is a pointer to a function that creates a new
- // simulation object builder based on a .ini-file parameter
- // section (specified by the first string argument), a unique name
- // for the object (specified by the second string argument), and
- // an optional config hierarchy node (specified by the third
- // argument). A pointer to the new SerializableBuilder is returned.
- typedef Serializable *(*CreateFunc)(CheckpointIn &cp,
- const std::string §ion);
-
- static std::map<std::string,CreateFunc> *classMap;
-
- // Constructor. For example:
- //
- // SerializableClass baseCacheSerializableClass("BaseCacheSerializable",
- // newBaseCacheSerializableBuilder);
- //
- SerializableClass(const std::string &className, CreateFunc createFunc);
-
- // create Serializable given name of class and pointer to
- // configuration hierarchy node
- static Serializable *createObject(CheckpointIn &cp,
- const std::string §ion);
-};
-
-//
-// Macros to encapsulate the magic of declaring & defining
-// SerializableBuilder and SerializableClass objects
-//
-
-#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \
-SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \
- OBJ_CLASS::createForUnserialize);
-
class CheckpointIn
{
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