List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
casadi::ResourceInternal Class Referenceabstract

RAII class base for reading from resources. More...

#include <resource_internal.hpp>

Detailed Description

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

Definition at line 40 of file resource_internal.hpp.

Inheritance diagram for casadi::ResourceInternal:
Inheritance graph
[legend]
Collaboration diagram for casadi::ResourceInternal:
Collaboration graph
[legend]

Public Types

using weak_ref_type = WeakRefInternal
 

Public Member Functions

 ResourceInternal ()
 Initialize with a path. More...
 
virtual const std::string & path () const =0
 Get path for a consumer. More...
 
void serialize (SerializingStream &s) const
 
virtual void serialize_type (SerializingStream &s) const
 
virtual void serialize_body (SerializingStream &s) const
 
void change_option (const std::string &option_name, const GenericType &option_value)
 
virtual std::string class_name () const =0
 Readable name of the internal class. More...
 
virtual void disp (std::ostream &stream, bool more) const =0
 Print a description of the object. More...
 
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 ResourceInternaldeserialize (DeserializingStream &s)
 

Protected Member Functions

 ResourceInternal (DeserializingStream &s)
 
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...
 

Protected Attributes

std::string serialize_mode_
 

Member Typedef Documentation

◆ weak_ref_type

Definition at line 152 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ ResourceInternal() [1/2]

casadi::ResourceInternal::ResourceInternal ( )
explicit

If the path is a directory or empty, the path is passed through to the consumer. Otherwise, the zip file is extracted to a temporary directory.

Upon destruction, the temporary directory is removed.

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

Definition at line 36 of file resource_internal.cpp.

36  {
37  serialize_mode_ = "link";
38 }

References serialize_mode_.

◆ ResourceInternal() [2/2]

casadi::ResourceInternal::ResourceInternal ( DeserializingStream s)
explicitprotected

Definition at line 159 of file resource_internal.cpp.

159  {
160  s.unpack("ResourceInternal::serialize_mode", serialize_mode_);
161  serialize_mode_ = "link";
162 }

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

Member Function Documentation

◆ change_option()

void casadi::ResourceInternal::change_option ( const std::string &  option_name,
const GenericType option_value 
)

Definition at line 53 of file resource_internal.cpp.

54  {
55  if (option_name=="serialize_mode") {
56  serialize_mode_ = option_value.to_string();
57  casadi_assert(serialize_mode_=="embed" || serialize_mode_=="link",
58  "Invalid serialization mode: " + serialize_mode_ + ". Pick 'link' or 'embed'.");
59  } else {
60  casadi_error("Option '" + option_name + "' does not exist");
61  }
62 }

References serialize_mode_, and casadi::GenericType::to_string().

◆ class_name()

virtual std::string casadi::SharedObjectInternal::class_name ( ) const
pure virtualinherited

Implemented in casadi::SymbolicQr, casadi::Sqpmethod, casadi::ShellCompiler, casadi::Scpgen, casadi::RungeKutta, casadi::Qrsqp, casadi::Qrqp, casadi::QpToNlp, casadi::Newton, casadi::Lsqr, casadi::LinsolTridiag, casadi::LinsolQr, casadi::LinsolLdl, casadi::LinearInterpolantJac, casadi::LinearInterpolant, casadi::Ipqp, casadi::ImplicitToNlp, casadi::Feasiblesqpmethod, casadi::FastNewton, casadi::Collocation, casadi::BSplineInterpolant, casadi::WorhpInterface, casadi::TinyXmlInterface, casadi::SuperscsInterface, casadi::KinsolInterface, casadi::IdasInterface, casadi::CvodesInterface, casadi::SqicInterface, casadi::SnoptInterface, casadi::SlicotExpm, casadi::SlicotDple, casadi::SLEQPInterface, casadi::QpoasesInterface, casadi::ProxqpInterface, casadi::OsqpInterface, casadi::OoqpInterface, casadi::MumpsInterface, casadi::MadnlpInterface, casadi::LapackQr, casadi::LapackLu, casadi::KnitroInterface, casadi::IpoptInterface, casadi::Ma27Interface, casadi::HpmpcInterface, casadi::HpipmInterface, casadi::HighsInterface, casadi::GurobiInterface, casadi::FatropInterface, casadi::FatropConicInterface, casadi::DaqpInterface, casadi::CsparseInterface, casadi::CSparseCholeskyInterface, casadi::CplexInterface, casadi::ClpInterface, casadi::ClarabelInterface, casadi::ClangCompiler, casadi::CbcInterface, casadi::BonminInterface, casadi::Blocksqp, casadi::AmplInterface, casadi::AlpaqaInterface, casadi::SXFunction, casadi::Switch, casadi::SparsityInternal, casadi::WeakRefInternal, casadi::ZipMemResource, casadi::ZipResource, casadi::DirResource, casadi::OptiNode, casadi::Nlpsol, casadi::MXNode, casadi::MXFunction, casadi::MapSum, casadi::ThreadMap, casadi::OmpMap, casadi::Map, casadi::JitFunction, casadi::Interpolant, casadi::DllLibrary, casadi::ImporterInternal, casadi::GenericTypeInternal< ID, T >, casadi::FmuFunction, casadi::Fmu3, casadi::Fmu2, casadi::Smoothing, casadi::CentralDiff, casadi::BackwardDiff, casadi::ForwardDiff, casadi::External, casadi::DaeBuilderInternal, casadi::CallbackInternal, and casadi::BlazingSplineFunction.

Referenced by casadi::FunctionInternal::call_forward(), casadi::FunctionInternal::call_reverse(), casadi::FunctionInternal::codegen_body(), casadi::ProtoFunction::construct(), casadi::FmuInternal::deserialize(), deserialize(), casadi::FmuInternal::disp(), casadi::FunctionInternal::disp(), casadi::LinsolInternal::disp(), casadi::XmlFileInternal::dump(), casadi::FunctionInternal::eval(), casadi::FunctionInternal::eval_dm(), casadi::FunctionInternal::eval_sx(), casadi::FunctionInternal::export_code(), casadi::LinsolInternal::generate(), casadi::FunctionInternal::generate_dependencies(), casadi::Conic::generateNativeCode(), casadi::FmuInternal::get_adjoint_derivative(), casadi::FunctionInternal::get_forward(), casadi::FunctionInternal::get_function(), casadi::FunctionInternal::get_jacobian(), casadi::FunctionInternal::get_reverse(), casadi::FiniteDiff::init(), casadi::FunctionInternal::instruction_constant(), casadi::FunctionInternal::instruction_id(), casadi::FunctionInternal::instruction_input(), casadi::FunctionInternal::instruction_MX(), casadi::FunctionInternal::instruction_output(), casadi::FunctionInternal::instructions_sx(), casadi::LinsolInternal::linsol_eval_sx(), casadi::FunctionInternal::n_instructions(), casadi::FunctionInternal::n_nodes(), casadi::LinsolInternal::neig(), casadi::LinsolInternal::nfact(), casadi::FunctionInternal::oracle(), casadi::XmlFileInternal::parse(), casadi::LinsolInternal::rank(), casadi::FmuInternal::serialize_type(), serialize_type(), and casadi::LinsolInternal::solve().

◆ 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()

ResourceInternal * casadi::ResourceInternal::deserialize ( DeserializingStream s)
static

Definition at line 164 of file resource_internal.cpp.

164  {
165  s.version("ResourceInternal", 1);
166  std::string class_name;
167  s.unpack("ResourceInternal::type", class_name);
168  if (class_name=="DirResource") {
169  return DirResource::deserialize(s);
170  } else if (class_name=="ZipResource") {
171  return ZipResource::deserialize(s);
172  } else if (class_name=="ZipMemResource") {
173  return ZipMemResource::deserialize(s);
174  } else {
175  casadi_error("Cannot deserialize type '" + class_name + "'");
176  }
177 }
static ResourceInternal * deserialize(DeserializingStream &s)
virtual std::string class_name() const =0
Readable name of the internal class.
static ResourceInternal * deserialize(DeserializingStream &s)
static ResourceInternal * deserialize(DeserializingStream &s)

References casadi::SharedObjectInternal::class_name(), casadi::DirResource::deserialize(), casadi::ZipResource::deserialize(), casadi::ZipMemResource::deserialize(), casadi::DeserializingStream::unpack(), and casadi::DeserializingStream::version().

Referenced by casadi::Resource::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()

virtual void casadi::SharedObjectInternal::disp ( std::ostream &  stream,
bool  more 
) const
pure virtualinherited

◆ getCount()

Definition at line 60 of file generic_shared_internal.hpp.

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

◆ 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  }

◆ path()

virtual const std::string& casadi::ResourceInternal::path ( ) const
pure virtual

◆ serialize()

void casadi::ResourceInternal::serialize ( SerializingStream s) const

Definition at line 145 of file resource_internal.cpp.

145  {
146  s.version("ResourceInternal", 1);
147  serialize_type(s);
148  serialize_body(s);
149 }
virtual void serialize_body(SerializingStream &s) const
virtual void serialize_type(SerializingStream &s) const

References serialize_body(), serialize_type(), and casadi::SerializingStream::version().

◆ serialize_body()

void casadi::ResourceInternal::serialize_body ( SerializingStream s) const
virtual

◆ serialize_type()

void casadi::ResourceInternal::serialize_type ( SerializingStream s) const
virtual

Reimplemented in casadi::ZipResource, and casadi::DirResource.

Definition at line 151 of file resource_internal.cpp.

151  {
152  s.pack("ResourceInternal::type", class_name());
153 }

References casadi::SharedObjectInternal::class_name(), and casadi::SerializingStream::pack().

Referenced by serialize().

◆ 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

◆ serialize_mode_

std::string casadi::ResourceInternal::serialize_mode_
protected

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