This commit is contained in:
Jan Möbius
2022-01-18 15:43:01 +01:00
2 changed files with 20 additions and 9 deletions

View File

@@ -33,7 +33,6 @@ typedef TriMesh Mesh;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef DOXY_IGNORE_THIS #ifndef DOXY_IGNORE_THIS
struct MyData struct MyData
{ {
int ival; int ival;
@@ -82,7 +81,6 @@ struct MyData
bool operator != (const MyData& _rhs) const { return !(*this == _rhs); } bool operator != (const MyData& _rhs) const { return !(*this == _rhs); }
}; };
#endif #endif
@@ -118,6 +116,11 @@ namespace OpenMesh {
return size_of(); return size_of();
} }
static std::string type_identifier(void)
{
return "RegisteredDataType";
}
static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false)
{ {
size_t bytes; size_t bytes;

View File

@@ -2,7 +2,7 @@
The %OpenMesh' proprietary OM format allows to store and restore The %OpenMesh' proprietary OM format allows to store and restore
custom properties along with the standard properties. For it we have custom properties along with the standard properties. For it we have
to use named custom properties like the following one to use named custom properties like the following one:
\dontinclude 10-persistence/persistence.cc \dontinclude 10-persistence/persistence.cc
\skipline VPropHandleT \skipline VPropHandleT
@@ -15,8 +15,8 @@ persistent, must follow a few rules
-# max. 256 characters long -# max. 256 characters long
-# The prefixes \c "v:", \c "h:", \c "e:", \c "f:" and \c "m:" are reserved. -# The prefixes \c "v:", \c "h:", \c "e:", \c "f:" and \c "m:" are reserved.
If we stick to this rules we are fine. Furthermore we have to If we stick to these rules we are fine. Furthermore, we have to
consider, that the names are handled case-sensitive. consider that the names are handled case-sensitive.
To actually make a custom property persistent we have to set the To actually make a custom property persistent we have to set the
persistent flag in the property with persistent flag in the property with
@@ -37,9 +37,8 @@ IO::read_mesh() will return \c false. And if the data cannot be
restored, because the appropriate restore method is not available the restored, because the appropriate restore method is not available the
exception std::logic_error() will be thrown. exception std::logic_error() will be thrown.
Since we now know the behaviour, we need to know what kind of data can Without any further effort, simply using named properties
we store? Without any further effort, simply using named properties and setting the persistent flag, we can store following types:
and setting the persistent flag, we can store following types
- bool, stored as a bitset - bool, stored as a bitset
- all other fundamental types except long double, (unsigned) long and size_t - all other fundamental types except long double, (unsigned) long and size_t
@@ -75,6 +74,7 @@ Herein we have to implement the following set of static member
variables and functions: variables and functions:
\skipline is_streamable \skipline is_streamable
\skipline type_identifier
\skipline size_of \skipline size_of
\skipline size_of \skipline size_of
\skipline store \skipline store
@@ -83,6 +83,14 @@ variables and functions:
The flag \c is_streamable has to be set to \c true. Else the data The flag \c is_streamable has to be set to \c true. Else the data
cannot be stored at all. cannot be stored at all.
<h5>\c type_identifier </h5>
The \c type_identifier method needs only to be implemented if typename.hh
does not already provide a string for type recognition. If this is the
case, the type identifier needs to be registered with the macro
\c OM_REGISTER_PROPERTY_TYPE(MyData)
<h5>\c size_of methods </h5> <h5>\c size_of methods </h5>
Since the size of the custom data can be static, which means we know Since the size of the custom data can be static, which means we know