SST  14.0.0
StructuralSimulationToolkit
component.h
1 // Copyright 2009-2024 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-2024, 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_COMPONENT_H
13 #define SST_CORE_COMPONENT_H
14 
15 #include "sst/core/baseComponent.h"
16 #include "sst/core/eli/elementinfo.h"
17 #include "sst/core/sst_types.h"
18 
19 #include <map>
20 
21 using namespace SST::Statistics;
22 
23 namespace SST {
24 class SubComponent;
25 
26 /**
27  * Main component object for the simulation.
28  * All models inherit from this.
29  */
30 class Component : public BaseComponent
31 {
32 public:
33  SST_ELI_DECLARE_BASE(Component)
34  // declare extern to limit compile times
35  SST_ELI_DECLARE_CTOR_EXTERN(ComponentId_t,SST::Params&)
36  // These categories will print in sst-info in the order they are
37  // listed here
38  SST_ELI_DECLARE_INFO_EXTERN(
46 
47  /** Constructor. Generally only called by the factory class.
48  @param id Unique component ID
49  */
50  Component(ComponentId_t id);
51  virtual ~Component();
52 
53  /** Register as a primary component, which allows the component to
54  specify when it is and is not OK to end simulation. The
55  simulator will not end simulation naturally (through use of
56  the Exit object) while any primary component has specified
57  primaryComponentDoNotEndSim(). However, it is still possible
58  for Actions other than Exit to end simulation. Once all
59  primary components have specified
60  primaryComponentOKToEndSim(), the Exit object will trigger and
61  end simulation.
62 
63  This must be called during simulation wireup (i.e during the
64  constructor for the component). By default, the state of the
65  primary component is set to OKToEndSim.
66 
67  If no component registers as a primary component, then the
68  Exit object will not be used for that simulation and
69  simulation termination must be accomplished through some other
70  mechanism (e.g. --stopAt flag, or some other Action object).
71 
72  @sa Component::primaryComponentDoNotEndSim()
73  @sa Component::primaryComponentOKToEndSim()
74  */
75  void registerAsPrimaryComponent();
76 
77  /** Tells the simulation that it should not exit. The component
78  will remain in this state until a call to
79  primaryComponentOKToEndSim().
80 
81  @sa Component::registerAsPrimaryComponent()
82  @sa Component::primaryComponentOKToEndSim()
83  */
84  void primaryComponentDoNotEndSim();
85 
86  /** Tells the simulation that it is now OK to end simulation.
87  Simulation will not end until all primary components have
88  called this function.
89 
90  @sa Component::registerAsPrimaryComponent()
91  @sa Component::primaryComponentDoNotEndSim()
92  */
93  void primaryComponentOKToEndSim();
94 
95  void serialize_order(SST::Core::Serialization::serializer& ser) override;
96  ImplementSerializable(SST::Component)
97 
98 protected:
99  friend class SubComponent;
100 
101  // For Serialization only
102  Component();
103 };
104 
105 } // namespace SST
106 
107 // These macros allow you to register a base class for a set of
108 // components that have the same (or substantially the same) ELI
109 // information. ELI information can be defined in the base class, and
110 // will be inherited by the child classes.
111 #define SST_ELI_REGISTER_COMPONENT_BASE(cls) \
112  SST_ELI_DECLARE_NEW_BASE(SST::Component,::cls) \
113  SST_ELI_NEW_BASE_CTOR(SST::ComponentId_t,SST::Params&)
114 
115 #define SST_ELI_REGISTER_COMPONENT_DERIVED_BASE(cls, base) \
116  SST_ELI_DECLARE_NEW_BASE(::base,::cls) \
117  SST_ELI_NEW_BASE_CTOR(SST::ComponentId_t,SST::Params&)
118 
119 // 'x' is needed because you can't pass ##__VAR_ARGS__ as the first
120 // item to the macro or you end up with a leading comma that won't
121 // compile.
122 #define ELI_GET_COMPONENT_DEFAULT(x, arg1, ...) arg1
123 
124 #define SST_ELI_REGISTER_COMPONENT(cls, lib, name, version, desc, cat, ...) \
125  SST_ELI_REGISTER_DERIVED(ELI_GET_COMPONENT_DEFAULT(,##__VA_ARGS__,SST::Component),cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
126  SST_ELI_CATEGORY_INFO(cat)
127 
128 #endif // SST_CORE_COMPONENT_H
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Definition: portsInfo.h:39
Main component object for the simulation.
Definition: component.h:30
Definition: statsInfo.h:39
Definition: action.cc:18
Definition: paramsInfo.h:40
Main component object for the simulation.
Definition: baseComponent.h:51
Definition: subcompSlotInfo.h:39
Parameter store.
Definition: params.h:55
Definition: attributeInfo.h:40
Definition: categoryInfo.h:25
Definition: componentInfo.h:36
Definition: profilePointInfo.h:39
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:28