List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions
casadi::GenericTypeInternal< ID, T > Class Template Reference

#include <generic_type_internal.hpp>

Detailed Description

template<TypeID ID, typename T>
class casadi::GenericTypeInternal< ID, T >

Definition at line 46 of file generic_type_internal.hpp.

Inheritance diagram for casadi::GenericTypeInternal< ID, T >:
Inheritance graph
[legend]
Collaboration diagram for casadi::GenericTypeInternal< ID, T >:
Collaboration graph
[legend]

Public Types

using weak_ref_type = WeakRefInternal
 

Public Member Functions

 GenericTypeInternal (const T &d)
 
 ~GenericTypeInternal () override
 
std::string class_name () const override
 Readable name of the internal class. More...
 
void disp (std::ostream &stream, bool more) const override
 Print a description of the object. More...
 
TypeID getType () const override
 
void serialize (SerializingStream &s) const override
 
casadi_int getCount () const
 Get the reference count. More...
 
std::string debug_repr (const SharedObjectInternal *) const
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 

Static Public Member Functions

static GenericType deserialize (DeserializingStream &s)
 

Public Attributes

d_
 

Protected Member Functions

void initSingleton ()
 
void destroySingleton ()
 
shared_from_this ()
 Get a shared object from the current internal object. More...
 
const B shared_from_this () const
 Get a shared object from the current internal object. More...
 

Member Typedef Documentation

◆ weak_ref_type

Definition at line 152 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ GenericTypeInternal()

template<TypeID ID, typename T >
casadi::GenericTypeInternal< ID, T >::GenericTypeInternal ( const T &  d)
inlineexplicit

Definition at line 48 of file generic_type_internal.hpp.

◆ ~GenericTypeInternal()

template<TypeID ID, typename T >
casadi::GenericTypeInternal< ID, T >::~GenericTypeInternal ( )
inlineoverride

Definition at line 49 of file generic_type_internal.hpp.

49 {}

Member Function Documentation

◆ class_name()

template<TypeID ID, typename T >
std::string casadi::GenericTypeInternal< ID, T >::class_name ( ) const
inlineoverridevirtual

Implements casadi::SharedObjectInternal.

Definition at line 50 of file generic_type_internal.hpp.

50 {return "GenericTypeInternal";}

◆ debug_repr()

std::string casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::debug_repr ( const Internal *  i) const
inherited

Definition at line 62 of file generic_shared_internal.hpp.

162  {
163  // Note: i != this because of something something multiple inheritance
164  return str( (casadi_int)(i)) + "/" + static_cast<const Internal*>(this)->class_name();
165  }
std::string str(const T &v)
String representation, any type.

◆ deserialize()

template<TypeID ID, typename T >
static GenericType casadi::GenericTypeInternal< ID, T >::deserialize ( DeserializingStream s)
inlinestatic

Definition at line 57 of file generic_type_internal.hpp.

57  {
58  T d;
59  s.unpack("GenericType::d", d);
60  return GenericType(d);
61  }

References casadi::T, and casadi::DeserializingStream::unpack().

Referenced by casadi::GenericType::deserialize().

◆ destroySingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::destroySingleton ( )
inlineprotectedinherited

Called in the destructor of singletons

Definition at line 77 of file generic_shared_internal.hpp.

77  {
78  static_cast<Internal*>(this)->count--;
79  }

◆ disp()

template<TypeID ID, typename T >
void casadi::GenericTypeInternal< ID, T >::disp ( std::ostream &  stream,
bool  more 
) const
inlineoverridevirtual

Implements casadi::SharedObjectInternal.

Definition at line 51 of file generic_type_internal.hpp.

51 { stream << d_; }

◆ getCount()

Definition at line 60 of file generic_shared_internal.hpp.

186  {
187  return static_cast<const Internal*>(this)->count;
188  }

◆ getType()

template<TypeID ID, typename T >
TypeID casadi::GenericTypeInternal< ID, T >::getType ( ) const
inlineoverridevirtual

Implements casadi::GenericTypeBase.

Definition at line 52 of file generic_type_internal.hpp.

52 { return ID;}

◆ initSingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::initSingleton ( )
inlineprotectedinherited

Called in the constructor of singletons to avoid that the counter reaches zero

Definition at line 71 of file generic_shared_internal.hpp.

71  {
72  casadi_assert_dev(static_cast<Internal*>(this)->count==0);
73  static_cast<Internal*>(this)->count++;
74  }

◆ serialize()

template<TypeID ID, typename T >
void casadi::GenericTypeInternal< ID, T >::serialize ( SerializingStream s) const
inlineoverridevirtual

Implements casadi::GenericTypeBase.

Definition at line 54 of file generic_type_internal.hpp.

54  {
55  s.pack("GenericType::d", d_);
56  }

References casadi::SerializingStream::pack().

◆ shared_from_this() [1/2]

B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( )
inlineprotectedinherited

Definition at line 83 of file generic_shared_internal.hpp.

83  {
84  casadi_assert_dev(B::test_cast(static_cast<Internal*>(this)));
85  B ret;
86  ret.own(static_cast<Internal*>(this));
87  return ret;
88  }

◆ shared_from_this() [2/2]

const B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( ) const
inlineprotectedinherited

Definition at line 92 of file generic_shared_internal.hpp.

92  {
93  casadi_assert_dev(B::test_cast(static_cast<const Internal*>(this)));
94  B ret;
95  ret.own(const_cast<Internal*>(static_cast<const Internal*>(this)));
96  return ret;
97  }

◆ weak()

Extra doc: https://github.com/casadi/casadi/wiki/L_1ai

Definition at line 67 of file generic_shared_internal.hpp.

191  {
192  if (weak_ref_==nullptr) {
193  weak_ref_ = new GenericWeakRef<Shared, Internal>(static_cast<Internal*>(this));
194  }
195  return weak_ref_;
196  }

Member Data Documentation

◆ d_

template<TypeID ID, typename T >
T casadi::GenericTypeInternal< ID, T >::d_

Definition at line 53 of file generic_type_internal.hpp.


The documentation for this class was generated from the following file: