26 #ifndef CASADI_SHARED_OBJECT_HPP
27 #define CASADI_SHARED_OBJECT_HPP
29 #include "generic_shared_internal.hpp"
35 class SharedObjectInternal;
36 class WeakRefInternal;
88 void disp(std::ostream& stream,
bool more=
false)
const;
91 std::string
get_str(
bool more=
false)
const {
99 void print_ptr(std::ostream &stream=
casadi::uout())
const;
127 class CASADI_EXPORT SharedObjectInternal :
128 public GenericSharedInternal<SharedObject, SharedObjectInternal> {
129 friend class GenericShared<SharedObject, SharedObjectInternal>;
130 friend class SharedObject;
131 friend class GenericWeakRef<SharedObject, SharedObjectInternal>;
132 friend class GenericSharedInternal<SharedObject, SharedObjectInternal>;
134 friend class UniversalNodeOwner;
139 SharedObjectInternal() : GenericSharedInternal<SharedObject, SharedObjectInternal>() {
142 SharedObjectInternal(
const SharedObjectInternal& node) :
143 GenericSharedInternal<SharedObject, SharedObjectInternal>(node) {
147 virtual std::string class_name()
const = 0;
150 virtual void disp(std::ostream& stream,
bool more)
const = 0;
152 using weak_ref_type = WeakRefInternal;
156 #ifdef CASADI_WITH_THREAD
157 std::atomic<casadi_int> count;
164 class CASADI_EXPORT WeakRefInternal :
165 public GenericWeakRefInternal<SharedObject, SharedObjectInternal> {
168 void disp(std::ostream& stream,
bool more)
const override;
171 std::string class_name()
const override {
return "WeakRefInternal";}
173 using GenericWeakRefInternal<SharedObject, SharedObjectInternal>::GenericWeakRefInternal;
GenericShared implements a reference counting framework similar for efficient and.
std::string class_name() const
Get class name.
void disp(std::ostream &stream, bool more=false) const
Print a description of the object.
std::string get_str(bool more=false) const
Get string representation.
SharedObjectInternal internal_base_type
WeakRef(SharedObject shared)
CASADI_EXPORT std::ostream & uout()