26 #ifndef CASADI_GENERIC_TYPE_INTERNAL_HPP
27 #define CASADI_GENERIC_TYPE_INTERNAL_HPP
29 #include "generic_type.hpp"
30 #include "casadi_misc.hpp"
31 #include "serializing_stream.hpp"
32 #include "shared_object_internal.hpp"
38 class CASADI_EXPORT GenericTypeBase :
public SharedObjectInternal {
40 virtual ~GenericTypeBase() {}
41 virtual TypeID getType()
const = 0;
42 virtual void serialize(SerializingStream& s)
const = 0;
45 template<TypeID ID,
typename T>
46 class CASADI_EXPORT GenericTypeInternal :
public GenericTypeBase {
48 explicit GenericTypeInternal(
const T& d) : d_(d) {}
49 ~GenericTypeInternal()
override {}
50 std::string class_name()
const override {
return "GenericTypeInternal";}
51 void disp(std::ostream& stream,
bool more)
const override { stream << d_; }
52 TypeID getType()
const override {
return ID;}
54 void serialize(SerializingStream& s)
const override {
55 s.pack(
"GenericType::d", d_);
57 static GenericType deserialize(DeserializingStream& s) {
59 s.unpack(
"GenericType::d", d);
60 return GenericType(d);