12 #ifndef SST_CORE_SERIALIZATION_SERIALIZABLE_H 13 #define SST_CORE_SERIALIZATION_SERIALIZABLE_H 15 #include <sst/core/serialization/serializer.h> 16 #include <sst/core/warnmacros.h> 17 #include <unordered_map> 23 namespace Serialization {
30 inline uint32_t type_hash(
const char* key)
32 int len = ::strlen(key);
34 for(
int i = 0; i < len; ++i)
51 constexpr uint32_t B(
const uint32_t b)
57 constexpr uint32_t A(
const uint32_t a)
59 return B( (a << 10 ) + a);
64 constexpr uint32_t ct_hash_rec(
const char* str)
66 return A( str[idx] + ct_hash_rec<idx-1>(str) );
72 constexpr uint32_t ct_hash_rec<size_t(-1)>(
const char* UNUSED(str))
78 constexpr uint32_t E(
const uint32_t e)
84 constexpr uint32_t D(
const uint32_t d)
86 return E( (d >> 11) ^ d);
90 constexpr uint32_t C(
const uint32_t c)
92 return D( (c << 3 ) + c);
98 constexpr uint32_t ct_hash(
const char* str)
100 return C(ct_hash_rec<idx>(str));
104 #define COMPILE_TIME_HASH(x) (::SST::Core::Serialization::pvt::ct_hash<sizeof(x)-2>(x)) 113 cls_name()
const = 0;
120 virtual std::string serialization_name()
const = 0;
125 typedef enum { ConstructorFlag } cxn_flag_t;
126 static void serializable_abort(uint32_t line,
const char* file,
const char* func,
const char* obj);
134 #define ImplementVirtualSerializable(obj) \ 136 obj(cxn_flag_t flag){} 139 #define NotSerializable(obj) \ 143 serializable_abort(CALL_INFO_LONG, #obj); \ 146 serialize_order(SST::Core::Serialization::serializer& UNUSED(sst)) override { \ 150 cls_id() const override { \ 155 construct_deserialize_stub() { \ 159 virtual std::string \ 160 serialization_name() const override { \ 164 virtual const char* \ 165 cls_name() const override { \ 170 #define ImplementSerializableDefaultConstructor(obj) \ 172 virtual const char* \ 173 cls_name() const override { \ 177 cls_id() const override { \ 178 return SST::Core::Serialization::serializable_builder_impl<obj>::static_cls_id(); \ 181 construct_deserialize_stub() { \ 184 virtual std::string \ 185 serialization_name() const override { \ 189 friend class SST::Core::Serialization::serializable_builder_impl<obj>; \ 191 you_forgot_to_add_ImplementSerializable_to_this_class() { \ 195 #define ImplementSerializable(obj) \ 197 ImplementSerializableDefaultConstructor(obj) 222 static const char* name_;
223 static const uint32_t cls_id_;
227 build()
const override {
228 return T::construct_deserialize_stub();
232 name()
const override {
237 cls_id()
const override {
253 return (
typeid(T) ==
typeid(*ser));
260 typedef std::unordered_map<long, serializable_builder*> builder_map;
261 static builder_map* builders_;
265 get_serializable(uint32_t cls_id);
276 return (*builders_)[cls_id]->sanity(ser);
299 #define SerializableName(obj) #obj 301 #define DeclareSerializable(obj) 304 #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:219
Definition: serializable.h:109
Definition: serializable.h:200
static uint32_t add_builder(serializable_builder *builder, const char *name)
Definition: serializable.cc:35
Definition: serializable.h:257
Definition: serializable.h:130