12 #ifndef SST_CORE_SERIALIZATION_SERIALIZABLE_H
13 #define SST_CORE_SERIALIZATION_SERIALIZABLE_H
15 #include <sst/core/serialization/serializer.h>
16 #include <unordered_map>
22 namespace Serialization {
29 inline uint32_t type_hash(
const char* key)
31 int len = ::strlen(key);
33 for(
int i = 0; i < len; ++i)
50 constexpr uint32_t B(
const uint32_t b)
56 constexpr uint32_t A(
const uint32_t a)
58 return B( (a << 10 ) + a);
63 constexpr uint32_t ct_hash_rec(
const char* str)
65 return A( str[idx] + ct_hash_rec<idx-1>(str) );
71 constexpr uint32_t ct_hash_rec<size_t(-1)>(
const char* str)
77 constexpr uint32_t E(
const uint32_t e)
83 constexpr uint32_t D(
const uint32_t d)
85 return E( (d >> 11) ^ d);
89 constexpr uint32_t C(
const uint32_t c)
91 return D( (c << 3 ) + c);
97 constexpr uint32_t ct_hash(
const char* str)
99 return C(ct_hash_rec<idx>(str));
103 #define COMPILE_TIME_HASH(x) (::SST::Core::Serialization::pvt::ct_hash<sizeof(x)-2>(x))
112 cls_name()
const = 0;
123 typedef enum { ConstructorFlag } cxn_flag_t;
124 static void serializable_abort(uint32_t line,
const char* file,
const char* func,
const char* obj);
132 #define ImplementVirtualSerializable(obj) \
134 obj(cxn_flag_t flag){}
137 #define NotSerializable(obj) \
141 serializable_abort(CALL_INFO_LONG, #obj); \
144 serialize_order(SST::Core::Serialization::serializer& sst){ \
153 construct_deserialize_stub() { \
157 virtual std::string \
158 serialization_name() const { \
162 virtual const char* \
168 #define ImplementSerializableDefaultConstructor(obj) \
170 virtual const char* \
176 return SST::Core::Serialization::serializable_builder_impl<obj>::static_cls_id(); \
179 construct_deserialize_stub() { \
182 virtual std::string \
183 serialization_name() const { \
187 friend class SST::Core::Serialization::serializable_builder_impl<obj>; \
189 you_forgot_to_add_ImplementSerializable_to_this_class() { \
193 #define ImplementSerializable(obj) \
195 ImplementSerializableDefaultConstructor(obj)
209 virtual const uint32_t
220 static const char* name_;
221 static const uint32_t cls_id_;
226 return T::construct_deserialize_stub();
251 return (
typeid(T) ==
typeid(*ser));
258 typedef std::unordered_map<long, serializable_builder*> builder_map;
259 static builder_map* builders_;
263 get_serializable(uint32_t cls_id);
274 return (*builders_)[cls_id]->sanity(ser);
297 #define SerializableName(obj) #obj
299 #define DeclareSerializable(obj)
302 #include <sst/core/serialization/serialize_serializable.h>
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Definition: serializable.h:217
Definition: serializable.h:108
Definition: serializable.h:198
static uint32_t add_builder(serializable_builder *builder, const char *name)
Definition: serializable.cc:35
Definition: serializable.h:255
Definition: serializable.h:128