26 #ifndef CASADI_SHARED_OBJECT_HPP
27 #define CASADI_SHARED_OBJECT_HPP
29 #include "casadi_common.hpp"
30 #include "exception.hpp"
41 class SharedObjectInternal;
42 class WeakRefInternal;
87 template<
class B>
friend const B shared_cast(
const SharedObject& A);
106 void own(SharedObjectInternal* node);
113 void assign(SharedObjectInternal* node);
116 SharedObjectInternal* get()
const;
119 casadi_int getCount()
const;
125 SharedObjectInternal* operator->()
const;
135 void disp(std::ostream& stream,
bool more=
false)
const;
139 std::stringstream ss;
146 void print_ptr(std::ostream &stream=
casadi::uout())
const;
169 SharedObjectInternal *node;
183 friend class SharedObjectInternal;
220 explicit WeakRef(SharedObjectInternal* raw);
240 SharedObjectInternal* ptr = A.get();
246 if (!B::test_cast(ptr))
return ret;
259 const B shared_cast(
const SharedObject& A) {
260 SharedObject A_copy = A;
261 return shared_cast<B>(A_copy);
SharedObject implements a reference counting framework similar for efficient and.
std::string class_name() const
Get class name.
casadi_int __hash__() const
Returns a number that is unique for a given Node.
void disp(std::ostream &stream, bool more=false) const
Print a description of the object.
bool is_null() const
Is a null pointer?
std::string get_str(bool more=false) const
Get string representation.
SharedObject shared()
Get a shared (owning) reference.
WeakRef(int dummy=0)
Default constructor.
const WeakRefInternal * operator->() const
Const access functions of the node.
WeakRef(SharedObject shared)
Construct from a shared object (also implicit type conversion)
WeakRefInternal * operator->()
Access functions of the node.
bool alive() const
Check if alive.
CASADI_EXPORT std::ostream & uout()