+ class ScopedCheckpointSection {
+ public:
+ /**
+ * This is the constructor for Scoped checkpoint section helper
+ * class.
+ *
+ * Scoped checkpoint helper class creates a section within a
+ * checkpoint without the need for a separate serializeable
+ * object. It is mainly used within the Serializable class
+ * when serializing or unserializing section (see
+ * serializeSection() and unserializeSection()). It
+ * can also be used to maintain backwards compatibility in
+ * existing code that serializes structs that are not inheriting
+ * from Serializable into subsections.
+ *
+ * When the class is instantiated, it appends a name to the active
+ * path in a checkpoint. The old path is later restored when the
+ * instance is destroyed. For example, serializeSection() could be
+ * implemented by instantiating a ScopedCheckpointSection and then
+ * calling serialize() on an object.
+ *
+ * @ingroup api_serialize
+ * @{
+ */
+ template<class CP>
+ ScopedCheckpointSection(CP &cp, const char *name) {
+ pushName(name);
+ nameOut(cp);
+ }
+
+ template<class CP>
+ ScopedCheckpointSection(CP &cp, const std::string &name) {
+ pushName(name.c_str());
+ nameOut(cp);
+ }
+ /** @}*/ //end of api_serialize group
+
+ ~ScopedCheckpointSection();
+
+ ScopedCheckpointSection() = delete;
+ ScopedCheckpointSection(const ScopedCheckpointSection &) = delete;
+ ScopedCheckpointSection &operator=(
+ const ScopedCheckpointSection &) = delete;
+ ScopedCheckpointSection &operator=(
+ ScopedCheckpointSection &&) = delete;
+
+ private:
+ void pushName(const char *name);
+ void nameOut(CheckpointOut &cp);
+ void nameOut(CheckpointIn &cp) {};
+ };
+
+ /**
+ * @ingroup api_serialize
+ */
+ Serializable();
+ virtual ~Serializable();
+
+ /**
+ * Serialize an object
+ *
+ * Output an object's state into the current checkpoint section.
+ *
+ * @param cp Checkpoint state
+ *
+ * @ingroup api_serialize
+ */
+ virtual void serialize(CheckpointOut &cp) const = 0;
+
+ /**
+ * Unserialize an object
+ *
+ * Read an object's state from the current checkpoint section.
+ *
+ * @param cp Checkpoint state
+ *
+ * @ingroup api_serialize
+ */
+ virtual void unserialize(CheckpointIn &cp) = 0;
+
+ /**
+ * Serialize an object into a new section
+ *
+ * This method creates a new section in a checkpoint and calls
+ * serialize() to serialize the current object into that
+ * section. The name of the section is appended to the current
+ * checkpoint path.
+ *
+ * @param cp Checkpoint state
+ * @param name Name to append to the active path
+ *
+ * @ingroup api_serialize
+ */
+ void serializeSection(CheckpointOut &cp, const char *name) const;
+
+ /**
+ * @ingroup api_serialize
+ */
+ void serializeSection(CheckpointOut &cp, const std::string &name) const {
+ serializeSection(cp, name.c_str());
+ }
+
+ /**
+ * Unserialize an a child object
+ *
+ * This method loads a child object from a checkpoint. The object
+ * name is appended to the active path to form a fully qualified
+ * section name and unserialize() is called.
+ *
+ * @param cp Checkpoint state
+ * @param name Name to append to the active path
+ *
+ * @ingroup api_serialize
+ */
+ void unserializeSection(CheckpointIn &cp, const char *name);
+
+ /**
+ * @ingroup api_serialize
+ */
+ void unserializeSection(CheckpointIn &cp, const std::string &name) {
+ unserializeSection(cp, name.c_str());
+ }
+
+ /**
+ * Gets the fully-qualified name of the active section
+ *
+ * @ingroup api_serialize
+ */
+ static const std::string ¤tSection();
+
+ /**
+ * Serializes all the SimObjects.
+ *
+ * @ingroup api_serialize
+ */
+ static void serializeAll(const std::string &cpt_dir);