serialize.hh (6820:2980bd04e6df) | serialize.hh (7491:e8ff1fb26dbc) |
---|---|
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; --- 205 unchanged lines hidden (view full) --- 214// Macros to encapsulate the magic of declaring & defining 215// SerializableBuilder and SerializableClass objects 216// 217 218#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \ 219SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \ 220 OBJ_CLASS::createForUnserialize); 221 | 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; --- 205 unchanged lines hidden (view full) --- 214// Macros to encapsulate the magic of declaring & defining 215// SerializableBuilder and SerializableClass objects 216// 217 218#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \ 219SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \ 220 OBJ_CLASS::createForUnserialize); 221 |
222void 223setCheckpointDir(const std::string &name); 224 | |
225class Checkpoint 226{ 227 private: 228 229 IniFile *db; | 222class Checkpoint 223{ 224 private: 225 226 IniFile *db; |
230 const std::string basePath; 231 std::map<std::string, Serializable*> objMap; | |
232 233 public: | 227 228 public: |
234 Checkpoint(const std::string &cpt_dir, const std::string &path); | 229 Checkpoint(const std::string &cpt_dir); |
235 236 const std::string cptDir; 237 238 bool find(const std::string §ion, const std::string &entry, 239 std::string &value); 240 241 bool findObj(const std::string §ion, const std::string &entry, 242 SimObject *&value); 243 244 bool sectionExists(const std::string §ion); 245 246 // The following static functions have to do with checkpoint 247 // creation rather than restoration. This class makes a handy | 230 231 const std::string cptDir; 232 233 bool find(const std::string §ion, const std::string &entry, 234 std::string &value); 235 236 bool findObj(const std::string §ion, const std::string &entry, 237 SimObject *&value); 238 239 bool sectionExists(const std::string §ion); 240 241 // The following static functions have to do with checkpoint 242 // creation rather than restoration. This class makes a handy |
248 // namespace for them though. | 243 // namespace for them though. Currently no Checkpoint object is 244 // created on serialization (only unserialization) so we track the 245 // directory name as a global. It would be nice to change this 246 // someday |
249 | 247 |
248 private: 249 // current directory we're serializing into. 250 static std::string currentDirectory; 251 252 public: 253 // Set the current directory. This function takes care of 254 // inserting curTick if there's a '%d' in the argument, and 255 // appends a '/' if necessary. The final name is returned. 256 static std::string setDir(const std::string &base_name); 257 |
|
250 // Export current checkpoint directory name so other objects can 251 // derive filenames from it (e.g., memory). The return value is 252 // guaranteed to end in '/' so filenames can be directly appended. 253 // This function is only valid while a checkpoint is being created. 254 static std::string dir(); 255 256 // Filename for base checkpoint file within directory. 257 static const char *baseFilename; 258}; 259 260#endif // __SERIALIZE_HH__ | 258 // Export current checkpoint directory name so other objects can 259 // derive filenames from it (e.g., memory). The return value is 260 // guaranteed to end in '/' so filenames can be directly appended. 261 // This function is only valid while a checkpoint is being created. 262 static std::string dir(); 263 264 // Filename for base checkpoint file within directory. 265 static const char *baseFilename; 266}; 267 268#endif // __SERIALIZE_HH__ |