OpenDDS  Snapshot(2023/04/28-20:55)
DynamicTypeSupport.h
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #ifndef OPENDDS_DCPS_XTYPES_DYNAMIC_TYPE_SUPPORT_H
7 #define OPENDDS_DCPS_XTYPES_DYNAMIC_TYPE_SUPPORT_H
8 
9 #ifndef OPENDDS_SAFETY_PROFILE
10 
11 #include <dds/DdsDynamicTypeSupportC.h>
12 #include <dds/DdsDcpsTypeSupportExtC.h>
13 
15 
16 #include "DynamicSample.h"
17 
19 
20 namespace DDS {
21  class DynamicTypeSupport;
22 }
23 
24 namespace OpenDDS {
25  namespace DCPS {
26  class DataReaderImpl;
27  class ReceivedDataElement;
28  }
29 
30  namespace XTypes {
33  : seq_(seq)
34  {}
35 
36  ACE_CDR::ULong max_slots() const { return seq_.maximum(); }
37  void internal_set_length(ACE_CDR::ULong len) { seq_.length(len); }
38 
40  {
41  seq_[i] = d.dynamic_data();
42  }
43 
47 
49  };
50  }
51 
52  namespace DCPS {
53  template <>
54  struct DDSTraits<XTypes::DynamicSample> {
63  static const char* type_name() { return "Dynamic"; } // used for logging
64  };
65 
66  template <>
67  struct MarshalTraits<XTypes::DynamicSample> {
68  static bool to_message_block(ACE_Message_Block&, const XTypes::DynamicSample&) { return false; }
69  static bool from_message_block(XTypes::DynamicSample&, const ACE_Message_Block&) { return false; }
70  };
71 
72  bool operator>>(Serializer& strm, XTypes::DynamicSample& sample);
73  bool operator>>(Serializer& strm, const KeyOnly<XTypes::DynamicSample>& sample);
74  }
75 }
76 
77 namespace DDS {
78 
80 
82 
84  : public virtual OpenDDS::DCPS::TypeSupportImpl
85  , public virtual DynamicTypeSupportInterf
86  {
87  public:
88  typedef DynamicTypeSupport_ptr _ptr_type;
89  typedef DynamicTypeSupport_var _var_type;
90 
91  explicit DynamicTypeSupport(DynamicType_ptr type)
92  : TypeSupportImpl(type)
93  , name_(type->get_name())
94  {
95  }
96 
97  virtual ~DynamicTypeSupport() {}
98 
99  const char* name() const
100  {
101  return name_.in();
102  }
103 
104  size_t key_count() const;
105  bool is_dcps_key(const char* field) const;
106 
107  void representations_allowed_by_type(DataRepresentationIdSeq& seq);
108 
109  OpenDDS::DCPS::Extensibility base_extensibility() const;
111 
113  {
115  }
116 
118  const OpenDDS::DCPS::Encoding&) const
119  {
121  }
122 
123  DataWriter_ptr create_datawriter();
124  DataReader_ptr create_datareader();
125 #ifndef OPENDDS_NO_MULTI_TOPIC
126  DataReader_ptr create_multitopic_datareader();
127 #endif
128 
130  const OpenDDS::XTypes::TypeMap& getMinimalTypeMap() const;
132  const OpenDDS::XTypes::TypeMap& getCompleteTypeMap() const;
133 
134  const OpenDDS::XTypes::TypeInformation* preset_type_info() const;
135 
136  DynamicType_ptr get_type()
137  {
138  return DynamicType::_duplicate(type_);
139  }
140 
141 #ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE
142  const OpenDDS::DCPS::MetaStruct& getMetaStructForType() const;
143 #endif
144 
145  CORBA::Boolean _is_a(const char* type_id)
146  {
147  return DynamicTypeSupportInterf::_is_a(type_id);
148  }
149 
150  const char* _interface_repository_id() const
151  {
152  return DynamicTypeSupportInterf::_interface_repository_id();
153  }
154 
156  {
157  return false;
158  }
159 
160  static DynamicTypeSupport_ptr _duplicate(DynamicTypeSupport_ptr obj);
161 
162  protected:
164  };
165 }
166 
168 
170 namespace TAO {
171  template <>
172  struct OpenDDS_Dcps_Export Objref_Traits<DDS::DynamicTypeSupport> {
174  static void release(DDS::DynamicTypeSupport_ptr p);
175  static DDS::DynamicTypeSupport_ptr nil();
177  };
178 }
180 
181 #endif // OPENDDS_SAFETY_PROFILE
182 
183 #endif // OPENDDS_DCPS_XTYPES_DYNAMIC_TYPE_SUPPORT_H
CORBA::Boolean operator>>(TAO_InputCDR &, CORBA::Object *&)
Definition: Object.cpp:333
CORBA::Boolean _is_a(const char *type_id)
#define TAO_BEGIN_VERSIONED_NAMESPACE_DECL
static bool to_message_block(ACE_Message_Block &, const XTypes::DynamicSample &)
const XTypes::TypeIdentifier & getCompleteTypeIdentifier()
TAO_Objref_Var_T< DynamicTypeSupport > DynamicTypeSupport_var
void release(T x)
const XTypes::TypeMap & getMinimalTypeMap()
DynamicTypeSupport(DynamicType_ptr type)
DCPS::KeyOnly< const XTypes::DynamicSample > KeyOnlyType
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
const char * name() const
sequence< DynamicData > DynamicDataSeq
sequence< DataRepresentationId_t > DataRepresentationIdSeq
DynamicTypeSupport * DynamicTypeSupport_ptr
T * _duplicate(T *st)
DynamicType_ptr get_type()
Class to serialize and deserialize data for DDS.
Definition: Serializer.h:369
DynamicTypeSupport_ptr _ptr_type
DynamicSequenceAdapter(DDS::DynamicDataSeq &seq)
ACE_CDR::Boolean Boolean
void assign_sample(ACE_CDR::ULong i, const DynamicSample &d)
void assign_ptr(ACE_CDR::ULong, const DCPS::ReceivedDataElement *)
OpenDDS::DCPS::SerializedSizeBound serialized_size_bound(const OpenDDS::DCPS::Encoding &) const
Implements the DDS::DataReader interface.
XTypes::DynamicSample::KeyLessThan LessThanType
DDS::DynamicData_var dynamic_data() const
Definition: DynamicSample.h:74
ACE_UINT32 ULong
const XTypes::TypeMap & getCompleteTypeMap()
The End User API.
CORBA::Boolean marshal(TAO_OutputCDR &)
const XTypes::TypeIdentifier & getMinimalTypeIdentifier()
TAO_AnyTypeCode_Export bool marshal(TAO_OutputCDR &cdr, CORBA::TypeCode_ptr tc, CORBA::ULong offset)
XTypes::DynamicSequenceAdapter MessageSequenceAdapterType
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
void set_loaner(DCPS::DataReaderImpl *)
DynamicTypeSupport_var _var_type
DDS::ReturnCode_t max_extensibility(DDS::DynamicType_ptr type, DCPS::Extensibility &ext)
#define TAO_END_VERSIONED_NAMESPACE_DECL
static bool from_message_block(XTypes::DynamicSample &, const ACE_Message_Block &)
OpenDDS::DCPS::SerializedSizeBound key_only_serialized_size_bound(const OpenDDS::DCPS::Encoding &) const
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
DDS::ReturnCode_t key_count(DDS::DynamicType_ptr type, size_t &count)
const char * _interface_repository_id() const
void internal_set_length(ACE_CDR::ULong len)