MIRA
ReflectCollection.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
48 #ifndef _MIRA_REFLECTCOLLECTION_H_
49 #define _MIRA_REFLECTCOLLECTION_H_
50 
52 
53 namespace mira {
54 
56 
57 namespace serialization {
58 
60 
68 template<typename Reflector, typename Collection>
70 {
71  static void reflect(Reflector& r, uint32& ioCount)
72  {
73  r.member("@itemcount", ioCount, "");
74  }
75 };
76 
84 template<typename Reflector, typename Container>
86 {
87  typedef typename Container::value_type type;
88 
89  static void reflect(Reflector& r, Container& c)
90  {
91  // store each item
92 #if __GNUC_PREREQ(4,5)
93  using std::begin;
94  using std::end;
95  auto it = begin(c);
96  auto endit = end(c);
97 #else
98  auto it = c.begin();
99  auto endit = c.end();
100 #endif
101 
102  for (int id=0; it != endit; ++it, ++id)
103  {
104  // specifies the id string of the element, since the
105  // name "item" is the same for all elements
106  MIRA_PROPERTY_WITH_ID(r, "item", "item["+toString(id)+"]", *it, "",
108  }
109  }
110 };
111 
113 
114 } // namespace
115 
117 
118 } // namespace
119 
120 #endif
#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
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
Can be specialized for a concrete derived RecursiveMemberReflector to reflect the items of collection...
Definition: ReflectCollection.h:85
Contains the base interface of all Reflectors, Serializers, etc.
static void reflect(Reflector &r, uint32 &ioCount)
Definition: ReflectCollection.h:71
Container::value_type type
Definition: ReflectCollection.h:87
static void reflect(Reflector &r, Container &c)
Definition: ReflectCollection.h:89
This object is volatile: its memory location may become invalid to access.
Definition: ReflectControlFlags.h:90
Can be specialized for a concrete derived RecursiveMemberReflector to reflect the size of collections...
Definition: ReflectCollection.h:69