MIRA
ServiceLevel.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 
47 #ifndef _MIRA_SERVICELEVEL_H_
48 #define _MIRA_SERVICELEVEL_H_
49 
50 #ifndef Q_MOC_RUN
51 #include <boost/algorithm/string/replace.hpp>
52 #endif
53 
54 namespace mira
55 {
56 
58 
63 {
64 public:
65 
67  {
68  UDP,
70  };
71 
73 
74  template<typename Reflector>
75  void reflect(Reflector& r)
76  {
78  = r.version(2, serialization::AcceptDesiredVersion(), this);
79  r.member("Codecs", codecs,"", std::list<BinarySerializerCodecPtr>());
80  r.member("ConnectionType", connectionType, "", TCP);
81 
82  if (version >= 2)
83  r.member("Interval", interval, "", Duration::seconds(-1));
84  }
85 
86  // Specialization for XMLDeserializer
87  // for convenience: add the Interval member without requiring a version
88  // (with proper default if not present)
90  {
91  r.member("Codecs", codecs,"", std::list<BinarySerializerCodecPtr>());
92  r.member("ConnectionType", connectionType, "", TCP);
93  r.member("Interval", interval, "", Duration::seconds(-1));
94  }
95 
96  std::list<BinarySerializerCodecPtr> codecs;
98  Duration interval; // negative by default, as invalid Duration cannot be serialized properly :(
99 };
100 
103 {
104 public:
105 
107 
108  ServiceLevel(const std::string& channel) :
109  channelID(channel) {}
110 
111  ServiceLevel(const std::string& channel, const ServiceLevelBase& other) :
112  ServiceLevelBase(other), channelID(channel) {}
113 
114  template<typename Reflector>
115  void reflect(Reflector& r)
116  {
117  r.member("Channel", channelID, "", "");
118 
119  // As an exception, do not use reflectBase here, in order to remain compatible
120  // with older serialization. (Cannot use 'version' in this case either, as the
121  // ServiceLevel must be understood by older code, and that will understand
122  // there is a version, but not accept a newer version :( )
124  }
125 
126  std::string channelID;
127 };
128 
131 {
132 public:
133 
135 
137  channelType(type) {}
138 
139  template<typename Reflector>
140  void reflect(Reflector& r)
141  {
142  r.member("ChannelType", channelType,
144  "", "");
146  }
147 
149  boost::replace_all(type, "(", "<");
150  boost::replace_all(type, "[", "<");
151  boost::replace_all(type, "{", "<");
152 
153  boost::replace_all(type, ")", ">");
154  boost::replace_all(type, "]", ">");
155  boost::replace_all(type, "}", ">");
156 
157  channelType = type;
158  }
159 
161 };
163 
164 }
165 
166 #endif
QoS management information for channels.
Definition: ServiceLevel.h:62
void reflect(Reflector &r)
Definition: ServiceLevel.h:115
void reflect(XMLDeserializer &r)
Definition: ServiceLevel.h:89
Definition: ServiceLevel.h:69
ServiceLevel by channel name.
Definition: ServiceLevel.h:102
Definition: ServiceLevel.h:68
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
std::string Typename
Definition: Typename.h:60
void member(const char *name, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: RecursiveMemberReflector.h:862
#define MIRA_REFLECT_BASE(reflector, BaseClass)
Macro that can be used to reflect the base class easily.
Definition: ReflectorInterface.h:912
Setter< T > setter(void(*f)(const T &))
Creates a Setter for global or static class methods taking the argument by const reference.
Definition: GetterSetter.h:443
Duration interval
Definition: ServiceLevel.h:98
ServiceLevel by channel type.
Definition: ServiceLevel.h:130
TypeServiceLevel(const Typename &type)
Definition: ServiceLevel.h:136
ServiceLevel(const std::string &channel, const ServiceLevelBase &other)
Definition: ServiceLevel.h:111
uint8 VersionType
Definition: ReflectorInterface.h:72
std::string channelID
Definition: ServiceLevel.h:126
ConnectionType connectionType
Definition: ServiceLevel.h:97
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
sec_type seconds() const
Returns normalized number of seconds (0..59)
Definition: Time.h:280
Use this class to represent time durations.
Definition: Time.h:106
ConnectionType
Definition: ServiceLevel.h:66
ServiceLevel()
Definition: ServiceLevel.h:106
Tag class used as parameter to ReflectorInterface::version() etc.
Definition: ReflectorInterface.h:80
void reflect(Reflector &r)
Definition: ServiceLevel.h:75
void setChannelType(Typename type)
Definition: ServiceLevel.h:148
ServiceLevel(const std::string &channel)
Definition: ServiceLevel.h:108
void reflect(Reflector &r)
Definition: ServiceLevel.h:140
TypeServiceLevel()
Definition: ServiceLevel.h:134
ServiceLevelBase()
Definition: ServiceLevel.h:72
std::list< BinarySerializerCodecPtr > codecs
Definition: ServiceLevel.h:96
Typename channelType
Definition: ServiceLevel.h:160
Deserializer for serializing objects from XML format.
Definition: XMLSerializer.h:313