Inviwo 0.9.12-pre
Inviwo documentation
|
Public Types | |
enum class | Result { NoChange , Modified , NotFound } |
using | ExceptionHandler = std::function<void(ExceptionContext)> |
Public Types inherited from inviwo::SerializeBase | |
using | allocator_type = std::pmr::polymorphic_allocator<std::byte> |
Public Member Functions | |
Deserializer (const std::filesystem::path &fileName, std::string_view rootElement=SerializeConstants::InviwoWorkspace, allocator_type alloc={}) | |
Deserialize content from a file. | |
Deserializer (std::istream &stream, const std::filesystem::path &refPath, std::string_view rootElement=SerializeConstants::InviwoWorkspace, allocator_type alloc={}) | |
Deserialize content from a stream. | |
Deserializer (const std::pmr::string &content, const std::filesystem::path &refPath, std::string_view rootElement=SerializeConstants::InviwoWorkspace, allocator_type alloc={}) | |
Deserialize content from a stream. | |
Deserializer (const Deserializer &)=delete | |
Deserializer (Deserializer &&)=default | |
Deserializer & | operator= (const Deserializer &that)=delete |
Deserializer & | operator= (Deserializer &&that)=default |
template<typename T , typename A > | |
void | deserialize (std::string_view key, std::vector< T, A > &sVector, std::string_view itemKey="item") |
Deserialize a vector. | |
template<typename T , typename H , typename P , typename A > | |
void | deserialize (std::string_view key, std::unordered_set< T, H, P, A > &sSet, 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<std::regular T, typename A > | |
Result | deserializeTrackChanges (std::string_view key, std::vector< T, A > &sVector, std::string_view itemKey="item") |
template<typename DeserializeFunction > | |
void | deserializeRange (std::string_view key, std::string_view itemKey, DeserializeFunction deserializeFunction) |
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 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 C , typename T = typename C::value_type, typename... Funcs> requires requires(T& t, size_t i, std::string_view s, deserializer::IndexFunctions<Funcs...> f) { { std::invoke(f.makeNew) } -> std::same_as<T>; { std::invoke(f.onNew, t, i) }; { std::invoke(f.onRemove, t) }; } | |
void | deserialize (std::string_view key, C &container, std::string_view itemKey, deserializer::IndexFunctions< Funcs... > f) |
template<typename C , typename T = typename C::value_type, typename... Funcs> requires requires(T& t, size_t i, std::string_view s, deserializer::IdentifierFunctions<Funcs...> f) { { std::invoke(f.getID, t) } -> std::same_as<std::string_view>; { std::invoke(f.makeNew) } -> std::same_as<T>; { std::invoke(f.filter, s, i) } -> std::same_as<bool>; { std::invoke(f.onNew, t, i) }; { std::invoke(f.onRemove, s) }; { std::invoke(f.onMove, t, i) }; } | |
void | deserialize (std::string_view key, C &container, std::string_view itemKey, deserializer::IdentifierFunctions< Funcs... > f) |
template<typename C , typename K = typename C::key_type, typename T = typename C::mapped_type, typename... Funcs> requires requires(const K& k, T& t, size_t i, std::string_view s, deserializer::MapFunctions<Funcs...> f) { { std::invoke(f.idTransform, s) } -> std::same_as<K>; { std::invoke(f.makeNew) } -> std::same_as<T>; { std::invoke(f.filter, k) } -> std::same_as<bool>; { std::invoke(f.onNew, k, t) }; { std::invoke(f.onRemove, k) }; } | |
void | deserialize (std::string_view key, C &container, std::string_view itemKey, deserializer::MapFunctions< Funcs... > f) |
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 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<class T > requires requires(T& t, Deserializer& d) { { t.deserialize(d) }; } | |
void | deserialize (std::string_view key, T &sObj) |
std::optional< std::string_view > | attribute (std::string_view key) const |
std::optional< std::string_view > | attribute (std::string_view child, std::string_view key) const |
bool | hasElement (std::string_view key) const |
void | setExceptionHandler (ExceptionHandler handler) |
void | handleError (const ExceptionContext &context) |
void | convertVersion (VersionConverter *converter) |
void | registerFactory (FactoryBase *factory) |
int | getVersion () const |
Public Member Functions inherited from inviwo::SerializeBase | |
SerializeBase (const std::filesystem::path &fileName, allocator_type alloc={}) | |
Base class for Serializer and Deserializer. | |
SerializeBase (const SerializeBase &rhs)=delete | |
SerializeBase (SerializeBase &&rhs) noexcept | |
SerializeBase & | operator= (const SerializeBase &)=delete |
SerializeBase & | operator= (SerializeBase &&) noexcept |
const std::filesystem::path & | getFileName () const |
Gets the workspace file name. | |
const std::filesystem::path & | getFileDir () const |
Gets the workspace file directory. | |
allocator_type | getAllocator () const |
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 | |
LogFilter & | operator= (const LogFilter &)=default |
LogFilter & | operator= (LogFilter &&) noexcept=default |
void | setVerbosity (LogVerbosity verbosity) |
LogVerbosity | getVerbosity () |
void | setLogger (Logger *logger) |
Logger * | getLogger () 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 |
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. | |
Protected Attributes inherited from inviwo::SerializeBase | |
std::filesystem::path | fileName_ |
std::filesystem::path | fileDir_ |
std::unique_ptr< TiXmlDocument > | doc_ |
TiXmlElement * | rootElement_ |
bool | retrieveChild_ |
|
explicit |
Deserialize content from a file.
fileName | path to file that is to be deserialized. |
inviwo::Deserializer::Deserializer | ( | std::istream & | stream, |
const std::filesystem::path & | refPath, | ||
std::string_view | rootElement = SerializeConstants::InviwoWorkspace, | ||
allocator_type | alloc = {} ) |
Deserialize content from a stream.
stream | Stream with content that is to be deserialized. |
refPath | Used to calculate paths relative to the stream source if any. |
inviwo::Deserializer::Deserializer | ( | const std::pmr::string & | content, |
const std::filesystem::path & | refPath, | ||
std::string_view | rootElement = SerializeConstants::InviwoWorkspace, | ||
allocator_type | alloc = {} ) |
Deserialize content from a stream.
content | String with content that is to be deserialized. |
refPath | Used to calculate paths relative to the stream source if any. |
void inviwo::Deserializer::deserialize | ( | std::string_view | key, |
C & | container, | ||
std::string_view | itemKey, | ||
deserializer::IndexFunctions< Funcs... > | f ) |
For more advanced deserialization. Useful when one has to call observer notifications. Example usage, serialize as usual
Then deserialize with notifications:
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
In the above xml tree,
key = "Properties" itemKey = "Property" param comparisonAttribute = "identifier"
key | Map key or parent node of itemKey. |
sMap | map to be deserialized - source / input map. |
itemKey | map item key of children nodes. |
comparisonAttribute | forced comparison attribute. |
void inviwo::Deserializer::deserialize | ( | std::string_view | key, |
std::vector< T, A > & | 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>
key | vector key. |
sVector | vector to be deserialized. |
itemKey | vector item key |