47 #ifndef _MIRA_PROPERTYSERIALIZER_H_ 48 #define _MIRA_PROPERTYSERIALIZER_H_ 98 template <
typename Getter,
typename Setter>
134 TwithoutConst& nonconstMember =
const_cast<TwithoutConst&
>(
member);
135 typedNode->
update(nonconstMember);
137 typedNode->mUpdated =
true;
138 foreach (
auto c, typedNode->
children())
151 TwithoutConst& nonconstMember =
const_cast<TwithoutConst&
>(
member);
152 node = createNode(parentNode, nonconstMember, meta, hint,
isReadOnly, isVolatile);
167 std::vector<std::tuple<int, PropertyNode::NodeList::iterator, PropertyNode*>> toRemove;
169 if (!(*it)->mUpdated)
170 toRemove.push_back(std::make_tuple(index, it, *it));
176 for (
auto i = toRemove.rbegin(); i != toRemove.rend(); ++i) {
177 auto inext = std::next(i);
178 if ((inext != toRemove.rend()) && (std::get<0>(*i) == std::get<0>(*inext)+1)) {
188 for (
auto i = toRemove.rbegin(); i != toRemove.rend(); ++i) {
218 template <
typename T>
228 template <
typename T>
230 const std::string&
id, T&
object) {
241 template <
typename T>
253 template <
typename T>
255 const std::string&
id, T&
object) {
274 PropertyNode* node =
new TypedPropertyNodeImpl<T>(meta.
id, meta.
name,
279 std::swap(node->mHint, hint);
294 template <
typename T>
298 MIRA_THROW(XInvalidParameter,
"PropertyNode::synchronize() requires a valid parent node!");
302 this->
id(), *this->value());
307 template <
typename T>
308 inline void TypedPropertyNodeImpl<T*>::synchronize()
311 MIRA_THROW(XInvalidParameter,
"PropertyNode::synchronize() requires a valid parent node!");
314 s.reflectProperties(this->
parent(), this->
name().c_str(),
315 this->
id(), *this->pointer());
319 template <
typename Getter,
typename Setter>
320 inline void TypedPropertyNodeImpl<Accessor<Getter,Setter>>::synchronize()
323 MIRA_THROW(XInvalidParameter,
"PropertyNode::synchronize() requires a valid parent node!");
325 PropertySerializer s;
326 s.reflectProperties(this->parent(), this->name().c_str(),
327 this->
id(), *this->accessor());
334 namespace serialization {
338 template<
typename Reflector,
typename Container>
struct ReflectReadSetItems;
344 template<
typename Container>
345 struct ReflectReadSetItems<PropertySerializer, Container>
347 typedef typename Container::value_type
type;
349 static void reflect(PropertySerializer& r, Container& c)
353 foreach(
const type& v, c)
355 r.roproperty(
"item",
"item["+
toString(
id)+
"]", v,
"",
362 template<
typename Reflector,
typename Container>
struct ReflectReadMapItems;
369 template<
typename Container>
370 struct ReflectReadMapItems<PropertySerializer, Container>
372 typedef typename Container::value_type
value_type;
374 static void reflect(PropertySerializer& r, Container& c)
380 r.roproperty(
"key",
"key["+
toString(
id)+
"]", p.first,
"",
Abstract base class for all derived property node classes.
Definition: PropertyNode.h:202
void object(T &member)
Is called for each complex object.
Definition: RecursiveMemberReflector.h:301
std::string mID
the unique id of the property
Definition: PropertyNode.h:178
PropertyNode * mCurrentNode
Definition: PropertySerializer.h:289
virtual PropertyNode * parent()
Returns the parent property node (or NULL, if this is a root node)
Definition: PropertyNode.h:224
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:87
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:173
virtual NodeList & children()
Returns a vector with all child property nodes.
Definition: PropertyNode.h:230
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:99
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:82
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:256
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:73
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
Implementation of TypedPropertyNode.
Definition: PropertyNode.h:811
void update(T &value)
Is called by PropertySerializer to update the internal representation of the value of the property...
Definition: PropertyNode.h:735
bool isReadOnly() const
Returns true, if this property is read-only and hence, can not be modified.
Definition: PropertyNode.h:167
A special PropertyReflector that creates a PropertyNode for each reflected property.
Definition: PropertySerializer.h:67
void itemName(const std::string &name)
Definition: PropertySerializer.h:201
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:113
PropertyNode * reflectProperties(const std::string &name, T &object)
Reflects the properties of the specified 'object'.
Definition: PropertySerializer.h:242
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:229
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:254
void removeChildren(int index, int count)
Removes contiguous children, starting at index (without deleting them).
Definition: PropertyNode.h:364
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.
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:170
void reflectProperties(PropertyNode *root, const std::string &name, T &object)
Reflects the properties of the specified 'object'.
Definition: PropertySerializer.h:219
const std::string & name() const
Returns the name of this property as specified in the reflect() method.
Definition: PropertyNode.h:143
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:729
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