CoreDX DDS C++ Reference Manual
dds_dtype.hh
Go to the documentation of this file.
1 /*****************************************************************
2  * file: dds_dtype.hh
3  * desc: CDX DynamicType support for C++
4  * NOTE: this API is deprecated. The preferred
5  * DynamicType API is provided in xtypes_dtype.h
6  *
7  *****************************************************************
8  *
9  * Copyright(C) 2011-2016 Twin Oaks Computing, Inc
10  * All rights reserved. Castle Rock, CO 80108
11  *
12  *****************************************************************
13  *
14  * This software has been provided pursuant to a License Agreement
15  * containing restrictions on its use. This software contains
16  * valuable trade secrets and proprietary information of
17  * Twin Oaks Computing, Inc and is protected by law. It may not be
18  * copied or distributed in any form or medium, disclosed to third
19  * parties, reverse engineered or used in any manner not provided
20  * for in said License Agreement except with the prior written
21  * authorization from Twin Oaks Computing, Inc.
22  *
23  *****************************************************************/
24 
25 #ifndef _DDS_DTYPE_HH
26 #define _DDS_DTYPE_HH
27 
28 #include <dds/dds.h>
29 #include <dds/dds_dtype.h>
30 #include <dds/dds_seq.hh>
31 
38 namespace CDX
39 {
40  class DynamicType;
41  class DynamicTypeTypeSupport;
42  class DynamicTypeDataReader;
43  class DynamicTypeDataWriter;
44  class CoreDX_DynamicType;
45  class CoreDX_StructDynamicType;
46 
47  DECLARE_CPP_UNBOUNDED_SEQ( DynamicType *, DynamicTypePtrSeq );
48 
49  typedef enum {
50  TYPECODE_NULL=0,
74  } TypeCodeKind;
75 
76 
77 
78  // -------------------------------------------------------------
79  // Dynamic Type
80  // -------------------------------------------------------------
81 
97  class COREDX_CPP_CLASS_API DynamicType {
98  public:
103  virtual TypeCodeKind get_type( );
104  static DDS::TypeSupport * create_typesupport(DynamicType * dt);
105  static void delete_typesupport(DDS::TypeSupport *ts);
106  protected:
107  DynamicType();
108  virtual ~DynamicType();
109  CoreDX_DynamicType * _impl;
110  friend class CoreDX_DynamicType;
111  };
112 
116  class COREDX_CPP_CLASS_API OctetDynamicType : public DynamicType {
117  public:
119  virtual ~OctetDynamicType();
120 
125  unsigned char get_octet( );
131  DDS::ReturnCode_t set_octet( unsigned char c );
132  private:
133  };
134 
138  class COREDX_CPP_CLASS_API BooleanDynamicType : public DynamicType {
139  public:
141  virtual ~BooleanDynamicType();
146  unsigned char get_boolean( );
152  DDS::ReturnCode_t set_boolean( unsigned char c );
153  private:
154  };
155 
159  class COREDX_CPP_CLASS_API CharDynamicType : public DynamicType {
160  public:
161  CharDynamicType();
162  virtual ~CharDynamicType();
167  char get_char( );
173  DDS::ReturnCode_t set_char( char c );
174  private:
175  };
176 
180  class COREDX_CPP_CLASS_API ShortDynamicType : public DynamicType {
181  public:
183  virtual ~ShortDynamicType();
188  int16_t get_short( );
194  DDS::ReturnCode_t set_short( short c );
195  private:
196  };
197 
201  class COREDX_CPP_CLASS_API UShortDynamicType : public DynamicType {
202  public:
204  virtual ~UShortDynamicType();
209  uint16_t get_ushort( );
215  DDS::ReturnCode_t set_ushort( unsigned short c );
216  private:
217  };
218 
222  class COREDX_CPP_CLASS_API LongDynamicType : public DynamicType {
223  public:
224  LongDynamicType();
225  virtual ~LongDynamicType();
230  int32_t get_long( );
236  DDS::ReturnCode_t set_long( int32_t c );
237  private:
238  };
239 
243  class COREDX_CPP_CLASS_API ULongDynamicType : public DynamicType {
244  public:
246  virtual ~ULongDynamicType();
251  uint32_t get_ulong( );
257  DDS::ReturnCode_t set_ulong( uint32_t c );
258  private:
259  };
260 
264  class COREDX_CPP_CLASS_API LongLongDynamicType : public DynamicType {
265  public:
267  virtual ~LongLongDynamicType();
272  int64_t get_longlong( );
278  DDS::ReturnCode_t set_longlong( int64_t c );
279  private:
280  };
281 
285  class COREDX_CPP_CLASS_API ULongLongDynamicType : public DynamicType {
286  public:
288  virtual ~ULongLongDynamicType();
293  uint64_t get_ulonglong( );
299  DDS::ReturnCode_t set_ulonglong( uint64_t c );
300  private:
301  };
302 
306  class COREDX_CPP_CLASS_API FloatDynamicType : public DynamicType {
307  public:
309  virtual ~FloatDynamicType();
314  float get_float( );
320  DDS::ReturnCode_t set_float( float c );
321  private:
322  };
323 
327  class COREDX_CPP_CLASS_API DoubleDynamicType : public DynamicType {
328  public:
330  virtual ~DoubleDynamicType();
335  double get_double( );
341  DDS::ReturnCode_t set_double( double c );
342  private:
343  };
344 
348  class COREDX_CPP_CLASS_API StringDynamicType : public DynamicType {
349  public:
351  virtual ~StringDynamicType();
356  const char * get_string( );
357 
367  uint32_t get_max_length( );
375  uint32_t get_length( );
376 
386  DDS::ReturnCode_t set_string( const char * c );
394  DDS::ReturnCode_t set_max_length( uint32_t n );
395  private:
396  };
397 
401  class COREDX_CPP_CLASS_API ArrayDynamicType : public DynamicType {
402  public:
404  virtual ~ArrayDynamicType();
410  DDS::ReturnCode_t set_element_type( DynamicType * e );
418  DynamicType * get_element_type( );
426  DDS::ReturnCode_t set_element( uint32_t n, DynamicType * e );
434  DynamicType * get_element( uint32_t n );
442  DDS::ReturnCode_t set_max_length( uint32_t n );
456  DDS::ReturnCode_t set_length( uint32_t n );
464  uint32_t get_length( );
465  private:
466  friend class CoreDX_DynamicType;
467  };
468 
472  class COREDX_CPP_CLASS_API SequenceDynamicType : public DynamicType {
473  public:
475  virtual ~SequenceDynamicType();
483  uint32_t get_length( );
491  DynamicType * get_element_type( );
499  DynamicType * get_element( uint32_t n );
507  DDS::ReturnCode_t set_max_length( uint32_t n );
521  DDS::ReturnCode_t set_length( uint32_t n );
527  DDS::ReturnCode_t set_element_type( DynamicType * e );
535  DDS::ReturnCode_t set_element( uint32_t n, DynamicType * e );
536  private:
537  friend class CoreDX_DynamicType;
538  };
539 
543  class COREDX_CPP_CLASS_API EnumConstant {
544  public:
545  ~EnumConstant();
546  char * name;
547  uint32_t value;
548  private:
549  EnumConstant();
550  friend class CoreDX_DynamicType;
551  };
552 
556  class COREDX_CPP_CLASS_API EnumDynamicType : public DynamicType {
557  public:
558  EnumDynamicType();
559  ~EnumDynamicType();
560 
561  DDS::ReturnCode_t set_num_constants ( int32_t n );
562  DDS::ReturnCode_t set_constant ( int32_t n, const char *name, uint32_t val );
563  DDS::ReturnCode_t set_value ( uint32_t c );
565  int32_t get_num_constants ( void );
566  EnumConstant * get_constant (int32_t index );
567  EnumConstant * get_constant_by_name ( const char *name );
568  EnumConstant * get_constant_by_value ( uint32_t val );
569  uint32_t get_value ( void );
570  private:
571  friend class CoreDX_DynamicType;
572  };
573 
574 
578  class COREDX_CPP_CLASS_API StructDynamicType : public DynamicType {
579  public:
581  virtual ~StructDynamicType();
590  uint32_t get_num_fields( );
597  DynamicType * get_field( uint32_t n );
604  const char * get_field_name( uint32_t n );
605 
613  unsigned char get_field_key( uint32_t n );
619  DDS::ReturnCode_t set_num_fields( uint32_t n );
633  DDS::ReturnCode_t set_field( uint32_t n, const char * field_name,
634  DynamicType * e, unsigned char key );
635 
636  private:
637  friend class CoreDX_DynamicType;
638  };
639 
643  class COREDX_CPP_CLASS_API UnionDynamicType : public DynamicType {
644  public:
646  virtual ~UnionDynamicType();
655  uint32_t get_num_fields( );
662  DynamicType * get_field( uint32_t n );
669  const char * get_field_name( uint32_t n );
676  DynamicType * get_discriminator( );
684  int32_t get_default_field( ); /* -1 indicates no default case */
692  uint32_t get_field_num_labels( uint32_t field );
701  int32_t get_field_label( uint32_t field, uint32_t label );
709  DynamicType * get_selected_field( void );
710 
716  DDS::ReturnCode_t set_num_fields( uint32_t n );
728  DDS::ReturnCode_t set_field( uint32_t n, const char * field_name, DynamicType * e );
744  DDS::ReturnCode_t set_discriminator( DynamicType * d );
755  DDS::ReturnCode_t set_default_field( int32_t field ); /* -1 indicates no default case */
770  DDS::ReturnCode_t set_field_num_labels( uint32_t field, uint32_t n );
778  DDS::ReturnCode_t set_field_label( uint32_t field, uint32_t label, int32_t val );
779  private:
780  friend class CoreDX_DynamicType;
781  };
782 
783  // -------------------------------------------------------------
784  // Dynamic Type DataReader
785  // -------------------------------------------------------------
792  class COREDX_CPP_CLASS_API DynamicTypeDataReader : public DDS::DataReader
793  {
794  public:
795  /* DataReader Methods */
796  DDS::ReturnCode_t read( DynamicTypePtrSeq * received_data,
797  DDS::SampleInfoSeq * sample_infos,
798  int max_samples,
799  DDS::SampleStateMask sample_states,
800  DDS::ViewStateMask view_states,
801  DDS::InstanceStateMask instance_states );
802  DDS::ReturnCode_t take( DynamicTypePtrSeq * received_data,
803  DDS::SampleInfoSeq * sample_infos,
804  int max_samples,
805  DDS::SampleStateMask sample_states,
806  DDS::ViewStateMask view_states,
807  DDS::InstanceStateMask instance_states );
808  DDS::ReturnCode_t read_w_condition ( DynamicTypePtrSeq * received_data,
809  DDS::SampleInfoSeq * sample_infos,
810  int max_samples,
811  DDS::ReadCondition * a_condition);
812  DDS::ReturnCode_t take_w_condition ( DynamicTypePtrSeq * received_data,
813  DDS::SampleInfoSeq * sample_infos,
814  int max_samples,
815  DDS::ReadCondition * a_condition);
816  DDS::ReturnCode_t read_next_sample ( DynamicType * received_data,
817  DDS::SampleInfo * sample_info);
818  DDS::ReturnCode_t take_next_sample ( DynamicType * received_data,
819  DDS::SampleInfo * sample_info);
820  DDS::ReturnCode_t read_instance ( DynamicTypePtrSeq * received_data,
821  DDS::SampleInfoSeq * sample_infos,
822  int max_samples,
823  DDS::InstanceHandle_t a_handle,
824  DDS::SampleStateMask sample_states,
825  DDS::ViewStateMask view_states,
826  DDS::InstanceStateMask instance_states);
827  DDS::ReturnCode_t take_instance ( DynamicTypePtrSeq * received_data,
828  DDS::SampleInfoSeq * sample_infos,
829  int max_samples,
830  DDS::InstanceHandle_t a_handle,
831  DDS::SampleStateMask sample_states,
832  DDS::ViewStateMask view_states,
833  DDS::InstanceStateMask instance_states);
834  DDS::ReturnCode_t read_next_instance ( DynamicTypePtrSeq * received_data,
835  DDS::SampleInfoSeq * sample_infos,
836  int max_samples,
837  DDS::InstanceHandle_t previous_handle,
838  DDS::SampleStateMask sample_states,
839  DDS::ViewStateMask view_states,
840  DDS::InstanceStateMask instance_states);
841  DDS::ReturnCode_t take_next_instance ( DynamicTypePtrSeq * received_data,
842  DDS::SampleInfoSeq * sample_infos,
843  int max_samples,
844  DDS::InstanceHandle_t previous_handle,
845  DDS::SampleStateMask sample_states,
846  DDS::ViewStateMask view_states,
847  DDS::InstanceStateMask instance_states);
848  DDS::ReturnCode_t read_next_instance_w_condition( DynamicTypePtrSeq * received_data,
849  DDS::SampleInfoSeq * sample_infos,
850  int max_samples,
851  DDS::InstanceHandle_t previous_handle,
852  DDS::ReadCondition * a_condition);
853  DDS::ReturnCode_t take_next_instance_w_condition( DynamicTypePtrSeq * received_data,
854  DDS::SampleInfoSeq * sample_infos,
855  int max_samples,
856  DDS::InstanceHandle_t previous_handle,
857  DDS::ReadCondition * a_condition);
858  DDS::ReturnCode_t return_loan ( DynamicTypePtrSeq * received_data,
859  DDS::SampleInfoSeq * sample_infos);
860  DDS::ReturnCode_t get_key_value ( DynamicType * key_holder,
861  DDS::InstanceHandle_t handle);
862  DDS::InstanceHandle_t lookup_instance ( DynamicType * instance_data);
863  static DynamicTypeDataReader * narrow( DDS::DataReader * dr) { return (DynamicTypeDataReader *)dr; }
864  DynamicTypeDataReader * narrow( void ) { return this; }
865 
866  private:
867  /* Constructor / Destructor private - use Subscriber::create_datareader() */
869  ~DynamicTypeDataReader() {};
870  friend class DynamicTypeTypeSupport;
871  };
872 
873  // -------------------------------------------------------------
874  // Dynamic Type DataWriter
875  // -------------------------------------------------------------
881  class COREDX_CPP_CLASS_API DynamicTypeDataWriter : public DDS::DataWriter {
882  public:
883  /* DataWriter Methods */
884  DDS::InstanceHandle_t register_instance( const DynamicType * instance_data);
885  DDS::InstanceHandle_t register_instance_w_timestamp( const DynamicType * instance_data,
886  const DDS::Time_t source_timestamp);
887  DDS::ReturnCode_t unregister_instance( const DynamicType * instance_data,
888  const DDS::InstanceHandle_t handle);
889  DDS::ReturnCode_t unregister_instance_w_timestamp( const DynamicType * instance_data,
890  const DDS::InstanceHandle_t handle,
891  const DDS::Time_t source_timestamp);
892  DDS::ReturnCode_t write( const DynamicType * instance_data,
893  const DDS::InstanceHandle_t handle);
894  DDS::ReturnCode_t write_w_timestamp( const DynamicType * instance_data,
895  const DDS::InstanceHandle_t handle,
896  const DDS::Time_t source_timestamp);
897  DDS::ReturnCode_t dispose( const DynamicType * instance_data,
898  const DDS::InstanceHandle_t instance_handle);
899  DDS::ReturnCode_t dispose_w_timestamp( const DynamicType * instance_data,
900  const DDS::InstanceHandle_t instance_handle,
901  const DDS::Time_t source_timestamp);
902  DDS::ReturnCode_t get_key_value( DynamicType * key_holder,
903  const DDS::InstanceHandle_t handle);
904  DDS::InstanceHandle_t lookup_instance( const DynamicType * instance_data);
905  static DynamicTypeDataWriter * narrow( DDS::DataWriter * dw) { return (DynamicTypeDataWriter *)dw; }
906  DynamicTypeDataWriter * narrow( void ) { return this; }
907 
908  private:
909  /* Constructor / Destructor private -- use Publisher::create_datawriter() */
911  ~DynamicTypeDataWriter() {};
912  friend class DynamicTypeTypeSupport;
913  };
914 
915 }
916 #endif
Contains a long.
Definition: dds_dtype.hh:222
long ReturnCode_t
Definition: dds.hh:200
Definition: dds_dtype.hh:59
Definition: dds_dtype.hh:65
The DataWriter entity provides an interface for the application to publish (write) data...
Definition: dds.hh:2179
Definition: dds_dtype.hh:52
Definition: dds_dtype.hh:66
Contains a long long.
Definition: dds_dtype.hh:264
Definition: dds_dtype.hh:67
Definition: dds_dtype.hh:56
Definition: dds_dtype.hh:55
Definition: dds_dtype.hh:51
Contains an unsigned long.
Definition: dds_dtype.hh:243
Definition: dds_dtype.hh:62
Definition: dds_dtype.hh:53
Contains a double.
Definition: dds_dtype.hh:327
uint32_t value
Definition: dds_dtype.hh:547
Definition: dds_dtype.hh:73
Contains a char.
Definition: dds_dtype.hh:159
Represents a struct of members. Each member has an associated data type.
Definition: dds_dtype.hh:578
Definition: dds_dtype.hh:70
A ReadCondition is a specialized Condition associated with a DataReader.
Definition: dds.hh:3057
Definition: dds_dtype.hh:61
The DataReader entity allows the application to subscribe to and read data.
Definition: dds.hh:2466
Represents an enum (set of constants)
Definition: dds_dtype.hh:556
Definition: dds_dtype.hh:69
Definition: dds_dtype.hh:60
Contains an array.
Definition: dds_dtype.hh:401
A DataWriter that writes &#39;DynamicType&#39; data elements. Data written by this DataWriter can be read by ...
Definition: dds_dtype.hh:881
Contains an unsigned short.
Definition: dds_dtype.hh:201
Represents a union.
Definition: dds_dtype.hh:643
char * name
Definition: dds_dtype.hh:546
Represents an enum constant value.
Definition: dds_dtype.hh:543
Definition: dds_dtype.hh:64
Contains a boolean.
Definition: dds_dtype.hh:138
DynamicType is an object that enhances CoreDX DDS with the facilities to process dynamic data types (...
Definition: dds_dtype.hh:97
Contains an octet.
Definition: dds_dtype.hh:116
Definition: dds_dtype.hh:68
Contains a float.
Definition: dds_dtype.hh:306
Definition: dds_dtype.hh:54
Definition: dds_dtype.hh:71
Definition: dds_dtype.hh:63
TypeCodeKind
Definition: dds_dtype.hh:49
DDS_HANDLE_TYPE_NATIVE InstanceHandle_t
Definition: dds.hh:199
Definition: dds_dtype.hh:57
Contains a sequence.
Definition: dds_dtype.hh:472
The Time_t structure contains data to define a time.
Definition: dds.hh:214
Definition: dds_dtype.hh:58
Definition: dds_dtype.hh:38
A DataReader that reads &#39;DynamicType&#39; data elements A DynamicTypeDataReader can read data published b...
Definition: dds_dtype.hh:792
Contains a short.
Definition: dds_dtype.hh:180
Contains an unsigned long long.
Definition: dds_dtype.hh:285
Contains a string.
Definition: dds_dtype.hh:348
Definition: dds_dtype.hh:72

© 2009-2017 Twin Oaks Computing, Inc
Castle Rock, CO 80108
All rights reserved.