The Sparta Modeling Framework
Loading...
Searching...
No Matches
PhasedObject.hpp
Go to the documentation of this file.
1// <PhasedObject> -*- C++ -*-
2
8#pragma once
9
10#include "sparta/utils/Utils.hpp"
14#include "sparta/utils/StringManager.hpp"
15
16namespace sparta
17{
18
27 {
28 public:
29
33
74
77
81
82
83 PhasedObject() :
84 phase_(TREE_BUILDING)
85 { }
86
87 PhasedObject(PhasedObject&&) = default;
88
89 virtual ~PhasedObject()
90 { }
91
94
98
103 virtual const std::string& getName() const = 0;
104
146 virtual std::string getLocation() const = 0;
147
151
158 return phase_;
159 }
160
168 virtual bool isBuilding() const {
169 return phase_ == TREE_BUILDING;
170 }
171
179 virtual bool isBuilt() const {
180 return phase_ > TREE_BUILDING;
181 }
182
191 virtual bool isConfigured() const {
192 return phase_ > TREE_CONFIGURING;
193 }
194
202 virtual bool isConfiguring() const {
203 return phase_ == TREE_CONFIGURING;
204 }
205
213 virtual bool isFinalizing() const {
214 return phase_ == TREE_FINALIZING;
215 }
216
224 virtual bool isFinalized() const {
225 return phase_ == TREE_FINALIZED;
226 }
227
242 virtual bool isTearingDown() const {
243 return phase_ == TREE_TEARDOWN;
244 }
245
246 protected:
247
254 void setPhase_(TreePhase phase) {
255 phase_ = phase;
256 }
257
258 private:
259
263 TreePhase phase_;
264 };
265
266} // namespace sparta
267
Helpers for printing and populating vectors.
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Object having a specific phase in the sparta construction paradigm.
virtual bool isBuilding() const
Is this node (and thus the entire tree above and below it) currently in the TREE_BUILDING phase.
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 met...
void setPhase_(TreePhase phase)
Sets the current phase.
virtual const std::string & getName() const =0
Gets the name of this node.
virtual bool isFinalizing() const
Is this node (and thus the entire tree above it) "finalized".
virtual bool isConfigured() const
Is this node (and thus the entire tree above it) "configured". Checks that getPhase has passed TREE_C...
virtual bool isTearingDown() const
Is this node (and thus the entire tree above it) in the "teardown" phase.
virtual bool isBuilt() const
Is this node (and thus the entire tree above it) "built". Checks that getPhase has passed TREE_BUILDI...
virtual bool isFinalized() const
Is this node (and thus the entire tree above it) "finalized".
TreePhase getPhase() const
Gets the trees current phase.
virtual bool isConfiguring() const
Is this node (and thus the entire tree above it) currently in the TREE_CONFIGURING phase.
TreePhase
Current phase of tree construction (applies to node and entire tree).
@ TREE_FINALIZING
Tree is being finalized, but has not completed (maybe errors?)
@ TREE_CONFIGURING
Setting parameters, ports, and other pre-instantiation attributes. Hierarchy cannot be modified.
@ TREE_TEARDOWN
Simulation is complete. Tree and all resources are now allowed to be deleted (phase does not imply th...
@ TREE_BUILDING
Setting up tree hierarchy only (initial state)
@ TREE_FINALIZED
Tree and all resources have been instantiated. No more configuration/connection allowed.
Macros for handling exponential backoff.