Inviwo  0.9.10.1
Inviwo documentation
inviwo::Deserializer Class Reference
+ Inheritance diagram for inviwo::Deserializer:

Public Member Functions

 Deserializer (std::string fileName, bool allowReference=true)
 Deserializer constructor. More...
 
 Deserializer (std::istream &stream, const std::string &refPath, bool allowReference=true)
 Deserializes content from the stream using refPath to calculate relative paths to data. More...
 
 Deserializer (const Deserializer &)=delete
 
 Deserializer (Deserializer &&)=default
 
Deserializeroperator= (const Deserializer &that)=delete
 
Deserializeroperator= (Deserializer &&that)=default
 
template<typename T >
void deserialize (const std::string &key, std::vector< T * > &sVector, const std::string &itemKey="item")
 Deserialize a vector. More...
 
template<typename T , typename C >
void deserialize (const std::string &key, std::vector< T * > &sVector, const std::string &itemKey, C identifier)
 
template<typename T >
void deserialize (const std::string &key, std::vector< T > &sVector, const std::string &itemKey="item")
 
template<typename T >
void deserialize (const std::string &key, std::unordered_set< T > &sSet, const std::string &itemKey="item")
 
template<typename T >
void deserialize (const std::string &key, std::vector< std::unique_ptr< T >> &vector, const std::string &itemKey="item")
 
template<typename T >
void deserialize (const std::string &key, std::list< T > &sContainer, const std::string &itemKey="item")
 
template<typename K , typename V , typename C , typename A >
void deserialize (const std::string &key, std::map< K, V, C, A > &sMap, const std::string &itemKey="item", const std::string &comparisionAttribute=SerializeConstants::KeyAttribute)
 Deserialize a map. More...
 
template<typename K , typename V , typename C , typename A >
void deserialize (const std::string &key, std::map< K, V *, C, A > &sMap, const std::string &itemKey="item", const std::string &comparisionAttribute=SerializeConstants::KeyAttribute)
 
template<typename K , typename V , typename C , typename A >
void deserialize (const std::string &key, std::map< K, std::unique_ptr< V >, C, A > &sMap, const std::string &itemKey="item", const std::string &comparisionAttribute=SerializeConstants::KeyAttribute)
 
template<typename T , typename K >
void deserialize (const std::string &key, ContainerWrapper< T, K > &container)
 
void deserialize (const std::string &key, signed char &data, const SerializationTarget &target=SerializationTarget::Node)
 
void deserialize (const std::string &key, char &data, const SerializationTarget &target=SerializationTarget::Node)
 
void deserialize (const std::string &key, unsigned char &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename T , typename std::enable_if< std::is_integral< T >::value||util::is_floating_point< T >::value||util::is_string< T >::value, int >::type = 0>
void deserialize (const std::string &key, T &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0>
void deserialize (const std::string &key, T &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename T >
void deserialize (const std::string &key, flags::flags< T > &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename Vec , typename std::enable_if< util::rank< Vec >::value==1, int >::type = 0>
void deserialize (const std::string &key, Vec &data)
 
template<typename Mat , typename std::enable_if< util::rank< Mat >::value==2, int >::type = 0>
void deserialize (const std::string &key, Mat &data)
 
template<unsigned N>
void deserialize (const std::string &key, std::bitset< N > &bits)
 
void deserialize (const std::string &key, Serializable &sObj)
 Deserialize any Serializable object.
 
template<class T >
void deserialize (const std::string &key, T *&data)
 Deserialize pointer data of type T, which is of type serializable object or primitive data.
 
template<class Base , class T >
void deserializeAs (const std::string &key, T *&data)
 
template<class T , class D >
void deserialize (const std::string &key, std::unique_ptr< T, D > &data)
 
template<class Base , class T , class D >
void deserializeAs (const std::string &key, std::unique_ptr< T, D > &data)
 
void setExceptionHandler (ExceptionHandler handler)
 
void handleError (const ExceptionContext &context)
 
void convertVersion (VersionConverter *converter)
 
template<typename T >
T * getRegisteredType (const std::string &className)
 For allocating objects such as processors, properties.. using registered factories. More...
 
template<typename T >
T * getNonRegisteredType ()
 For allocating objects that do not belong to any registered factories. More...
 
void registerFactory (FactoryBase *factory)
 
int getInviwoWorkspaceVersion () const
 
- Public Member Functions inherited from inviwo::SerializeBase
 SerializeBase (bool allowReference=true)
 Base class for Serializer and Deserializer. More...
 
 SerializeBase (std::string fileName, bool allowReference=true)
 Base class for Serializer and Deserializer. More...
 
 SerializeBase (std::istream &stream, const std::string &path, bool allowReference=true)
 Base class for Serializer and Deserializer. More...
 
 SerializeBase (const SerializeBase &rhs)=delete
 
 SerializeBase (SerializeBase &&rhs)=default
 
SerializeBaseoperator= (const SerializeBase &)=delete
 
SerializeBaseoperator= (SerializeBase &&)=default
 
virtual const std::string & getFileName () const
 gets the xml file name.
 
bool isPrimitiveType (const std::type_info &type) const
 Checks whether the given type is a primitive type. More...
 
- Public Member Functions inherited from inviwo::LogFilter
 LogFilter (Logger *logger=LogCentral::getPtr())
 
 LogFilter (Logger *logger, LogVerbosity verbosity)
 
void setVerbosity (LogVerbosity verbosity)
 
LogVerbosity getVerbosity ()
 
void setLogger (Logger *logger)
 
LoggergetLogger () const
 
virtual void log (std::string logSource, LogLevel level, LogAudience audience, const char *file, const char *function, int line, std::string msg) override
 
virtual void logProcessor (Processor *processor, LogLevel level, LogAudience audience, std::string msg, const char *file, const char *function, int line) override
 
virtual void logNetwork (LogLevel level, LogAudience audience, std::string msg, const char *file, const char *function, int line) override
 
- Public Member Functions inherited from inviwo::Logger
virtual void logAssertion (const char *file, const char *function, int line, std::string msg)
 

Friends

class NodeSwitch
 
template<typename T , typename K >
class ContainerWrapper
 

Additional Inherited Members

- Public Types inherited from inviwo::SerializeBase
using RefDataPair = std::pair< const void *, SerializeBase::ReferenceData >
 
using RefMap = std::multimap< const void *, ReferenceData >
 
- Static Public Member Functions inherited from inviwo::SerializeBase
static std::string nodeToString (const TxElement &node)
 
- Protected Attributes inherited from inviwo::SerializeBase
std::string fileName_
 
TxDocument doc_
 
TxElement * rootElement_
 
bool allowRef_
 
bool retrieveChild_
 
ReferenceDataContainer refDataContainer_
 

Constructor & Destructor Documentation

◆ Deserializer() [1/2]

inviwo::Deserializer::Deserializer ( std::string  fileName,
bool  allowReference = true 
)

Deserializer constructor.

Parameters
fileNamepath to file that is to be deserialized.
allowReferenceflag to manage references to avoid multiple object creation.

◆ Deserializer() [2/2]

inviwo::Deserializer::Deserializer ( std::istream &  stream,
const std::string &  refPath,
bool  allowReference = true 
)

Deserializes content from the stream using refPath to calculate relative paths to data.

Parameters
streamStream with content that is to be deserialized.
refPathA path that will be used to decode the location of data during deserialization.
allowReferenceflag to manage references to avoid multiple object creation.

Member Function Documentation

◆ deserialize() [1/2]

template<typename T >
void inviwo::Deserializer::deserialize ( const std::string &  key,
std::vector< T * > &  sVector,
const std::string &  itemKey = "item" 
)

Deserialize a vector.

Deserialize the vector that has pre-allocated objects of type T or allocated by deserializer. A vector is identified by key and vector items are identified by itemKey

eg. xml tree with key=Properties and itemKey=Property

<Properties>
     <Property identifier="enableMIP" displayName="MIP">
         <value content="0" />
     </Property>
     <Property identifier="enableShading" displayName="Shading">
         <value content="0" />
     </Property>
<Properties>
Parameters
keyvector key.
sVectorvector to be deserialized.
itemKeyvector item key

◆ deserialize() [2/2]

template<typename K , typename V , typename C , typename A >
void inviwo::Deserializer::deserialize ( const std::string &  key,
std::map< K, V, C, A > &  sMap,
const std::string &  itemKey = "item",
const std::string &  comparisionAttribute = SerializeConstants::KeyAttribute 
)

Deserialize a map.

Deserialize a map, which can have keys of type K, values of type V* (pointers) and compare function C ( optional if K primitive type, i.e., std::string, int, etc.,) eg., std::map<std::string, Property*>

eg. xml tree

<Properties>
<Property identifier="enableMIP" displayName="MIP">
<value content="0" />
</Property>
<Property identifier="enableShading" displayName="Shading">
<value content="0" />
</Property>
<Properties>

In the above xml tree,

key = "Properties" itemKey = "Property" param comparisionAttribute = "identifier" param sMap["enableMIP"] = address of a property sMap["enableShading"] = address of a property where, "enableMIP" & "enableShading" are keys. address of a property is a value

Note: If children has attribute "type", then comparisionAttribute becomes meaningless. Because deserializer always allocates a new instance of type using registered factories. eg., <Processor type="EntryExitPoints" identifier="EntryExitPoints" reference="ref2">

Parameters
keyMap key or parent node of itemKey.
sMapmap to be deserialized - source / input map.
itemKeymap item key of children nodes.
comparisionAttributeforced comparison attribute.

◆ getNonRegisteredType()

template<typename T >
T * inviwo::Deserializer::getNonRegisteredType ( )

For allocating objects that do not belong to any registered factories.

Returns
T* Pointer to object of type T.

◆ getRegisteredType()

template<typename T >
T * inviwo::Deserializer::getRegisteredType ( const std::string &  className)

For allocating objects such as processors, properties.. using registered factories.

Parameters
classNameis used by registered factories to allocate the required object.
Returns
T* nullptr if allocation fails or className does not exist in any factories.

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