serialize.hh (12452:ad4adeb441d0) serialize.hh (13107:8fa5f70698a2)
1/*
1/*
2 * Copyright (c) 2015 ARM Limited
2 * Copyright (c) 2015, 2018 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
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

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

46/* @file
47 * Serialization Interface Declarations
48 */
49
50#ifndef __SERIALIZE_HH__
51#define __SERIALIZE_HH__
52
53
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
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

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

46/* @file
47 * Serialization Interface Declarations
48 */
49
50#ifndef __SERIALIZE_HH__
51#define __SERIALIZE_HH__
52
53
54#include <algorithm>
54#include <iostream>
55#include <list>
56#include <map>
57#include <stack>
58#include <set>
59#include <vector>
60
61#include "base/bitunion.hh"

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

139
140template <class T>
141void arrayParamIn(CheckpointIn &cp, const std::string &name,
142 std::set<T> &param);
143
144void
145objParamIn(CheckpointIn &cp, const std::string &name, SimObject * &param);
146
55#include <iostream>
56#include <list>
57#include <map>
58#include <stack>
59#include <set>
60#include <vector>
61
62#include "base/bitunion.hh"

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

140
141template <class T>
142void arrayParamIn(CheckpointIn &cp, const std::string &name,
143 std::set<T> &param);
144
145void
146objParamIn(CheckpointIn &cp, const std::string &name, SimObject * &param);
147
148template <class T>
149static void
150arrayParamOut(CheckpointOut &cp, const std::string &name,
151 const BitUnionType<T> *param, unsigned size)
152{
153 // We copy the array into a vector. This is needed since we cannot
154 // directly typecast a pointer to BitUnionType<T> into a pointer
155 // of BitUnionBaseType<T> but we can typecast BitUnionType<T>
156 // to BitUnionBaseType<T> since we overloaded the typecast operator
157 std::vector<BitUnionBaseType<T>> bitunion_vec(param, param + size);
158
159 arrayParamOut(cp, name, bitunion_vec);
160}
161
162template <class T>
163static void
164arrayParamIn(CheckpointIn &cp, const std::string &name,
165 BitUnionType<T> *param, unsigned size)
166{
167 std::vector<BitUnionBaseType<T>> bitunion_vec(size);
168
169 arrayParamIn(cp, name, bitunion_vec);
170 std::copy(bitunion_vec.begin(), bitunion_vec.end(), param);
171}
172
147//
148// These macros are streamlined to use in serialize/unserialize
149// functions. It's assumed that serialize() has a parameter 'os' for
150// the ostream, and unserialize() has parameters 'cp' and 'section'.
151#define SERIALIZE_SCALAR(scalar) paramOut(cp, #scalar, scalar)
152
153#define UNSERIALIZE_SCALAR(scalar) paramIn(cp, #scalar, scalar)
154#define UNSERIALIZE_OPT_SCALAR(scalar) optParamIn(cp, #scalar, scalar)

--- 245 unchanged lines hidden ---
173//
174// These macros are streamlined to use in serialize/unserialize
175// functions. It's assumed that serialize() has a parameter 'os' for
176// the ostream, and unserialize() has parameters 'cp' and 'section'.
177#define SERIALIZE_SCALAR(scalar) paramOut(cp, #scalar, scalar)
178
179#define UNSERIALIZE_SCALAR(scalar) paramIn(cp, #scalar, scalar)
180#define UNSERIALIZE_OPT_SCALAR(scalar) optParamIn(cp, #scalar, scalar)

--- 245 unchanged lines hidden ---