serialize.hh (2665:a124942bacb8) | serialize.hh (2738:5d7a31c7fa29) |
---|---|
1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 28 unchanged lines hidden (view full) --- 37#define __SERIALIZE_HH__ 38 39 40#include <list> 41#include <iostream> 42#include <map> 43 44#include "sim/host.hh" | 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 28 unchanged lines hidden (view full) --- 37#define __SERIALIZE_HH__ 38 39 40#include <list> 41#include <iostream> 42#include <map> 43 44#include "sim/host.hh" |
45#include "sim/configfile.hh" | |
46 | 45 |
46class IniFile; |
|
47class Serializable; 48class Checkpoint; 49 50template <class T> 51void paramOut(std::ostream &os, const std::string &name, const T ¶m); 52 53template <class T> 54void paramIn(Checkpoint *cp, const std::string §ion, --- 117 unchanged lines hidden (view full) --- 172 173 // Type CreateFunc is a pointer to a function that creates a new 174 // simulation object builder based on a .ini-file parameter 175 // section (specified by the first string argument), a unique name 176 // for the object (specified by the second string argument), and 177 // an optional config hierarchy node (specified by the third 178 // argument). A pointer to the new SerializableBuilder is returned. 179 typedef Serializable *(*CreateFunc)(Checkpoint *cp, | 47class Serializable; 48class Checkpoint; 49 50template <class T> 51void paramOut(std::ostream &os, const std::string &name, const T ¶m); 52 53template <class T> 54void paramIn(Checkpoint *cp, const std::string §ion, --- 117 unchanged lines hidden (view full) --- 172 173 // Type CreateFunc is a pointer to a function that creates a new 174 // simulation object builder based on a .ini-file parameter 175 // section (specified by the first string argument), a unique name 176 // for the object (specified by the second string argument), and 177 // an optional config hierarchy node (specified by the third 178 // argument). A pointer to the new SerializableBuilder is returned. 179 typedef Serializable *(*CreateFunc)(Checkpoint *cp, |
180 const std::string §ion); | 180 const std::string §ion); |
181 182 static std::map<std::string,CreateFunc> *classMap; 183 184 // Constructor. For example: 185 // 186 // SerializableClass baseCacheSerializableClass("BaseCacheSerializable", 187 // newBaseCacheSerializableBuilder); 188 // 189 SerializableClass(const std::string &className, CreateFunc createFunc); 190 191 // create Serializable given name of class and pointer to 192 // configuration hierarchy node 193 static Serializable *createObject(Checkpoint *cp, | 181 182 static std::map<std::string,CreateFunc> *classMap; 183 184 // Constructor. For example: 185 // 186 // SerializableClass baseCacheSerializableClass("BaseCacheSerializable", 187 // newBaseCacheSerializableBuilder); 188 // 189 SerializableClass(const std::string &className, CreateFunc createFunc); 190 191 // create Serializable given name of class and pointer to 192 // configuration hierarchy node 193 static Serializable *createObject(Checkpoint *cp, |
194 const std::string §ion); | 194 const std::string §ion); |
195}; 196 197// 198// Macros to encapsulate the magic of declaring & defining 199// SerializableBuilder and SerializableClass objects 200// 201 202#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \ 203SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \ 204 OBJ_CLASS::createForUnserialize); 205 206class Checkpoint 207{ 208 private: 209 210 IniFile *db; 211 const std::string basePath; | 195}; 196 197// 198// Macros to encapsulate the magic of declaring & defining 199// SerializableBuilder and SerializableClass objects 200// 201 202#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \ 203SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \ 204 OBJ_CLASS::createForUnserialize); 205 206class Checkpoint 207{ 208 private: 209 210 IniFile *db; 211 const std::string basePath; |
212 const ConfigNode *configNode; | |
213 std::map<std::string, Serializable*> objMap; 214 215 public: | 212 std::map<std::string, Serializable*> objMap; 213 214 public: |
216 Checkpoint(const std::string &cpt_dir, const std::string &path, 217 const ConfigNode *_configNode); | 215 Checkpoint(const std::string &cpt_dir, const std::string &path); |
218 219 const std::string cptDir; 220 221 bool find(const std::string §ion, const std::string &entry, 222 std::string &value); 223 224 bool findObj(const std::string §ion, const std::string &entry, 225 Serializable *&value); --- 21 unchanged lines hidden --- | 216 217 const std::string cptDir; 218 219 bool find(const std::string §ion, const std::string &entry, 220 std::string &value); 221 222 bool findObj(const std::string §ion, const std::string &entry, 223 Serializable *&value); --- 21 unchanged lines hidden --- |