SST  11.0.0
StructuralSimulationToolkit
subcomponent.h
1 // Copyright 2009-2021 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-2021, 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 
13 #ifndef SST_CORE_SUBCOMPONENT_H
14 #define SST_CORE_SUBCOMPONENT_H
15 
16 #include "sst/core/warnmacros.h"
17 #include "sst/core/baseComponent.h"
18 #include "sst/core/module.h"
19 #include "sst/core/eli/elementinfo.h"
20 
21 namespace SST {
22 
23 /**
24  SubComponent is a class loadable through the factory which allows
25  dynamic functionality to be added to a Component. The
26  SubComponent API is nearly identical to the Component API and all
27  the calls are proxied to the parent Component.
28 */
29 class SubComponent : public Module, public BaseComponent {
30 
31 public:
32  SST_ELI_DECLARE_BASE(SubComponent)
33  //declare extern to limit compile times
34  SST_ELI_DECLARE_CTOR_EXTERN(ComponentId_t)
35  SST_ELI_DECLARE_INFO_EXTERN(
41 
42  SubComponent(ComponentId_t id);
43 
44  virtual ~SubComponent() {};
45 
46  /** Used during the init phase. The method will be called each phase of initialization.
47  Initialization ends when no components have sent any data. */
48  virtual void init(unsigned int UNUSED(phase)) override {}
49  /** Called after all components have been constructed and initialization has
50  completed, but before simulation time has begun. */
51  virtual void setup( ) override { }
52  /** Called after simulation completes, but before objects are
53  destroyed. A good place to print out statistics. */
54  virtual void finish( ) override { }
55 
56 protected:
57 
58 private:
59  friend class Component;
60 
61 };
62 
63 } //namespace SST
64 
65 
66 
67 // New way to register subcomponents. Must register an interface
68 // (API) first, then you can register a subcomponent that implements
69 // it
70 #define SST_ELI_REGISTER_SUBCOMPONENT_API(cls,...) \
71  SST_ELI_DECLARE_NEW_BASE(SST::SubComponent,::cls) \
72  SST_ELI_NEW_BASE_CTOR(SST::ComponentId_t,SST::Params&,##__VA_ARGS__)
73 
74 #define SST_ELI_REGISTER_SUBCOMPONENT_DERIVED_API(cls,base,...) \
75  SST_ELI_DECLARE_NEW_BASE(::base,::cls) \
76  SST_ELI_NEW_BASE_CTOR(SST::ComponentId_t,SST::Params&,##__VA_ARGS__)
77 
78 #define SST_ELI_REGISTER_SUBCOMPONENT_DERIVED(cls,lib,name,version,desc,interface) \
79  SST_ELI_REGISTER_DERIVED(::interface,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
80  SST_ELI_INTERFACE_INFO(#interface)
81 
82 #endif // SST_CORE_SUBCOMPONENT_H
virtual void finish() override
Called after simulation completes, but before objects are destroyed.
Definition: subcomponent.h:54
Definition: portsInfo.h:41
Main component object for the simulation.
Definition: component.h:31
Definition: statsInfo.h:38
Module is a tag class used with the loadModule function.
Definition: module.h:22
Definition: paramsInfo.h:39
virtual void setup() override
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: subcomponent.h:51
Main component object for the simulation.
Definition: baseComponent.h:53
Definition: subcompSlotInfo.h:39
virtual void init(unsigned int UNUSED(phase)) override
Used during the init phase.
Definition: subcomponent.h:48
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29
Definition: interfaceInfo.h:18