1/* 2 * Copyright (c) 2015 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 122 unchanged lines hidden (view full) --- 131 132template <class T> 133void arrayParamIn(CheckpointIn &cp, const std::string &name, 134 std::list<T> ¶m); 135 136void 137objParamIn(CheckpointIn &cp, const std::string &name, SimObject * ¶m); 138 |
139// 140// These macros are streamlined to use in serialize/unserialize 141// functions. It's assumed that serialize() has a parameter 'os' for 142// the ostream, and unserialize() has parameters 'cp' and 'section'. 143#define SERIALIZE_SCALAR(scalar) paramOut(cp, #scalar, scalar) 144 145#define UNSERIALIZE_SCALAR(scalar) paramIn(cp, #scalar, scalar) 146#define UNSERIALIZE_OPT_SCALAR(scalar) optParamIn(cp, #scalar, scalar) 147 148// ENUMs are like SCALARs, but we cast them to ints on the way out 149#define SERIALIZE_ENUM(scalar) paramOut(cp, #scalar, (int)scalar) 150 |
151#define UNSERIALIZE_ENUM(scalar) \ 152 do { \ 153 int tmp; \ 154 paramIn(cp, #scalar, tmp); \ 155 scalar = static_cast<decltype(scalar)>(tmp); \ 156 } while (0) |
157 158#define SERIALIZE_ARRAY(member, size) \ 159 arrayParamOut(cp, #member, member, size) 160 161#define UNSERIALIZE_ARRAY(member, size) \ 162 arrayParamIn(cp, #member, member, size) 163 164#define SERIALIZE_CONTAINER(member) \ --- 11 unchanged lines hidden (view full) --- 176 } while(0) 177 178#define SERIALIZE_OBJ(obj) obj.serializeSection(cp, #obj) 179#define UNSERIALIZE_OBJ(obj) obj.unserializeSection(cp, #obj) 180 181#define SERIALIZE_OBJPTR(objptr) paramOut(cp, #objptr, (objptr)->name()) 182 183#define UNSERIALIZE_OBJPTR(objptr) \ |
184 do { \ 185 SimObject *sptr; \ 186 objParamIn(cp, #objptr, sptr); \ 187 objptr = dynamic_cast<decltype(objptr)>(sptr); \ 188 } while (0) |
189 190/** 191 * Basic support for object serialization. 192 * 193 * Objects that support serialization should derive from this 194 * class. Such objects can largely be divided into two categories: 1) 195 * True SimObjects (deriving from SimObject), and 2) child objects 196 * (non-SimObjects). --- 295 unchanged lines hidden --- |