RefleX
Build DDS Applications in Modern C++ without IDL
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
type_manager.h
Go to the documentation of this file.
1 /*********************************************************************************************
2 (c) 2005-2014 Copyright, Real-Time Innovations, Inc. All rights reserved.
3 RTI grants Licensee a license to use, modify, compile, and create derivative works
4 of the Software. Licensee has the right to distribute object form only for use with RTI
5 products. The Software is provided "as is", with no warranty of any type, including
6 any warranty for fitness for any purpose. RTI is under no obligation to maintain or
7 support the Software. RTI shall not be liable for any incidental or consequential
8 damages arising out of the use or inability to use the software.
9 **********************************************************************************************/
10 
11 #ifndef RTI_REFLEX_TYPE_INFO_H
12 #define RTI_REFLEX_TYPE_INFO_H
13 
14 #include <memory>
15 
16 #include "reflex/safe_typecode.h"
17 
18 
19 namespace reflex
20 {
21  template <class T>
22  class SafeDynamicData;
23 
24  namespace detail {
25  class empty_deleter
26  {
27  public:
28  void operator () (DDSDynamicDataTypeSupport *) { }
29  };
30  }
31 
43  template <class T>
45  {
46  DDS_DynamicDataTypeProperty_t _props;
47  SafeTypeCode<T> _safe_typecode;
48  std::shared_ptr<DDSDynamicDataTypeSupport> _type_support;
49 
50  public:
56  explicit TypeManager(const DDS_DynamicDataTypeProperty_t & props =
57  DDS_DynamicDataTypeProperty_t())
58  : _props(props),
59  _safe_typecode(reflex::make_typecode<T>()),
60  _type_support(std::make_shared<DDSDynamicDataTypeSupport>(_safe_typecode.get(), _props))
61  { }
62 
69  TypeManager(DDSDynamicDataTypeSupport * support)
70  : _props(),
71  _safe_typecode(support->get_data_type()),
72  _type_support(support, detail::empty_deleter())
73  { }
74 
85  {
86  return SafeDynamicData<T>(_type_support.get(), src);
87  }
88 
96  T create_instance(const SafeDynamicData<T> & src) const
97  {
98  T t;
100  return t;
101  }
102 
106  DDS_DynamicDataTypeProperty_t & get_properties()
107  {
108  return _props;
109  }
110 
115  {
116  return _safe_typecode;
117  }
118 
122  DDS_TypeCode* get_typecode()
123  {
124  return _safe_typecode.get();
125  }
126 
130  DDSDynamicDataTypeSupport * get_type_support()
131  {
132  return _type_support.get();
133  }
137  const DDS_DynamicDataTypeProperty_t & get_properties() const
138  {
139  return _props;
140  }
141 
146  {
147  return _safe_typecode;
148  }
149 
153  const DDS_TypeCode* get_typecode() const
154  {
155  return _safe_typecode.get();
156  }
157 
161  const DDSDynamicDataTypeSupport * get_type_support() const
162  {
163  return _type_support.get();
164  }
165 
166  };
167 
168 } // namespace reflex
169 
170 
171 #endif // RTI_REFLEX_TYPE_INFO_H
172 
DDSDynamicDataTypeSupport * get_type_support()
Definition: type_manager.h:130
DDS_TypeCode * get_typecode()
Definition: type_manager.h:122
SafeTypeCode< T > make_typecode(const char *name)
Creates a TypeCode for structured type T.
Definition: reflex.h:175
Typesafe, exception-safe, poulated DynamicData.
Definition: reflex_fwd.h:24
Manage type-specific context, such as typecode, type-support, and dynamic data properties.
Definition: type_manager.h:44
SafeTypeCode< T > & get_safe_typecode()
Definition: type_manager.h:114
DDS_DynamicDataTypeProperty_t & get_properties()
Definition: type_manager.h:106
T create_instance(const SafeDynamicData< T > &src) const
Definition: type_manager.h:96
disable_if_lazy< reflex::type_traits::is_tuple< FusionSeq >::value, at< FusionSeq, I > >::type get(FusionSeq &seq)
Definition: enable_if.h:714
void read_dynamicdata(T &dest, const DDS_DynamicData &src)
Extracts data out from the source DDS_DynamicData instance and copies into the destination object of ...
Definition: reflex.h:186
const DDS_TypeCode * get_typecode() const
Definition: type_manager.h:153
TypeManager(const DDS_DynamicDataTypeProperty_t &props=DDS_DynamicDataTypeProperty_t())
Create a type manager that uses the argument properties to create all the DynamicData objects...
Definition: type_manager.h:56
TypeManager(DDSDynamicDataTypeSupport *support)
Create a type manager that uses the argument DynamicDataTypeSupport to create all the DynamicData obj...
Definition: type_manager.h:69
SafeDynamicData< T > create_dynamicdata(const T &src) const
Definition: type_manager.h:84
const SafeTypeCode< T > & get_safe_typecode() const
Definition: type_manager.h:145
A type-safe, exception-safe wrapper for DDS TypeCode.
Definition: reflex_fwd.h:27
const DDSDynamicDataTypeSupport * get_type_support() const
Definition: type_manager.h:161
const DDS_DynamicDataTypeProperty_t & get_properties() const
Definition: type_manager.h:137