Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::Deserializer Class Reference
+ Inheritance diagram for inviwo::Deserializer:

Public Types

template<typename T >
using HasDeserialize = decltype(std::declval<T>().deserialize(std::declval<Deserializer&>()))
 
using ExceptionHandler = std::function<void(ExceptionContext)>
 

Public Member Functions

 Deserializer (const std::filesystem::path &fileName)
 Deserialize content from a file.
 
 Deserializer (std::istream &stream, const std::filesystem::path &refPath)
 Deserialize content from a stream.
 
 Deserializer (const Deserializer &)=delete
 
 Deserializer (Deserializer &&)=default
 
Deserializeroperator= (const Deserializer &that)=delete
 
Deserializeroperator= (Deserializer &&that)=default
 
template<typename T >
void deserialize (std::string_view key, std::vector< T * > &sVector, std::string_view itemKey="item")
 Deserialize a vector.
 
template<typename T , typename C >
void deserialize (std::string_view key, std::vector< T * > &sVector, std::string_view itemKey, C identifier)
 
template<typename T >
void deserialize (std::string_view key, std::vector< T > &sVector, std::string_view itemKey="item")
 
template<typename T >
void deserialize (std::string_view key, std::unordered_set< T > &sSet, std::string_view itemKey="item")
 
template<typename T >
void deserialize (std::string_view key, std::vector< std::unique_ptr< T > > &vector, std::string_view itemKey="item")
 
template<typename T >
void deserialize (std::string_view key, std::list< T > &sContainer, std::string_view itemKey="item")
 
template<typename T , size_t N>
void deserialize (std::string_view key, std::array< T, N > &sContainer, std::string_view itemKey="item")
 
template<typename K , typename V , typename C , typename A >
void deserialize (std::string_view key, std::map< K, V, C, A > &sMap, std::string_view itemKey="item", std::string_view comparisonAttribute=SerializeConstants::KeyAttribute)
 Deserialize a map.
 
template<typename K , typename V , typename C , typename A >
void deserialize (std::string_view key, std::map< K, V *, C, A > &sMap, std::string_view itemKey="item", std::string_view comparisonAttribute=SerializeConstants::KeyAttribute)
 
template<typename K , typename V , typename C , typename A >
void deserialize (std::string_view key, std::map< K, std::unique_ptr< V >, C, A > &sMap, std::string_view itemKey="item", std::string_view comparisonAttribute=SerializeConstants::KeyAttribute)
 
template<typename K , typename V , typename H , typename C , typename A >
void deserialize (std::string_view key, std::unordered_map< K, V, H, C, A > &map, std::string_view itemKey="item", std::string_view comparisonAttribute=SerializeConstants::KeyAttribute)
 
template<typename T , typename ValueGetter , typename IdGetter >
void deserialize (std::string_view key, ContainerWrapper< T, ValueGetter, IdGetter > &container)
 
void deserialize (std::string_view key, signed char &data, const SerializationTarget &target=SerializationTarget::Node)
 
void deserialize (std::string_view key, char &data, const SerializationTarget &target=SerializationTarget::Node)
 
void deserialize (std::string_view 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 (std::string_view 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 (std::string_view key, T &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename T >
void deserialize (std::string_view 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 (std::string_view key, Vec &data)
 
template<typename Mat , typename std::enable_if< util::rank< Mat >::value==2, int >::type = 0>
void deserialize (std::string_view key, Mat &data)
 
template<size_t N>
void deserialize (std::string_view key, std::bitset< N > &bits)
 
void deserialize (std::string_view key, std::filesystem::path &path, const SerializationTarget &target=SerializationTarget::Node)
 
void deserialize (std::string_view key, Serializable &sObj)
 Deserialize any Serializable object.
 
template<class T >
void deserialize (std::string_view 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 (std::string_view key, T *&data)
 
template<class T >
void deserialize (std::string_view key, std::unique_ptr< T > &data)
 
template<class T >
void deserialize (std::string_view key, std::shared_ptr< T > &data)
 
template<class Base , class T >
void deserializeAs (std::string_view key, std::unique_ptr< T > &data)
 
template<typename T , typename = std::enable_if_t<util::is_detected_exact_v<void, HasDeserialize, T>>>
void deserialize (std::string_view key, T &sObj)
 
void setExceptionHandler (ExceptionHandler handler)
 
void handleError (const ExceptionContext &context)
 
void convertVersion (VersionConverter *converter)
 
template<typename T >
T * getRegisteredType (std::string_view className)
 For allocating objects such as processors, properties.. using registered factories.
 
template<typename T >
T * getNonRegisteredType ()
 For allocating objects that do not belong to any registered factories.
 
void registerFactory (FactoryBase *factory)
 
int getInviwoWorkspaceVersion () const
 
- Public Member Functions inherited from inviwo::SerializeBase
 SerializeBase ()
 Base class for Serializer and Deserializer.
 
 SerializeBase (const std::filesystem::path &fileName)
 Base class for Serializer and Deserializer.
 
 SerializeBase (std::istream &stream, const std::filesystem::path &path)
 Base class for Serializer and Deserializer.
 
 SerializeBase (const SerializeBase &rhs)=delete
 
 SerializeBase (SerializeBase &&rhs) noexcept
 
SerializeBaseoperator= (const SerializeBase &)=delete
 
SerializeBaseoperator= (SerializeBase &&) noexcept
 
virtual const std::filesystem::path & getFileName () const
 gets the xml file name.
 
- Public Member Functions inherited from inviwo::LogFilter
 LogFilter (Logger *logger=LogCentral::getPtr())
 
 LogFilter (Logger *logger, LogVerbosity verbosity)
 
 LogFilter (const LogFilter &)=default
 
 LogFilter (LogFilter &&) noexcept=default
 
LogFilteroperator= (const LogFilter &)=default
 
LogFilteroperator= (LogFilter &&) noexcept=default
 
void setVerbosity (LogVerbosity verbosity)
 
LogVerbosity getVerbosity ()
 
void setLogger (Logger *logger)
 
LoggergetLogger () const
 
virtual void log (std::string_view logSource, LogLevel level, LogAudience audience, std::string_view file, std::string_view function, int line, std::string_view msg) override
 
virtual void logProcessor (Processor *processor, LogLevel level, LogAudience audience, std::string_view msg, std::string_view file, std::string_view function, int line) override
 
virtual void logNetwork (LogLevel level, LogAudience audience, std::string_view msg, std::string_view file, std::string_view function, int line) override
 
- Public Member Functions inherited from inviwo::Logger
virtual void logAssertion (std::string_view file, std::string_view function, int line, std::string_view msg)
 

Friends

class NodeSwitch
 
template<typename T , typename ValueGetter , typename IdGetter >
class ContainerWrapper
 

Additional Inherited Members

- Static Public Member Functions inherited from inviwo::SerializeBase
template<typename U >
static constexpr bool isPrimitiveType ()
 Checks whether the given type is a primitive type.
 
static std::string nodeToString (const TxElement &node)
 
- Protected Attributes inherited from inviwo::SerializeBase
std::filesystem::path fileName_
 
std::unique_ptr< TxDocument > doc_
 
TxElement * rootElement_
 
bool retrieveChild_
 

Constructor & Destructor Documentation

◆ Deserializer() [1/2]

inviwo::Deserializer::Deserializer ( const std::filesystem::path & fileName)

Deserialize content from a file.

Parameters
fileNamepath to file that is to be deserialized.

◆ Deserializer() [2/2]

inviwo::Deserializer::Deserializer ( std::istream & stream,
const std::filesystem::path & refPath )

Deserialize content from a stream.

Parameters
streamStream with content that is to be deserialized.
refPathUsed to calculate paths relative to the stream source if any.

Member Function Documentation

◆ deserialize() [1/2]

template<typename K , typename V , typename C , typename A >
void inviwo::Deserializer::deserialize ( std::string_view key,
std::map< K, V, C, A > & sMap,
std::string_view itemKey = "item",
std::string_view comparisonAttribute = 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 comparisonAttribute = "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 comparisonAttribute 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.
comparisonAttributeforced comparison attribute.

◆ deserialize() [2/2]

template<typename T >
void inviwo::Deserializer::deserialize ( std::string_view key,
std::vector< T * > & sVector,
std::string_view 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

◆ 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 ( std::string_view 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 file: