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::F2FJacobianGenerator(Class F2FJacobianGenerator)public Karana::Dynamics::MultiJacobianGenerator(Class MultiJacobianGenerator)public Karana::Dynamics::StatePropagator(Class StatePropagator)public Karana::Dynamics::SubTree(Class SubTree)public Karana::Frame::Frame2Frame(Class Frame2Frame)public Karana::Frame::FrameContainer(Class FrameContainer)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 current or stale. 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::F2FJacobianGenerator, Karana::Dynamics::MultiJacobianGenerator, Karana::Dynamics::StatePropagator, Karana::Dynamics::SubTree, Karana::Frame::Frame2Frame, Karana::Frame::FrameContainer, 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.
-
virtual const std::string &typeString() const noexcept override#
Returns the type string of LockingBase.
- Returns:
The type string.
-
LockingBase(const LockingBase&) = delete#
-
LockingBase &operator=(const LockingBase&) = delete#
-
LockingBase(LockingBase&&) = delete#
-
LockingBase &operator=(LockingBase&&) = delete#
-
inline bool isCurrent() const#
Check whether this is locked or unlocked.
- Returns:
True if this is locked, false otherwise.
-
void ensureCurrent()#
Make sure this object is current if it is not already so.
-
bool ensureStale()#
Make sure this object is in stale state if it is not already so.
- Returns:
bool If true, then everything went as intended. If false, then we are _within_ensureCurrent. This is used to signal that we need to call ensureCurrent and not be stale.
-
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 std::string dumpString(const std::string &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(const std::string &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::string &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 callensureStaleon this, we will call ensureStale on the dependent first. Similarly, to make thedependentcurrent, we must first make this current.- 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 stale.
-
void unfreeze()#
Unfreezes the cache to allow it to become stale.
-
bool isFrozen()#
Returns whether the cache is frozen or not.
- Returns:
trueif the cache is frozen,falseotherwise.
-
virtual void makeZombie()#
Makes the object a zombie. Once zombie, making it current will throw an error. Intended for use in classes like Frame or SubTree to detect invalid object usage.
Public Static Functions
Protected Functions
-
virtual void _makeCurrent()#
Derived classes override this to define how to make themselves current.
-
virtual void _makeStale()#
Derived classes override this to define how to mark themselves as stale.
-
void _dumpDependencyTree(const std::string &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>> &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 _current = true#
Indicates whether the object is current.
-
bool _within_ensureCurrent = false#
Flag indicating whether we are in ensureCurrent.
-
bool _within_ensureStale = false#
Flag indicating whether we are in ensureStale.
-
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 ensureCurrent/ensureStale.
-
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 ensureCurrent/ensureStale.
-
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.
-
inline dumpOptions &operator=(const dumpOptions &p)#
Assignment operator.
- Parameters:
p – Other dumpOptions to assign from.
- Returns:
Reference to this.
-
dumpOptions() = default#
-
LockingBase(std::string_view name)#