12#ifndef SST_CORE_SERIALIZATION_IMPL_SERIALIZE_TRIVIAL_H
13#define SST_CORE_SERIALIZATION_IMPL_SERIALIZE_TRIVIAL_H
15#ifndef SST_INCLUDING_SERIALIZE_H
17 "The header file sst/core/serialization/impl/serialize_trivial.h should not be directly included as it is not part of the stable public API. The file is included in sst/core/serialization/serialize.h"
20#include "sst/core/output.h"
21#include "sst/core/serialization/serializer.h"
31namespace SST::Core::Serialization {
38template <
typename T,
size_t S>
56 std::enable_if_t<std::conjunction_v<std::negation<is_trivially_serializable_excluded<std::remove_pointer_t<T>>>,
57 is_trivially_serializable<std::remove_pointer_t<T>>>>>
59 void operator()(T& t,
serializer& ser, ser_opt_t options)
61 using U = std::remove_pointer_t<T>;
62 const auto& tPtr = get_ptr(t);
63 switch ( ser.mode() ) {
67 if constexpr ( std::is_arithmetic_v<U> || std::is_enum_v<U> || complex_properties<U>::is_complex ||
68 (std::is_constructible_v<U, std::string> && std::is_convertible_v<U, std::string>)) {
70 if ( SerOption::is_set(options, SerOption::map_read_only) ) obj_map->
setReadOnly();
71 ser.mapper().map_object(ser.getMapName(), obj_map);
76 static int UNUSED(once) = [] {
77 Output& output = Output::getDefaultObject();
80 const char* type = typestr.c_str();
81 if constexpr ( std::is_class_v<U> )
83 "Warning: Trivially serializable class type %s does not automatically have an "
84 "ObjectMap created for it.\nTo create an ObjectMap for %s, use one of these "
85 "methods:\n1. Add a serialize_order() method to %s.\n2. Define a serialize_impl<%s> "
86 "specialization.\n3. Add a constructor taking a std::string and an operator "
87 "std::string() const to %s, to allow conversion from/to std::string.\n\n",
88 type, type, type, type, type);
89 else if constexpr ( std::is_union_v<U> )
91 "Warning: Trivially serializable union type %s does not automatically have an "
92 "ObjectMap created for it.\nTo create an ObjectMap for %s, use one of these "
93 "methods:\n1. Define a serialize_impl<%s> specialization.\n2. Add a constructor "
94 "taking a std::string and an operator std::string() const to %s, to allow "
95 "conversion from/to std::string.\n\n",
96 type, type, type, type);
99 "Warning: Trivially serializable type %s does not automatically have an ObjectMap "
100 "created for it.\nTo create an ObjectMap for %s, define a serialize_impl<%s> "
101 "specialization.\n\n",
109 case serializer::UNPACK:
110 if constexpr ( std::is_pointer_v<T> ) t =
new U();
114 ser.primitive(*tPtr);
119 SST_FRIEND_SERIALIZE();
ObjectMap representing fundamental types, and classes treated as fundamental types.
Definition objectMap.h:1230
Base class for objects created by the serializer mapping mode used to map the variables for objects.
Definition objectMap.h:188
static std::string demangle_name(const char *name)
Static function to demangle type names returned from typeid(T).name().
Definition objectMap.cc:152
void setReadOnly(bool state=true)
Set the read-only state of the object.
Definition objectMap.h:263
Base serialize class.
Definition serialize.h:132
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:43
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file.
Definition output.h:58
uint32_t getVerboseLevel() const
Returns object verbose level.
Definition output.cc:109
void verbose(uint32_t line, const char *file, const char *func, uint32_t output_level, uint32_t output_bits, const char *format,...) const
Output the verbose message with formatting as specified by the format parameter.
Definition output.h:232
Definition serialize_trivial.h:36