Class LockingBase#
Defined in File LockingBase.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Base Type#
public Karana::Core::Base(Class Base)
Derived Types#
public Karana::Core::DataCache< T >(Template Class DataCache)public Karana::Core::SideEffect(Class SideEffect)public Karana::Dynamics::BilateralConstraintBase(Class BilateralConstraintBase)public Karana::Dynamics::CompoundBody(Class CompoundBody)public Karana::Dynamics::CompoundHinge(Class CompoundHinge)public Karana::Dynamics::CompoundSubhinge(Class CompoundSubhinge)public Karana::Dynamics::ConstraintKinematicsSolver(Class ConstraintKinematicsSolver)public Karana::Dynamics::CoordData(Class CoordData)public Karana::Dynamics::FrameToFrameJacobianGenerator(Class FrameToFrameJacobianGenerator)public Karana::Dynamics::ModelManager(Class ModelManager)public Karana::Dynamics::MultiJacobianGenerator(Class MultiJacobianGenerator)public Karana::Dynamics::SubTree(Class SubTree)public Karana::Frame::Frame(Class Frame)public Karana::Frame::FrameContainer(Class FrameContainer)public Karana::Frame::FrameToFrame(Class FrameToFrame)public Karana::KUtils::PacketTableConfig(Class PacketTableConfig)public Karana::Math::NonlinearSolver(Class NonlinearSolver)public Karana::Models::BaseKModel(Class BaseKModel)
Class Documentation#
-
class LockingBase : public Karana::Core::Base#
Locking version of the Base class. This is the base class but with logic to make it healthy or not healthy. It also contains logic to add/remove dependents.
Subclassed by Karana::Core::DataCache< T >, Karana::Core::SideEffect, Karana::Dynamics::BilateralConstraintBase, Karana::Dynamics::CompoundBody, Karana::Dynamics::CompoundHinge, Karana::Dynamics::CompoundSubhinge, Karana::Dynamics::ConstraintKinematicsSolver, Karana::Dynamics::CoordData, Karana::Dynamics::FrameToFrameJacobianGenerator, Karana::Dynamics::ModelManager, Karana::Dynamics::MultiJacobianGenerator, Karana::Dynamics::SubTree, Karana::Frame::Frame, Karana::Frame::FrameContainer, Karana::Frame::FrameToFrame, Karana::KUtils::PacketTableConfig, Karana::Math::NonlinearSolver, Karana::Models::BaseKModel
Public Functions
-
LockingBase(std::string_view name)#
LockingBase class constructor.
- Parameters:
name – Name for the base class.
-
virtual ~LockingBase()#
Destructor.
-
LockingBase(const LockingBase&) = delete#
-
LockingBase &operator=(const LockingBase&) = delete#
-
LockingBase(LockingBase&&) = delete#
-
LockingBase &operator=(LockingBase&&) = delete#
-
inline bool isHealthy() const#
Check whether this is locked or unlocked.
- Returns:
True if this is locked, false otherwise.
-
void ensureHealthy()#
Make sure this object is healthy if it is not already so.
-
bool ensureNotHealthy()#
Make sure this object is in not healthy state if it is not already so.
- Returns:
bool If true, then everything went as intended. If false, then we are _within_ensureHealthy. This is used to signal that we need to call ensureHealthy and not be not healthy.
-
virtual std::string dumpString(std::string_view prefix = "", const Base::DumpOptions *options = nullptr) const override#
Return a formatted string containing information about this object.
- Parameters:
prefix – String prefix to use for formatting.
options – Dump options (if null, defaults will be used).
- Returns:
A string representation of the object.
-
void dumpDependencyTree(std::string_view prefix = "", int depth = -1, bool downstream = true) const#
Display the dependency tree for the object.
- Parameters:
prefix – Optional prefix to add to each line.
depth – Depth to traverse (default -1 means no limit).
downstream – Whether to show downstream (true) or upstream (false) dependencies.
-
void dumpDependencyGraphviz(const std::filesystem::path &filename, const std::vector<ks_ptr<LockingBase>> &terminal = {}, int downstream_depth = -1, int upstream_depth = -1) const#
Create a Graphviz dot file representing the dependency graph.
- Parameters:
filename – Output filename.
terminal – Nodes to be considered as terminal nodes (stop created graph on current branch if one of these is reached).
downstream_depth – Max depth for downstream traversal.
upstream_depth – Max depth for upstream traversal.
-
void addDependent(const ks_ptr<LockingBase> &dependent)#
Add
dependentas a dependent of this, which means whenever we callensureNotHealthyon this, we will call ensureNotHealthy on the dependent first. Similarly, to make thedependenthealthy, we must first make this healthy.- Parameters:
dependent – The LockingBase to add as a dependent.
-
void removeDependent(const ks_ptr<LockingBase> &dependent)#
Remove
dependentas a dependent of this. SeeaddDependentfor more information on what a dependent is.Remove
dependentas a dependent of this.- Parameters:
dependent – The LockingBase to remove as a dependent.
-
void clearDependencies()#
Remove all upstream and downstream dependencies for this object.
-
bool isDependent(const ks_ptr<LockingBase> &dependent) const#
Check if the given argument is a dependent of this.
- Parameters:
dependent – The LockingBase to check.
- Returns:
trueif dependent is a dependent of this.falseotherwise.
-
void freeze()#
Freezes the cache to prevent it from becoming not healthy.
-
void unfreeze()#
Unfreezes the cache to allow it to become not healthy.
-
bool isFrozen()#
Returns whether the cache is frozen or not.
- Returns:
trueif the cache is frozen,falseotherwise.
Public Static Functions
Protected Functions
-
ks_ptr<LockingBase> _getPtr()#
Get a shared_ptr to self, enabled by the std::enabled_shared_from_this pattern.
- Returns:
Shared pointer to this.
-
ks_ptr<const LockingBase> _getPtr() const#
Get a shared_ptr to self, enabled by the std::enabled_shared_from_this pattern.
- Returns:
Const shared pointer to this.
-
virtual void _makeHealthy()#
Derived classes override this to define how to make themselves healthy.
-
virtual void _makeNotHealthy()#
Derived classes override this to define how to mark themselves as not healthy.
-
void _dumpDependencyTree(std::string_view prefix, int depth, bool downstream, std::unordered_set<id_t> &visited) const#
Helper function to recursively dump the dependency tree.
- Parameters:
prefix – Prefix string for formatting.
depth – Max recursion depth.
downstream – Whether to show downstream (true) or upstream (false) dependencies.
visited – Set of node IDs already visited.
-
std::string _dumpDependencyGraphviz(int depth, bool downstream, std::unordered_set<std::pair<id_t, id_t>, IdHashStruct> &edges, const std::vector<id_t> &terminal = {}) const#
Helper to generate graphviz representation of dependency graph.
- Parameters:
depth – Max depth of traversal.
downstream – Whether to include downstream (true) or upstream (false) dependencies.
edges – Set of edge pairs to fill.
terminal – Nodes to be considered as terminal nodes (stop created graph on current branch if one of these is reached).
- Returns:
String containing Graphviz dot representation.
Protected Attributes
-
bool _healthy = true#
Indicates whether the object is healthy.
-
bool _within_ensureHealthy = false#
Flag indicating whether we are in ensureHealthy.
-
bool _within_ensureNotHealthy = false#
Flag indicating whether we are in ensureNotHealthy.
-
RegistryList<LockingBase> _upstream_deps#
List of upstream dependencies.
-
std::vector<LockingBase*> _upstream_deps_cp#
Used to copy _upstream_deps when we loop through dependencies in ensureHealthy/ensureNotHealthy.
-
RegistryList<LockingBase> _downstream_deps#
List of downstream dependents.
-
std::vector<LockingBase*> _downstream_deps_cp#
Used to copy _downstream_deps when we loop through dependencies in ensureHealthy/ensureNotHealthy.
-
RegistryList<LockingBase> _request_remove#
List of objects that have requested removal as a dependent.
-
RegistryList<LockingBase> _request_add#
List of objects that have requested to be added as a dependent.
-
bool _frozen = false#
Flag indicating whether the object is frozen.
-
bool _upstream_deps_changed = true#
Flag to indicate when the upstream deps have changed.
Used to decide if we need to re-create the _upstream_deps_cp.
-
bool _downstream_deps_changed = true#
Flag to indicate when the upstream deps have changed.
Used to decide if we need to re-create the _upstream_deps_cp.
Protected Static Attributes
-
static std::string _trace_indent#
Indentation used for tracing output.
-
struct DumpOptions : public Karana::Core::Base::DumpOptions#
Options for dumping LockingBase information.
Subclassed by Karana::Dynamics::CompoundBody::DumpOptions
Public Functions
-
DumpOptions() = default#
Default constructor.
-
DumpOptions &operator=(const DumpOptions &p)#
Assignment operator.
- Parameters:
p – Other DumpOptions to assign from.
- Returns:
Reference to this.
-
virtual ~DumpOptions()#
Destructor.
-
DumpOptions() = default#
-
LockingBase(std::string_view name)#