SST 15.0
Structural Simulation Toolkit
serialize_atomic.h
1// Copyright 2009-2025 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2025, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_SERIALIZATION_IMPL_SERIALIZE_ATOMIC_H
13#define SST_CORE_SERIALIZATION_IMPL_SERIALIZE_ATOMIC_H
14
15#ifndef SST_INCLUDING_SERIALIZE_H
16#warning \
17 "The header file sst/core/serialization/impl/serialize_atomic.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"
18#endif
19
20#include "sst/core/serialization/serializer.h"
21
22#include <atomic>
23
24namespace SST::Core::Serialization {
25
26template <class T>
27class serialize_impl<std::atomic<T>>
28{
29 void operator()(std::atomic<T>& v, serializer& ser, ser_opt_t UNUSED(options))
30 {
31 switch ( ser.mode() ) {
32 case serializer::SIZER:
33 {
34 T t = v.load();
35 SST_SER(t);
36 // ser.size(t);
37 break;
38 }
39 case serializer::PACK:
40 {
41 T t = v.load();
42 SST_SER(t);
43 break;
44 }
45 case serializer::UNPACK:
46 {
47 T val {};
48 SST_SER(val);
49 v.store(val);
50 break;
51 }
52 case serializer::MAP:
53 {
54 // TODO: Add support for mapping mode
55 break;
56 }
57 }
58 }
59
60 SST_FRIEND_SERIALIZE();
61};
62
63} // namespace SST::Core::Serialization
64
65#endif // SST_CORE_SERIALIZATION_IMPL_SERIALIZE_VECTOR_H
Base serialize class.
Definition serialize.h:110
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:45