SST  9.1.0
StructuralSimulationToolkit
component.h
1 // Copyright 2009-2019 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-2019, 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/sst_types.h>
16 
17 #include <map>
18 #include <string>
19 
20 #include <sst/core/baseComponent.h>
21 #include <sst/core/eli/elementinfo.h>
22 
23 using namespace SST::Statistics;
24 
25 namespace SST {
26 class SubComponent;
27 
28 /**
29  * Main component object for the simulation.
30  * All models inherit from this.
31  */
32 class Component: public BaseComponent {
33 public:
34  SST_ELI_DECLARE_BASE(Component)
35  //declare extern to limit compile times
36  SST_ELI_DECLARE_CTOR_EXTERN(ComponentId_t,SST::Params&)
37  SST_ELI_DECLARE_INFO_EXTERN(
43 
44  /** Constructor. Generally only called by the factory class.
45  @param id Unique component ID
46  */
47  Component( ComponentId_t id );
48  virtual ~Component();
49 
50 
51  /** Register that the simulation should not end until this
52  component says it is OK to. Calling this function (generally
53  done in Component::setup() or in component constructor)
54  increments a global counter. Calls to
55  Component::unregisterExit() decrements the counter. The
56  simulation cannot end unless this counter reaches zero, or the
57  simulation time limit is reached. This counter is synchronized
58  periodically with the other nodes.
59 
60  @sa Component::unregisterExit()
61  */
62  bool registerExit() __attribute__ ((deprecated("registerExit is deprecated and will be removed in SST version 10.0. Please use registerAsPrimaryComponent() and primaryComponentDoNotEndSim() instead.")));
63 
64  /** Indicate permission for the simulation to end. This function is
65  the mirror of Component::registerExit(). It decrements the
66  global counter, which, upon reaching zero, indicates that the
67  simulation can terminate. @sa Component::registerExit() */
68  bool unregisterExit() __attribute__ ((deprecated("unregisterExit is deprecated and will be removed in SST version 10.0. Please use primaryComponentOKToEndSim() instead.")));
69 
70  /** Register as a primary component, which allows the component to
71  specify when it is and is not OK to end simulation. The
72  simulator will not end simulation naturally (through use of
73  the Exit object) while any primary component has specified
74  primaryComponentDoNotEndSim(). However, it is still possible
75  for Actions other than Exit to end simulation. Once all
76  primary components have specified
77  primaryComponentOKToEndSim(), the Exit object will trigger and
78  end simulation.
79 
80  This must be called during simulation wireup (i.e during the
81  constructor for the component). By default, the state of the
82  primary component is set to OKToEndSim.
83 
84  If no component registers as a primary component, then the
85  Exit object will not be used for that simulation and
86  simulation termination must be accomplished through some other
87  mechanism (e.g. --stopAt flag, or some other Action object).
88 
89  @sa Component::primaryComponentDoNotEndSim()
90  @sa Component::primaryComponentOKToEndSim()
91  */
92  void registerAsPrimaryComponent();
93 
94  /** Tells the simulation that it should not exit. The component
95  will remain in this state until a call to
96  primaryComponentOKToEndSim().
97 
98  @sa Component::registerAsPrimaryComponent()
99  @sa Component::primaryComponentOKToEndSim()
100  */
101  void primaryComponentDoNotEndSim();
102 
103  /** Tells the simulation that it is now OK to end simulation.
104  Simulation will not end until all primary components have
105  called this function.
106 
107  @sa Component::registerAsPrimaryComponent()
108  @sa Component::primaryComponentDoNotEndSim()
109  */
110  void primaryComponentOKToEndSim();
111 
112 
113 protected:
114  friend class SubComponent;
115  Component() {} // Unused, but previously available
116 
117 };
118 
119 } //namespace SST
120 
121 #define SST_ELI_REGISTER_COMPONENT(cls,lib,name,version,desc,cat) \
122  SST_ELI_REGISTER_DERIVED(SST::Component,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
123  SST_ELI_CATEGORY_INFO(cat)
124 
125 #endif // SST_CORE_COMPONENT_H
Definition: portsInfo.h:30
Main component object for the simulation.
Definition: component.h:32
Definition: statsInfo.h:27
Definition: paramsInfo.h:28
Main component object for the simulation.
Definition: baseComponent.h:52
Definition: subcompSlotInfo.h:28
Parameter store.
Definition: params.h:45
Definition: categoryInfo.h:10
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:30