Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions src/sst/core/serialization/impl/serialize_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,46 @@ constexpr bool is_adapter_v = is_same_type_template_v<T, std::stack> || is_same_

// Serialize adapter classes std::stack, std::queue, std::priority_queue
template <typename T>
class serialize_impl<T, std::enable_if_t<is_adapter_v<std::remove_pointer_t<T>>>>
class serialize_impl<T, std::enable_if_t<is_adapter_v<T>>>
{
struct S : std::remove_pointer_t<T>
struct S : T
{
using std::remove_pointer_t<T>::c; // access protected container
using T::c; // access protected container
};

void operator()(T& v, serializer& ser, ser_opt_t options)
{
if constexpr ( std::is_pointer_v<T> ) {
if ( ser.mode() == serializer::UNPACK ) v = new std::remove_pointer_t<T>;
SST_SER(static_cast<S&>(*v).c, options); // serialize the underlying container
}
else {
SST_SER(static_cast<S&>(v).c, options); // serialize the underlying container
switch ( ser.mode() ) {
case serializer::MAP:
ser.mapper().map_hierarchy_start(ser.getMapName(), new ObjectMapContainer<T>(&v));

// For std::priority_queue, mark the underlying container read-only
if constexpr ( is_same_type_template_v<T, std::priority_queue> ) options |= SerOption::map_read_only;

// serialize the underlying container
SST_SER_NAME(static_cast<S&>(v).c, "container", options);

ser.mapper().map_hierarchy_end();
break;

default:
// serialize the underlying container
SST_SER(static_cast<S&>(v).c, options);
break;
}
}

SST_FRIEND_SERIALIZE();
};

template <typename T>
class serialize_impl<T*, std::enable_if_t<is_adapter_v<T>>>
{
void operator()(T*& obj, serializer& ser, ser_opt_t options)
{
if ( ser.mode() == serializer::UNPACK ) obj = new T;
SST_SER(*obj, options);
}
SST_FRIEND_SERIALIZE();
};

Expand Down
1 change: 1 addition & 0 deletions src/sst/core/serialization/objectMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <cstdio>
#include <iostream>
#include <map>
#include <memory>
#include <ostream>
#include <string>
#include <type_traits>
Expand Down
Loading