SST  15.1.0
StructuralSimulationToolkit
mempool.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_MEMPOOL_H
13 #define SST_CORE_MEMPOOL_H
14 
15 #include "sst/core/serialization/serializable.h"
16 
17 #include <string>
18 
19 namespace SST {
20 class Output;
21 
22 namespace Core {
23 
24 // Base class for those classes that will use mempools. Mempools are
25 // designed to be used primarily with Activities/Events and small data
26 // strcutures that are part of events. Thus, MemPoolItem inherits
27 // from Serializable because all these classes will generally need to
28 // serialize.
30 {
31 protected:
32  MemPoolItem() {}
33 
34 public:
35  /** Allocates memory from a memory pool for a new Activity */
36  void* operator new(std::size_t size) noexcept;
37 
38  /** Returns memory for this Activity to the appropriate memory pool */
39  void operator delete(void* ptr);
40 
41  /** Get a string represenation of the entry. The default version
42  * will just use the name of the class, retrieved through the
43  * cls_name() function inherited from the serialzable class, which
44  * will return the name of the last class to call one of the
45  * serialization macros (ImplementSerializable(),
46  * ImplementVirtualSerializable(), or NotSerializable()).
47  * Subclasses can override this function if they want to add
48  * additional information.
49  */
50  virtual std::string toString() const;
51 
52 
53  virtual void print(const std::string& header, Output& out) const;
54 
55  ImplementVirtualSerializable(SST::Core::MemPoolItem)
56 };
57 
58 } // namespace Core
59 } // namespace SST
60 
61 #endif // SST_CORE_MEMPOOL_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:57
virtual std::string toString() const
Get a string represenation of the entry.
Definition: mempool.cc:506
Definition: action.cc:18
Definition: serializable.h:23
Definition: mempool.h:29