SST  6.0.0
StructuralSimulationToolkit
SST::Component Class Reference

Main component object for the simulation. More...

#include <component.h>

Inheritance diagram for SST::Component:
SST::IntrospectedComponent

Public Member Functions

 Component (ComponentId_t id)
 Constructor. More...
 
virtual void emergencyShutdown (void)
 Called when SIGINT or SIGTERM has been seen. More...
 
ComponentId_t getId () const
 Returns unique component ID.
 
const std::string & getName () const
 Returns component Name.
 
virtual void init (unsigned int phase)
 Component's type, set by the factory when the object is created. More...
 
virtual void setup ()
 Called after all components have been constructed and inialization has completed, but before simulation time has begun. More...
 
virtual void finish ()
 Called after simulation completes, but before objects are destroyed. More...
 
virtual bool Status ()
 Currently unused function.
 
virtual void printStatus (Output &out)
 Called by the Simulation to request that the component print it's current status. More...
 
bool isPortConnected (const std::string &name) const
 Determine if a port name is connected to any links.
 
LinkconfigureLink (std::string name, TimeConverter *time_base, Event::HandlerBase *handler=NULL)
 Configure a Link. More...
 
LinkconfigureLink (std::string name, std::string time_base, Event::HandlerBase *handler=NULL)
 Configure a Link. More...
 
LinkconfigureLink (std::string name, Event::HandlerBase *handler=NULL)
 Configure a Link. More...
 
LinkconfigureSelfLink (std::string name, TimeConverter *time_base, Event::HandlerBase *handler=NULL)
 Configure a SelfLink (Loopback link) More...
 
LinkconfigureSelfLink (std::string name, std::string time_base, Event::HandlerBase *handler=NULL)
 Configure a SelfLink (Loopback link) More...
 
LinkconfigureSelfLink (std::string name, Event::HandlerBase *handler=NULL)
 Configure a SelfLink (Loopback link) More...
 
TimeConverterregisterClock (std::string freq, Clock::HandlerBase *handler, bool regAll=true)
 Registers a clock for this component. More...
 
TimeConverterregisterClock (const UnitAlgebra &freq, Clock::HandlerBase *handler, bool regAll=true)
 
void unregisterClock (TimeConverter *tc, Clock::HandlerBase *handler)
 Removes a clock handler from the component.
 
Cycle_t reregisterClock (TimeConverter *freq, Clock::HandlerBase *handler)
 Reactivates an existing Clock and Handler. More...
 
Cycle_t getNextClockCycle (TimeConverter *freq)
 Returns the next Cycle that the TimeConverter would fire.
 
TimeConverterregisterOneShot (std::string timeDelay, OneShot::HandlerBase *handler)
 Registers a OneShot event for this component. More...
 
TimeConverterregisterOneShot (const UnitAlgebra &timeDelay, OneShot::HandlerBase *handler)
 
TimeConverterregisterTimeBase (std::string base, bool regAll=true)
 Registers a default time base for the component and optionally sets the the component's links to that timebase. More...
 
TimeConvertergetTimeConverter (const std::string &base)
 
TimeConvertergetTimeConverter (const UnitAlgebra &base)
 
SimTime_t getCurrentSimTime (TimeConverter *tc) const
 return the time since the simulation began in units specified by the parameter. More...
 
SimTime_t getCurrentSimTime () const
 return the time since the simulation began in the default timebase
 
SimTime_t getCurrentSimTime (std::string base)
 return the time since the simulation began in timebase specified More...
 
SimTime_t getCurrentSimTimeNano () const
 Utility function to return the time since the simulation began in nanoseconds.
 
SimTime_t getCurrentSimTimeMicro () const
 Utility function to return the time since the simulation began in microseconds.
 
SimTime_t getCurrentSimTimeMilli () const
 Utility function to return the time since the simulation began in milliseconds.
 
template<typename T >
Statistic< T > * registerStatisticCore (std::string statName, std::string statSubId="")
 Registers a statistic. More...
 
template<typename T >
Statistic< T > * registerStatistic (std::string statName, std::string statSubId="")
 
template<typename T >
Statistic< T > * registerStatistic (const char *statName, const char *statSubId="")
 
bool registerExit ()
 Register that the simulation should not end until this component says it is OK to. More...
 
bool unregisterExit ()
 Indicate permission for the simulation to end. More...
 
void registerAsPrimaryComponent ()
 Register as a primary component, which allows the component to specifiy when it is and is not OK to end simulation. More...
 
void primaryComponentDoNotEndSim ()
 Tells the simulation that it should not exit. More...
 
void primaryComponentOKToEndSim ()
 Tells the simulation that it is now OK to end simulation. More...
 
ModuleloadModule (std::string type, Params &params)
 Loads a module from an element Library. More...
 
ModuleloadModuleWithComponent (std::string type, Component *comp, Params &params)
 Loads a module from an element Library. More...
 
SubComponentloadSubComponent (std::string type, Component *comp, Params &params)
 Loads a SubComponent from an element Library. More...
 

Static Public Member Functions

static bool isPortValidForComponent (const std::string &comp_name, const std::string &port_name)
 

Protected Member Functions

void setDefaultTimeBase (TimeConverter *tc)
 Manually set the default detaulTimeBase.
 
LinkselfLink (std::string name, Event::HandlerBase *handler=NULL)
 Creates a new selfLink.
 
SharedRegiongetLocalSharedRegion (const std::string &key, size_t size)
 Find a lookup table.
 
SharedRegiongetGlobalSharedRegion (const std::string &key, size_t size, SharedRegionMerger *merger=NULL)
 
SimulationgetSimulation () const
 

Protected Attributes

TimeConverterdefaultTimeBase
 Timebase used if no other timebase is specified for calls like Component::getCurrentSimTime(). More...
 

Friends

class SubComponent
 

Detailed Description

Main component object for the simulation.

All models inherit from this.

Constructor & Destructor Documentation

SST::Component::Component ( ComponentId_t  id)

Constructor.

Generally only called by the factory class.

Parameters
idUnique component ID

References SST::Simulation::getSimulation().

Member Function Documentation

Link * SST::Component::configureLink ( std::string  name,
TimeConverter time_base,
Event::HandlerBase handler = NULL 
)

Configure a Link.

Parameters
name- Port Name on which the link to configure is attached.
time_base- Time Base of the link
handler- Optional Handler to be called when an Event is received
Returns
A pointer to the configured link, or NULL if an error occured.

References SST::LinkMap::getLink(), SST::Link::setDefaultTimeBase(), SST::Link::setFunctor(), and SST::Link::setPolling().

Referenced by SST::SubComponent::configureLink(), configureLink(), and configureSelfLink().

Link * SST::Component::configureLink ( std::string  name,
std::string  time_base,
Event::HandlerBase handler = NULL 
)

Configure a Link.

Parameters
name- Port Name on which the link to configure is attached.
time_base- Time Base of the link
handler- Optional Handler to be called when an Event is received
Returns
A pointer to the configured link, or NULL if an error occured.

References configureLink().

Link * SST::Component::configureLink ( std::string  name,
Event::HandlerBase handler = NULL 
)

Configure a Link.

Parameters
name- Port Name on which the link to configure is attached.
handler- Optional Handler to be called when an Event is received
Returns
A pointer to the configured link, or NULL if an error occured.

References SST::LinkMap::getLink(), SST::Link::setFunctor(), and SST::Link::setPolling().

Link * SST::Component::configureSelfLink ( std::string  name,
TimeConverter time_base,
Event::HandlerBase handler = NULL 
)

Configure a SelfLink (Loopback link)

Parameters
name- Name of the self-link port
time_base- Time Base of the link
handler- Optional Handler to be called when an Event is received
Returns
A pointer to the configured link, or NULL if an error occured.

References configureLink().

Referenced by SST::SubComponent::configureSelfLink().

Link * SST::Component::configureSelfLink ( std::string  name,
std::string  time_base,
Event::HandlerBase handler = NULL 
)

Configure a SelfLink (Loopback link)

Parameters
name- Name of the self-link port
time_base- Time Base of the link
handler- Optional Handler to be called when an Event is received
Returns
A pointer to the configured link, or NULL if an error occured.

References configureLink().

Link * SST::Component::configureSelfLink ( std::string  name,
Event::HandlerBase handler = NULL 
)

Configure a SelfLink (Loopback link)

Parameters
name- Name of the self-link port
handler- Optional Handler to be called when an Event is received
Returns
A pointer to the configured link, or NULL if an error occured.

References configureLink().

virtual void SST::Component::emergencyShutdown ( void  )
inlinevirtual

Called when SIGINT or SIGTERM has been seen.

Allows components opportunity to clean up external state.

virtual void SST::Component::finish ( )
inlinevirtual

Called after simulation completes, but before objects are destroyed.

A good place to print out statistics.

SimTime_t SST::Component::getCurrentSimTime ( TimeConverter tc) const

return the time since the simulation began in units specified by the parameter.

Parameters
tcTimeConverter specificing the units

References SST::TimeConverter::convertFromCoreTime().

SimTime_t SST::Component::getCurrentSimTime ( std::string  base)

return the time since the simulation began in timebase specified

Parameters
baseTimebase frequency in SI Units

References getCurrentSimTime().

virtual void SST::Component::init ( unsigned int  phase)
inlinevirtual

Component's type, set by the factory when the object is created.

It is identical to the configuration string used to create the component. I.e. the XML "<component id="aFoo"><foo>..." would set component::type to "foo" Used during the init phase. The method will be called each phase of initialization. Initialization ends when no components have sent any data.

Module * SST::Component::loadModule ( std::string  type,
Params params 
)

Loads a module from an element Library.

Parameters
typeFully Qualified library.moduleName
paramsParameters the module should use for configuration
Returns
handle to new instance of module, or NULL on failure.
Module * SST::Component::loadModuleWithComponent ( std::string  type,
Component comp,
Params params 
)

Loads a module from an element Library.

Parameters
typeFully Qualified library.moduleName
compPointer to component to pass to Module's constructor
paramsParameters the module should use for configuration
Returns
handle to new instance of module, or NULL on failure.
SubComponent * SST::Component::loadSubComponent ( std::string  type,
Component comp,
Params params 
)

Loads a SubComponent from an element Library.

Parameters
typeFully Qualified library.moduleName
compPointer to component to pass to SuComponent's constructor
paramsParameters the module should use for configuration
Returns
handle to new instance of SubComponent, or NULL on failure.
void SST::Component::primaryComponentDoNotEndSim ( )

Tells the simulation that it should not exit.

The component will remain in this state until a call to primaryComponentOKToEndSim().

See also
Component::registerAsPrimaryComponent()
Component::primaryComponentOKToEndSim()

References SST::Simulation::getExit(), getId(), SST::Simulation::getRank(), and SST::Exit::refInc().

void SST::Component::primaryComponentOKToEndSim ( )

Tells the simulation that it is now OK to end simulation.

Simulation will not end until all primary components have called this function.

See also
Component::registerAsPrimaryComponent()
Component::primaryComponentDoNotEndSim()

References SST::Simulation::getExit(), getId(), SST::Simulation::getRank(), and SST::Exit::refDec().

virtual void SST::Component::printStatus ( Output out)
inlinevirtual

Called by the Simulation to request that the component print it's current status.

Useful for debugging.

Parameters
outThe Output class which should be used to print component status.
void SST::Component::registerAsPrimaryComponent ( )

Register as a primary component, which allows the component to specifiy when it is and is not OK to end simulation.

The simulator will not end simulation natuarally (through use of the Exit object) while any primary component has specified primaryComponentDoNotEndSim(). However, it is still possible for Actions other than Exit to end simulation. Once all primary components have specified primaryComponentOKToEndSim(), the Exit object will trigger and end simulation.

This must be called during simulation wireup (i.e during the constructor for the component). By default, the state of the primary component is set to OKToEndSim.

If no component registers as a primary component, then the Exit object will not be used for that simulation and simulation termination must be accomplished through some other mechanism (e.g. –stopAt flag, or some other Action object).

See also
Component::primaryComponentDoNotEndSim()
Component::primaryComponentOKToEndSim()
TimeConverter * SST::Component::registerClock ( std::string  freq,
Clock::HandlerBase handler,
bool  regAll = true 
)

Registers a clock for this component.

Parameters
freqFrequency for the clock in SI units
handlerPointer to Clock::HandlerBase which is to be invoked at the specified interval
regAllShould this clock perioud be used as the default time base for all of the links connected to this component

References defaultTimeBase, SST::LinkMap::getLinkMap(), and SST::Simulation::registerClock().

Referenced by SST::SubComponent::registerClock().

bool SST::Component::registerExit ( )

Register that the simulation should not end until this component says it is OK to.

Calling this function (generally done in Component::setup() or in component constructor) increments a global counter. Calls to Component::unregisterExit() decrements the counter. The simulation cannot end unless this counter reaches zero, or the simulation time limit is reached. This counter is synchonized periodically with the other nodes.

See also
Component::unregisterExit()

References SST::Simulation::getExit(), getId(), SST::Simulation::getRank(), and SST::Exit::refInc().

TimeConverter * SST::Component::registerOneShot ( std::string  timeDelay,
OneShot::HandlerBase handler 
)

Registers a OneShot event for this component.

Note: OneShot cannot be canceled, and will always callback after the timedelay.

Parameters
timeDelayTime delay for the OneShot in SI units
handlerPointer to OneShot::HandlerBase which is to be invoked at the specified interval

References SST::Simulation::registerOneShot().

template<typename T >
Statistic<T>* SST::Component::registerStatisticCore ( std::string  statName,
std::string  statSubId = "" 
)
inline

Registers a statistic.

If Statistic is allowed to run (controlled by Python runtime parameters), then a statistic will be created and returned. If not allowed to run, then a NullStatistic will be returned. In either case, the returned value should be used for all future Statistic calls. The type of Statistic and the Collection Rate is set by Python runtime parameters. If no type is defined, then an Accumulator Statistic will be provided by default. If rate set to 0 or not provided, then the statistic will output results only at end of sim (if output is enabled).

Parameters
statNamePrimary name of the statistic. This name must match the defined ElementInfoStatistic in the component, and must also be enabled in the Python input file.
statSubIdAn additional sub name for the statistic
Returns
Either a created statistic of desired type or a NullStatistic depending upon runtime settings.
TimeConverter * SST::Component::registerTimeBase ( std::string  base,
bool  regAll = true 
)

Registers a default time base for the component and optionally sets the the component's links to that timebase.

Useful for components which do not have a clock, but would like a default timebase.

Parameters
baseFrequency for the clock in SI units
regAllShould this clock perioud be used as the default time base for all of the links connected to this component

References defaultTimeBase, SST::LinkMap::getLinkMap(), SST::TimeLord::getTimeConverter(), and SST::Simulation::getTimeLord().

Cycle_t SST::Component::reregisterClock ( TimeConverter freq,
Clock::HandlerBase handler 
)

Reactivates an existing Clock and Handler.

Returns
time of next time clock handler will fire

References SST::Simulation::reregisterClock().

Referenced by SST::SubComponent::reregisterClock().

virtual void SST::Component::setup ( )
inlinevirtual

Called after all components have been constructed and inialization has completed, but before simulation time has begun.

bool SST::Component::unregisterExit ( )

Indicate permission for the simulation to end.

This function is the mirror of Component::registerExit(). It decrements the global counter, which, upon reaching zero, indicates that the simulation can terminate.

See also
Component::registerExit()

References SST::Simulation::getExit(), getId(), SST::Simulation::getRank(), and SST::Exit::refDec().

Field Documentation

TimeConverter* SST::Component::defaultTimeBase
protected

Timebase used if no other timebase is specified for calls like Component::getCurrentSimTime().

Often set by Component::registerClock() function

Referenced by SST::IntrospectedComponent::getFreq(), registerClock(), and registerTimeBase().


The documentation for this class was generated from the following files: