SST  9.0.0
StructuralSimulationToolkit
subcomponent.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 
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/component.h>
19 #include <sst/core/module.h>
20 #include <sst/core/eli/elementinfo.h>
21 
22 namespace SST {
23 
24 /**
25  SubComponent is a class loadable through the factory which allows
26  dynamic functionality to be added to a Component. The
27  SubComponent API is nearly identical to the Component API and all
28  the calls are proxied to the parent Component.
29 */
30 class SubComponent : public Module, public BaseComponent {
31 
32 public:
33  SST_ELI_DECLARE_BASE(SubComponent)
34  //declare extern to limit compile times
35  SST_ELI_DECLARE_CTOR_EXTERN(Component*,SST::Params&)
36  SST_ELI_DECLARE_INFO_EXTERN(
42 
43  SubComponent(Component* parent);
44  SubComponent(ComponentId_t id);
45 
46  virtual ~SubComponent() {};
47 
48  /** Used during the init phase. The method will be called each phase of initialization.
49  Initialization ends when no components have sent any data. */
50  virtual void init(unsigned int UNUSED(phase)) override {}
51  /** Called after all components have been constructed and initialization has
52  completed, but before simulation time has begun. */
53  virtual void setup( ) override { }
54  /** Called after simulation completes, but before objects are
55  destroyed. A good place to print out statistics. */
56  virtual void finish( ) override { }
57 
58 protected:
59  Component* const parent __attribute__ ((deprecated("The parent data member will be removed in SST version 10.0. With the new subcomponent structure, direct access to your parent is not allowed.")));
60 
61  /* Deprecate? Old ELI style*/
62  SubComponent* loadSubComponent(std::string type, Params& params) __attribute__ ((deprecated("This version of loadSubComponent will be removed in SST version 10.0. Please switch to new user defined API (LoadUserSubComponent(std::string, int, ARGS...)).")));
63 
64 
65 private:
66  friend class Component;
67 
68 };
69 
70 } //namespace SST
71 
72 
73 // Legacy version of subcomponent registration
74 #define SST_ELI_REGISTER_SUBCOMPONENT(cls,lib,name,version,desc,interface) \
75  SST_ELI_REGISTER_DERIVED(SST::SubComponent,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
76  SST_ELI_INTERFACE_INFO(interface)
77 
78 // New way to register subcomponents. Must register an interface
79 // (API) first, then you can register a subcomponent that implements
80 // it
81 #define SST_ELI_REGISTER_SUBCOMPONENT_API(cls,...) \
82  SST_ELI_DECLARE_NEW_BASE(SST::SubComponent,::cls) \
83  SST_ELI_NEW_BASE_CTOR(ComponentId_t,Params&,##__VA_ARGS__)
84 
85 #define SST_ELI_REGISTER_SUBCOMPONENT_DERIVED_API(cls,base,...) \
86  SST_ELI_DECLARE_NEW_BASE(::base,::cls) \
87  SST_ELI_NEW_BASE_CTOR(ComponentId_t,Params&,##__VA_ARGS__)
88 
89 #define SST_ELI_REGISTER_SUBCOMPONENT_DERIVED(cls,lib,name,version,desc,interface) \
90  SST_ELI_REGISTER_DERIVED(::interface,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
91  SST_ELI_INTERFACE_INFO(#interface)
92 
93 #endif // SST_CORE_SUBCOMPONENT_H
virtual void finish() override
Called after simulation completes, but before objects are destroyed.
Definition: subcomponent.h:56
Definition: portsInfo.h:30
Main component object for the simulation.
Definition: component.h:32
Definition: statsInfo.h:27
Module is a tag class used with the loadModule function.
Definition: module.h:22
Definition: paramsInfo.h:28
virtual void setup() override
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: subcomponent.h:53
Main component object for the simulation.
Definition: baseComponent.h:52
Definition: subcompSlotInfo.h:28
Parameter store.
Definition: params.h:45
virtual void init(unsigned int UNUSED(phase)) override
Used during the init phase.
Definition: subcomponent.h:50
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:30
Definition: interfaceInfo.h:7