The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::PhasedObject Class Referenceabstract

Object having a specific phase in the sparta construction paradigm. More...

#include <PhasedObject.hpp>

Inheritance diagram for sparta::PhasedObject:

Public Types

Types
enum  TreePhase {
  TREE_BUILDING = 0 , TREE_CONFIGURING = 1 , TREE_FINALIZING = 2 , TREE_FINALIZED = 3 ,
  TREE_TEARDOWN = 4
}
 Current phase of tree construction (applies to node and entire tree). More...
 

Public Member Functions

Construction
 PhasedObject (PhasedObject &&)=default
 
Identification Attributes
virtual const std::string & getName () const =0
 Gets the name of this node.
 
virtual std::string getLocation () const =0
 Returns the location of this node in device tree which can be used to navigate the device tree in methods such as getChild if this is fully attached to the device tree.
 

Phase Attributes

TreePhase getPhase () const
 Gets the trees current phase.
 
virtual bool isBuilding () const
 Is this node (and thus the entire tree above and below it) currently in the TREE_BUILDING phase.
 
virtual bool isBuilt () const
 Is this node (and thus the entire tree above it) "built". Checks that getPhase has passed TREE_BUILDING.
 
virtual bool isConfigured () const
 Is this node (and thus the entire tree above it) "configured". Checks that getPhase has passed TREE_CONFIGURING (i.e. FINALIZED, FINALIZING, TEARDOWN, etc).
 
virtual bool isConfiguring () const
 Is this node (and thus the entire tree above it) currently in the TREE_CONFIGURING phase.
 
virtual bool isFinalizing () const
 Is this node (and thus the entire tree above it) "finalized".
 
virtual bool isFinalized () const
 Is this node (and thus the entire tree above it) "finalized".
 
virtual bool isTearingDown () const
 Is this node (and thus the entire tree above it) in the "teardown" phase.
 
void setPhase_ (TreePhase phase)
 Sets the current phase.
 

Detailed Description

Object having a specific phase in the sparta construction paradigm.

See also
PhasedObject::TreePhase

Contains methods for querying and setting phase with some transition logic.

Definition at line 26 of file PhasedObject.hpp.

Member Enumeration Documentation

◆ TreePhase

Current phase of tree construction (applies to node and entire tree).

Note
Phases listed here must be in sequence so that the can be compared with > and < operators as well as ==.

Tree construction steps through these discrete phases, which restrict what operations can be done on the tree.

Enumerator
TREE_BUILDING 

Setting up tree hierarchy only (initial state)

TREE_CONFIGURING 

Setting parameters, ports, and other pre-instantiation attributes. Hierarchy cannot be modified.

TREE_FINALIZING 

Tree is being finalized, but has not completed (maybe errors?)

TREE_FINALIZED 

Tree and all resources have been instantiated. No more configuration/connection allowed.

TREE_TEARDOWN 

Simulation is complete. Tree and all resources are now allowed to be deleted (phase does not imply that deletion will occur)

Definition at line 43 of file PhasedObject.hpp.

Constructor & Destructor Documentation

◆ PhasedObject()

sparta::PhasedObject::PhasedObject ( )
inline

Definition at line 83 of file PhasedObject.hpp.

◆ ~PhasedObject()

virtual sparta::PhasedObject::~PhasedObject ( )
inlinevirtual

Definition at line 89 of file PhasedObject.hpp.

Member Function Documentation

◆ getLocation()

virtual std::string sparta::PhasedObject::getLocation ( ) const
pure virtual

Returns the location of this node in device tree which can be used to navigate the device tree in methods such as getChild if this is fully attached to the device tree.

Returns
dotted absolute location string to (and including) this node with some variations to indicate when the node is not yet part of a tree.
  • If this node does not have a parent (getParent), then the expected parent set through setExpectedParent_ will be used to compute the location string and the expected-parent relationship will be represented with a '.'.
  • If this node has no parent and no expected parent, then the returned location will be the name of this node preceeded by a '~' to indicate that the node is unattached.
Note
If a node in the location has no name, it will not be accessible using the string returned by this function and the getChild/findChildren methods.

The ',' is used to indicate expected, but unattached parents (set through setExpectedParent_) which happens during construction to avoid having to roll back any tree changes in the case of an exception while validating a node about to be attached to the tree.

If this node 'c' is attached to parent 'b':

* getLocation() => "top.a.b.c"
* 

If this node 'c' is expecting parent 'b' and 'b' is has expected parent 'a', which is already attached to parent 'top':

* getLocation() => "top.a,b,c"
* 

If this node 'c' has no parent, is not a RootTreeNode and has no expected parent:

* getLocation() => "~c"
* 

Implemented in sparta::TreeNode.

◆ getName()

virtual const std::string & sparta::PhasedObject::getName ( ) const
pure virtual

Gets the name of this node.

Returns
string name of this node

Implemented in sparta::TreeNode.

◆ getPhase()

TreePhase sparta::PhasedObject::getPhase ( ) const
inline

Gets the trees current phase.

Initially TREE_BUILDING

Definition at line 157 of file PhasedObject.hpp.

◆ isBuilding()

virtual bool sparta::PhasedObject::isBuilding ( ) const
inlinevirtual

Is this node (and thus the entire tree above and below it) currently in the TREE_BUILDING phase.

Returns
true if currently in the building phase

Building phase allows new ResourceTreeNodes to be added to the tree.

Definition at line 168 of file PhasedObject.hpp.

◆ isBuilt()

virtual bool sparta::PhasedObject::isBuilt ( ) const
inlinevirtual

Is this node (and thus the entire tree above it) "built". Checks that getPhase has passed TREE_BUILDING.

Returns
true if built.

Being built prevents new nodes from being attached to the tree.

Definition at line 179 of file PhasedObject.hpp.

◆ isConfigured()

virtual bool sparta::PhasedObject::isConfigured ( ) const
inlinevirtual

Is this node (and thus the entire tree above it) "configured". Checks that getPhase has passed TREE_CONFIGURING (i.e. FINALIZED, FINALIZING, TEARDOWN, etc).

Returns
true if built.

Being built prevents new nodes from being attached to the tree.

Definition at line 191 of file PhasedObject.hpp.

◆ isConfiguring()

virtual bool sparta::PhasedObject::isConfiguring ( ) const
inlinevirtual

Is this node (and thus the entire tree above it) currently in the TREE_CONFIGURING phase.

Returns
true if built.

Being built prevents new nodes from being attached to the tree.

Definition at line 202 of file PhasedObject.hpp.

◆ isFinalized()

virtual bool sparta::PhasedObject::isFinalized ( ) const
inlinevirtual

Is this node (and thus the entire tree above it) "finalized".

Returns
true if finalized.
Note
isFinalizing will not longer return true in this phase

Being in TREE_FINALIZE prevents the tree from finalizing again.

Reimplemented in sparta::Scheduler.

Definition at line 224 of file PhasedObject.hpp.

◆ isFinalizing()

virtual bool sparta::PhasedObject::isFinalizing ( ) const
inlinevirtual

Is this node (and thus the entire tree above it) "finalized".

Returns
true if finalized.

Being in TREE_FINALIZING prevents configuration but indicates that the tree has not yet successfully finalized.

Definition at line 213 of file PhasedObject.hpp.

◆ isTearingDown()

virtual bool sparta::PhasedObject::isTearingDown ( ) const
inlinevirtual

Is this node (and thus the entire tree above it) in the "teardown" phase.

Returns
true if tearing down.
Note
isFinalized will not longer return true in this phase

Being in TREE_TEARDOWN supresses the exceptions normally thrown by caused by deleting nodes.

This phase exists in order to help catch the class of errors where Nodes were allocated on the stack and deleted before the tree to which they were attached is still being used. Tearing down indicates that the tree should no longer be used.

Definition at line 242 of file PhasedObject.hpp.

◆ setPhase_()

void sparta::PhasedObject::setPhase_ ( TreePhase  phase)
inlineprotected

Sets the current phase.

Precondition
Currently has no preconditions, but phase ording may be enforced later
Todo:
Enforce phas ordering here

Definition at line 254 of file PhasedObject.hpp.


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