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