47 #ifndef _MIRA_PROPERTYSERIALIZER_H_ 48 #define _MIRA_PROPERTYSERIALIZER_H_ 99 template <
typename Getter,
typename Setter>
135 TwithoutConst& nonconstMember =
const_cast<TwithoutConst&
>(
member);
136 typedNode->
update(nonconstMember);
138 mUpdatedNodes.insert(node);
150 TwithoutConst& nonconstMember =
const_cast<TwithoutConst&
>(
member);
151 node = createNode(parentNode, nonconstMember, meta, hint,
isReadOnly, isVolatile);
152 mUpdatedNodes.insert(node);
157 }
else if (parentNode && isVolatile) {
169 std::vector<std::tuple<int, PropertyNode::NodeList::iterator, PropertyNode*>> toRemove;
171 if (mUpdatedNodes.find((*it)) == mUpdatedNodes.end())
172 toRemove.push_back(std::make_tuple(index, it, *it));
178 for (
auto i = toRemove.rbegin(); i != toRemove.rend(); ++i) {
179 auto inext = std::next(i);
180 if ((inext != toRemove.rend()) && (std::get<0>(*i) == std::get<0>(*inext)+1)) {
190 for (
auto i = toRemove.rbegin(); i != toRemove.rend(); ++i) {
220 template <
typename T>
223 mUpdatedNodes.clear();
231 template <
typename T>
233 const std::string&
id, T&
object) {
235 mUpdatedNodes.clear();
245 template <
typename T>
248 mUpdatedNodes.clear();
258 template <
typename T>
260 const std::string&
id, T&
object) {
262 mUpdatedNodes.clear();
280 PropertyNode* node =
new TypedPropertyNodeImpl<T>(meta.
id, meta.
name,
285 std::swap(node->mHint, hint);
299 std::set<PropertyNode*> mUpdatedNodes;
304 template <
typename T>
305 template <
typename Type>
308 return serialization::hasRecursiveReflect<Type, typename PropertySerializer::Tag>();
312 template <
typename T>
316 MIRA_THROW(XInvalidParameter,
"PropertyNode::synchronize() requires a valid parent node!");
320 this->
id(), nodeValue);
325 template <
typename T>
329 MIRA_THROW(XInvalidParameter,
"PropertyNode::synchronize() requires a valid parent node!");
333 this->
id(), nodePointer);
337 template <
typename Getter,
typename Setter>
338 inline void TypedPropertyNodeImpl<Accessor<Getter,Setter>>::synchronize(AccessorType& nodeAccessor)
341 MIRA_THROW(XInvalidParameter,
"PropertyNode::synchronize() requires a valid parent node!");
343 PropertySerializer s;
344 s.reflectProperties(this->parent(), this->name().c_str(),
345 this->
id(), nodeAccessor);
352 namespace serialization {
356 template<
typename Reflector,
typename Container>
struct ReflectReadSetItems;
362 template<
typename Container>
363 struct ReflectReadSetItems<PropertySerializer, Container>
365 typedef typename Container::value_type
type;
367 static void reflect(PropertySerializer& r, Container& c)
371 foreach(
const type& v, c)
373 r.roproperty(
"item",
"item["+
toString(
id)+
"]", v,
"",
380 template<
typename Reflector,
typename Container>
struct ReflectReadMapItems;
387 template<
typename Container>
388 struct ReflectReadMapItems<PropertySerializer, Container>
390 typedef typename Container::value_type
value_type;
392 static void reflect(PropertySerializer& r, Container& c)
398 r.roproperty(
"key",
"key["+
toString(
id)+
"]", p.first,
"",
Abstract base class for all derived property node classes.
Definition: PropertyNode.h:212
void object(T &member)
Is called for each complex object.
Definition: RecursiveMemberReflector.h:385
std::string mID
the unique id of the property
Definition: PropertyNode.h:188
PropertyNode * mCurrentNode
Definition: PropertySerializer.h:295
virtual PropertyNode * parent()
Returns the parent property node (or NULL, if this is a root node)
Definition: PropertyNode.h:234
const PropertyNode * findChildNode(const std::vector< std::string > &ids, std::size_t level=0) const
Searches for a child property node (which may also be a child of a child of a child, etc).
static void reflect(Reflector &r, Container &c)
Definition: StlCollections.h:142
void continueWithBaseInvoke(T &member, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
Is called by invokePropertyMemberOverwrite() and will call the actual Base::invokePropertyMemberOverw...
Definition: PropertySerializer.h:88
Declaration and implementation of the property node hierarchy.
#define MIRA_PROPERTY_WITH_ID(reflector, name, id, var,...)
Definition: ReflectorInterface.h:1009
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void setName(const std::string &name)
For internal use by PropertySerializer only: Overrides the name of the property.
Definition: PropertyNode.h:179
virtual NodeList & children()
Returns a vector with all child property nodes.
Definition: PropertyNode.h:240
void continueWithBaseInvoke(Accessor< Getter, Setter > &accessor, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
Specialization of the above method for properties with getters and setters.
Definition: PropertySerializer.h:100
void member(const char *name, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: PropertyReflector.h:75
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:78
void setVolatile(bool isVolatile)
Definition: PropertyNode.h:183
A property hint gives optional instructions to the property editor, i.e.
Definition: PropertyHint.h:82
std::string toString(const T &value, int precision=-1)
Converts any data type to string (the data type must support the stream << operator).
Definition: ToString.h:252
boost::mpl::bool_< true > isReadOnly
Specifies, if the Reflector is read-only (true) or write-only (false).
Definition: ReflectorInterface.h:121
PropertySerializer()
Definition: PropertySerializer.h:74
static void reflect(Reflector &r, Container &c)
Definition: StlCollections.h:343
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
Container::value_type value_type
Definition: StlCollections.h:341
static constexpr bool mayHaveChildNodes()
Definition: PropertySerializer.h:306
Implementation of TypedPropertyNode.
Definition: PropertyNode.h:880
void update(T &value)
Is called by PropertySerializer to update the internal representation of the value of the property...
Definition: PropertyNode.h:804
bool isReadOnly() const
Returns true, if this property is read-only and hence, can not be modified.
Definition: PropertyNode.h:169
A special PropertyReflector that creates a PropertyNode for each reflected property.
Definition: PropertySerializer.h:68
void itemName(const std::string &name)
Definition: PropertySerializer.h:203
This object is volatile: its memory location may become invalid to access.
Definition: ReflectControlFlags.h:90
void invokePropertyMemberOverwrite(T &member, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
Invokes the PropertyReflector on the specified member.
Definition: PropertySerializer.h:114
PropertyNode * reflectProperties(const std::string &name, T &object)
Reflects the properties of the specified 'object'.
Definition: PropertySerializer.h:246
The Accessor class is used as an adapter to reduce the code bloat within the reflection and serializa...
Definition: Accessor.h:244
void reflectProperties(PropertyNode *root, const std::string &name, const std::string &id, T &object)
Same as above, but additionally, a unique id can be specified for the object.
Definition: PropertySerializer.h:232
PropertyNode * reflectProperties(const std::string &name, const std::string &id, T &object)
Same as above, but additionally, a unique id can be specified for the object.
Definition: PropertySerializer.h:259
void removeChildren(int index, int count)
Removes contiguous children, starting at index (without deleting them).
Definition: PropertyNode.h:382
void addChild(PropertyNode *child, int index=-1)
Adds the specified property node as child node.
Base class for all Reflectors that take care of properties.
void synchronize() override
Synchronizes this node and its children with the the actual underlying data representation.
Definition: PropertyNode.h:954
Base class for all Reflectors that take care of properties.
Definition: PropertyReflector.h:62
bool isVolatile() const
Returns true, if this property is volatile and hence, must be locked for access.
Definition: PropertyNode.h:172
void reflectProperties(PropertyNode *root, const std::string &name, T &object)
Reflects the properties of the specified 'object'.
Definition: PropertySerializer.h:221
const std::string & name() const
Returns the name of this property as specified in the reflect() method.
Definition: PropertyNode.h:145
void property(const char *name, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: PropertyReflector.h:126
friend class PropertySerializer
Definition: PropertyNode.h:798
void invokePropertyMemberOverwrite(T &member, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
Is called by invokePropertyMember.
Definition: PropertyReflector.h:337
Container::value_type type
Definition: StlCollections.h:140