Description

Class to handle C++ values of generic type using type erasure and functors.

For example used to call the ArchiveOut function for unrelated classes that implemented them. This helps stripping out the templating, to make ChArchiveOut easier and equippable with virtual functions.

#include <ChArchive.h>

Inherited by chrono::ChValueSpecific< TClass >.

Public Member Functions

virtual ChValuenew_clone ()=0
 
virtual std::string & GetClassRegisteredName ()=0
 Get registered name in class factory. More...
 
virtual int GetClassRegisteredVersion ()=0
 Get class version, if class version is registered, otherwise defaults to 0.
 
virtual const char * GetTypeidName ()=0
 Get platform-dependent typeid name of referenced data.
 
virtual const std::type_index GetTypeid ()=0
 Get platform-dependent typeid of referenced data.
 
virtual bool IsNull ()=0
 Tell if it is a null pointer.
 
virtual bool IsPolymorphic ()=0
 Tell if the underlying original type is polymorphic.
 
virtual bool IsArray ()=0
 Tell if the underlying original type is an array.
 
virtual bool IsClass ()=0
 Tell if the underlying original type is a class.
 
virtual bool IsPointer ()=0
 Tell if the underlying original type is a pointer.
 
virtual void * GetRawPtr ()=0
 Access the data by a raw pointer, given as static_cast.
 
const char * name () const
 Get name of property.
 
char & flags ()
 Get flags of property.
 
const ChCausalityType & GetCausality () const
 Get causality attribute.
 
const ChVariabilityType & GetVariability () const
 Get variability attribute.
 
template<typename U >
U * PointerUpCast ()
 Use this to do safe dynamic cast. More...
 
virtual void CallArchiveOut (ChArchiveOut &archive_out)=0
 Use this to call ArchiveOut member function.
 
virtual void CallArchiveOutConstructor (ChArchiveOut &archive_out)=0
 Use this to call (optional) member function ArchiveOutConstructor. More...
 
virtual bool HasArchiveContainerName ()=0
 Tell if the object has the ArchiveContainerName() function; if so you might call CallArchiveContainerName.
 
virtual std::string & CallArchiveContainerName ()=0
 Use this to call ArchiveContainerName member function, if present.
 
virtual void CallOut (ChArchiveOut &archive_out)=0
 

Protected Member Functions

virtual void thrower () const =0
 

Protected Attributes

std::string _name
 
char _flags
 
ChCausalityType _causality
 
ChVariabilityType _variability
 

Member Function Documentation

◆ CallArchiveOutConstructor()

virtual void chrono::ChValue::CallArchiveOutConstructor ( ChArchiveOut archive_out)
pure virtual

Use this to call (optional) member function ArchiveOutConstructor.

This is expected to serialize constructor parameters if any. If ArchiveOutConstructor is not provided, simply does nothing.

◆ GetClassRegisteredName()

virtual std::string& chrono::ChValue::GetClassRegisteredName ( )
pure virtual

Get registered name in class factory.

If type is not previously registered, returns a "" string. This is platform-independent.

◆ PointerUpCast()

template<typename U >
U* chrono::ChValue::PointerUpCast ( )
inline

Use this to do safe dynamic cast.

This uses the cast/throw trick for dynamic cast after type-erasure; note that this has performance penalty respect to usual dynamic_cast<>, which is not possible here. Note: can only upcast, but no downcast (i.e. U must be higher the TClass used when instantiating ChValueSpecific); otherwise use a later dynamic_cast<>.


The documentation for this class was generated from the following file:
  • /builds/uwsbel/chrono/src/chrono/serialization/ChArchive.h