serialize.hh (4841:89a9419e7361) serialize.hh (5543:3af77710f397)
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;

--- 68 unchanged lines hidden (view full) ---

77objParamIn(Checkpoint *cp, const std::string &section,
78 const std::string &name, SimObject * &param);
79
80
81//
82// These macros are streamlined to use in serialize/unserialize
83// functions. It's assumed that serialize() has a parameter 'os' for
84// the ostream, and unserialize() has parameters 'cp' and 'section'.
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;

--- 68 unchanged lines hidden (view full) ---

77objParamIn(Checkpoint *cp, const std::string &section,
78 const std::string &name, SimObject * &param);
79
80
81//
82// These macros are streamlined to use in serialize/unserialize
83// functions. It's assumed that serialize() has a parameter 'os' for
84// the ostream, and unserialize() has parameters 'cp' and 'section'.
85#define SERIALIZE_SCALAR(scalar) paramOut(os, #scalar, scalar)
85#define SERIALIZE_SCALAR(scalar) paramOut(os, #scalar, scalar)
86
86
87#define UNSERIALIZE_SCALAR(scalar) paramIn(cp, section, #scalar, scalar)
87#define UNSERIALIZE_SCALAR(scalar) paramIn(cp, section, #scalar, scalar)
88
89// ENUMs are like SCALARs, but we cast them to ints on the way out
88
89// ENUMs are like SCALARs, but we cast them to ints on the way out
90#define SERIALIZE_ENUM(scalar) paramOut(os, #scalar, (int)scalar)
90#define SERIALIZE_ENUM(scalar) paramOut(os, #scalar, (int)scalar)
91
91
92#define UNSERIALIZE_ENUM(scalar) \
93 do { \
94 int tmp; \
95 paramIn(cp, section, #scalar, tmp); \
96 scalar = (typeof(scalar))tmp; \
92#define UNSERIALIZE_ENUM(scalar) \
93 do { \
94 int tmp; \
95 paramIn(cp, section, #scalar, tmp); \
96 scalar = (typeof(scalar))tmp; \
97 } while (0)
98
97 } while (0)
98
99#define SERIALIZE_ARRAY(member, size) \
99#define SERIALIZE_ARRAY(member, size) \
100 arrayParamOut(os, #member, member, size)
101
100 arrayParamOut(os, #member, member, size)
101
102#define UNSERIALIZE_ARRAY(member, size) \
102#define UNSERIALIZE_ARRAY(member, size) \
103 arrayParamIn(cp, section, #member, member, size)
104
103 arrayParamIn(cp, section, #member, member, size)
104
105#define SERIALIZE_OBJPTR(objptr) paramOut(os, #objptr, (objptr)->name())
105#define SERIALIZE_OBJPTR(objptr) paramOut(os, #objptr, (objptr)->name())
106
106
107#define UNSERIALIZE_OBJPTR(objptr) \
108 do { \
109 SimObject *sptr; \
110 objParamIn(cp, section, #objptr, sptr); \
111 objptr = dynamic_cast<typeof(objptr)>(sptr); \
107#define UNSERIALIZE_OBJPTR(objptr) \
108 do { \
109 SimObject *sptr; \
110 objParamIn(cp, section, #objptr, sptr); \
111 objptr = dynamic_cast<typeof(objptr)>(sptr); \
112 } while (0)
113
114/*
115 * Basic support for object serialization.
116 */
117class Serializable
118{
119 protected:

--- 86 unchanged lines hidden (view full) ---

206 const std::string &section);
207};
208
209//
210// Macros to encapsulate the magic of declaring & defining
211// SerializableBuilder and SerializableClass objects
212//
213
112 } while (0)
113
114/*
115 * Basic support for object serialization.
116 */
117class Serializable
118{
119 protected:

--- 86 unchanged lines hidden (view full) ---

206 const std::string &section);
207};
208
209//
210// Macros to encapsulate the magic of declaring & defining
211// SerializableBuilder and SerializableClass objects
212//
213
214#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \
215SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \
214#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \
215SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \
216 OBJ_CLASS::createForUnserialize);
217
218void
219setCheckpointDir(const std::string &name);
220
221class Checkpoint
222{
223 private:

--- 33 unchanged lines hidden ---
216 OBJ_CLASS::createForUnserialize);
217
218void
219setCheckpointDir(const std::string &name);
220
221class Checkpoint
222{
223 private:

--- 33 unchanged lines hidden ---