SST  10.1.0
StructuralSimulationToolkit
component.h
1 // Copyright 2009-2020 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-2020, 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 
19 #include "sst/core/baseComponent.h"
20 #include "sst/core/eli/elementinfo.h"
21 
22 using namespace SST::Statistics;
23 
24 namespace SST {
25 class SubComponent;
26 
27 /**
28  * Main component object for the simulation.
29  * All models inherit from this.
30  */
31 class Component: public BaseComponent {
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  SST_ELI_DECLARE_INFO_EXTERN(
42 
43  /** Constructor. Generally only called by the factory class.
44  @param id Unique component ID
45  */
46  Component( ComponentId_t id );
47  virtual ~Component();
48 
49  /** Register as a primary component, which allows the component to
50  specify when it is and is not OK to end simulation. The
51  simulator will not end simulation naturally (through use of
52  the Exit object) while any primary component has specified
53  primaryComponentDoNotEndSim(). However, it is still possible
54  for Actions other than Exit to end simulation. Once all
55  primary components have specified
56  primaryComponentOKToEndSim(), the Exit object will trigger and
57  end simulation.
58 
59  This must be called during simulation wireup (i.e during the
60  constructor for the component). By default, the state of the
61  primary component is set to OKToEndSim.
62 
63  If no component registers as a primary component, then the
64  Exit object will not be used for that simulation and
65  simulation termination must be accomplished through some other
66  mechanism (e.g. --stopAt flag, or some other Action object).
67 
68  @sa Component::primaryComponentDoNotEndSim()
69  @sa Component::primaryComponentOKToEndSim()
70  */
71  void registerAsPrimaryComponent();
72 
73  /** Tells the simulation that it should not exit. The component
74  will remain in this state until a call to
75  primaryComponentOKToEndSim().
76 
77  @sa Component::registerAsPrimaryComponent()
78  @sa Component::primaryComponentOKToEndSim()
79  */
80  void primaryComponentDoNotEndSim();
81 
82  /** Tells the simulation that it is now OK to end simulation.
83  Simulation will not end until all primary components have
84  called this function.
85 
86  @sa Component::registerAsPrimaryComponent()
87  @sa Component::primaryComponentDoNotEndSim()
88  */
89  void primaryComponentOKToEndSim();
90 
91 
92 protected:
93  friend class SubComponent;
94  Component() {} // Unused, but previously available
95 
96 };
97 
98 } //namespace SST
99 
100 #define SST_ELI_REGISTER_COMPONENT(cls,lib,name,version,desc,cat) \
101  SST_ELI_REGISTER_DERIVED(SST::Component,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
102  SST_ELI_CATEGORY_INFO(cat)
103 
104 #endif // SST_CORE_COMPONENT_H
Definition: portsInfo.h:41
Main component object for the simulation.
Definition: component.h:31
Definition: statsInfo.h:38
Definition: paramsInfo.h:39
Main component object for the simulation.
Definition: baseComponent.h:52
Definition: subcompSlotInfo.h:39
Parameter store.
Definition: params.h:44
Definition: categoryInfo.h:21
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29