00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _DDS_DTYPE_HH
00024 #define _DDS_DTYPE_HH
00025
00026 #include <dds/dds.h>
00027 #include <dds/dds_dtype.h>
00028 #include <dds/dds_seq.hh>
00029
00035 namespace DDS
00036 {
00037 class DynamicType;
00038 class DynamicTypeTypeSupport;
00039 class DynamicTypeDataReader;
00040 class DynamicTypeDataWriter;
00041 class CoreDX_DynamicType;
00042 class CoreDX_StructDynamicType;
00043
00044 DECLARE_CPP_UNBOUNDED_SEQ( DynamicType *, DynamicTypePtrSeq );
00045
00046 typedef enum {
00047 TYPECODE_NULL=0,
00048 TYPECODE_SHORT,
00049 TYPECODE_LONG,
00050 TYPECODE_USHORT,
00051 TYPECODE_ULONG,
00052 TYPECODE_FLOAT,
00053 TYPECODE_DOUBLE,
00054 TYPECODE_BOOLEAN,
00055 TYPECODE_CHAR,
00056 TYPECODE_OCTET,
00057 TYPECODE_STRUCT,
00058 TYPECODE_UNION,
00059 TYPECODE_ENUM,
00060 TYPECODE_STRING,
00061 TYPECODE_SEQUENCE,
00062 TYPECODE_ARRAY,
00063 TYPECODE_ALIAS,
00064 TYPECODE_LONGLONG,
00065 TYPECODE_ULONGLONG,
00066 TYPECODE_LONGDOUBLE,
00067 TYPECODE_WCHAR,
00068 TYPECODE_WSTRING,
00069 TYPECODE_VALUE,
00070 TYPECODE_VALUE_PARAM
00071 } TypeCodeKind;
00072
00073
00074
00075
00076
00077
00078
00094 class COREDX_CPP_CLASS_API DynamicType {
00095 public:
00100 virtual TypeCodeKind get_type( );
00101 static TypeSupport * create_typesupport(DynamicType * dt);
00102 static void delete_typesupport( TypeSupport *ts);
00103 protected:
00104 DynamicType();
00105 virtual ~DynamicType();
00106 CoreDX_DynamicType * _impl;
00107 friend class CoreDX_DynamicType;
00108 };
00109
00113 class COREDX_CPP_CLASS_API OctetDynamicType : public DynamicType {
00114 public:
00115 OctetDynamicType();
00116 virtual ~OctetDynamicType();
00117
00122 unsigned char get_octet( );
00128 ReturnCode_t set_octet( unsigned char c );
00129 private:
00130 };
00131
00135 class COREDX_CPP_CLASS_API BooleanDynamicType : public DynamicType {
00136 public:
00137 BooleanDynamicType();
00138 virtual ~BooleanDynamicType();
00143 unsigned char get_boolean( );
00149 ReturnCode_t set_boolean( unsigned char c );
00150 private:
00151 };
00152
00156 class COREDX_CPP_CLASS_API CharDynamicType : public DynamicType {
00157 public:
00158 CharDynamicType();
00159 virtual ~CharDynamicType();
00164 char get_char( );
00170 ReturnCode_t set_char( char c );
00171 private:
00172 };
00173
00177 class COREDX_CPP_CLASS_API ShortDynamicType : public DynamicType {
00178 public:
00179 ShortDynamicType();
00180 virtual ~ShortDynamicType();
00185 int16_t get_short( );
00191 ReturnCode_t set_short( short c );
00192 private:
00193 };
00194
00198 class COREDX_CPP_CLASS_API UShortDynamicType : public DynamicType {
00199 public:
00200 UShortDynamicType();
00201 virtual ~UShortDynamicType();
00206 uint16_t get_ushort( );
00212 ReturnCode_t set_ushort( unsigned short c );
00213 private:
00214 };
00215
00219 class COREDX_CPP_CLASS_API LongDynamicType : public DynamicType {
00220 public:
00221 LongDynamicType();
00222 virtual ~LongDynamicType();
00227 int32_t get_long( );
00233 ReturnCode_t set_long( int32_t c );
00234 private:
00235 };
00236
00240 class COREDX_CPP_CLASS_API ULongDynamicType : public DynamicType {
00241 public:
00242 ULongDynamicType();
00243 virtual ~ULongDynamicType();
00248 uint32_t get_ulong( );
00254 ReturnCode_t set_ulong( uint32_t c );
00255 private:
00256 };
00257
00261 class COREDX_CPP_CLASS_API LongLongDynamicType : public DynamicType {
00262 public:
00263 LongLongDynamicType();
00264 virtual ~LongLongDynamicType();
00269 int64_t get_longlong( );
00275 ReturnCode_t set_longlong( int64_t c );
00276 private:
00277 };
00278
00282 class COREDX_CPP_CLASS_API ULongLongDynamicType : public DynamicType {
00283 public:
00284 ULongLongDynamicType();
00285 virtual ~ULongLongDynamicType();
00290 uint64_t get_ulonglong( );
00296 ReturnCode_t set_ulonglong( uint64_t c );
00297 private:
00298 };
00299
00303 class COREDX_CPP_CLASS_API FloatDynamicType : public DynamicType {
00304 public:
00305 FloatDynamicType();
00306 virtual ~FloatDynamicType();
00311 float get_float( );
00317 ReturnCode_t set_float( float c );
00318 private:
00319 };
00320
00324 class COREDX_CPP_CLASS_API DoubleDynamicType : public DynamicType {
00325 public:
00326 DoubleDynamicType();
00327 virtual ~DoubleDynamicType();
00332 double get_double( );
00338 ReturnCode_t set_double( double c );
00339 private:
00340 };
00341
00345 class COREDX_CPP_CLASS_API StringDynamicType : public DynamicType {
00346 public:
00347 StringDynamicType();
00348 virtual ~StringDynamicType();
00353 const char * get_string( );
00354
00364 uint32_t get_max_length( );
00372 uint32_t get_length( );
00373
00383 ReturnCode_t set_string( const char * c );
00391 ReturnCode_t set_max_length( uint32_t n );
00392 private:
00393 };
00394
00398 class COREDX_CPP_CLASS_API ArrayDynamicType : public DynamicType {
00399 public:
00400 ArrayDynamicType();
00401 virtual ~ArrayDynamicType();
00407 ReturnCode_t set_element_type( DynamicType * e );
00415 DynamicType * get_element_type( );
00423 ReturnCode_t set_element( uint32_t n, DynamicType * e );
00431 DynamicType * get_element( uint32_t n );
00439 ReturnCode_t set_max_length( uint32_t n );
00453 ReturnCode_t set_length( uint32_t n );
00461 uint32_t get_length( );
00462 private:
00463 friend class CoreDX_DynamicType;
00464 };
00465
00469 class COREDX_CPP_CLASS_API SequenceDynamicType : public DynamicType {
00470 public:
00471 SequenceDynamicType();
00472 virtual ~SequenceDynamicType();
00480 uint32_t get_length( );
00488 DynamicType * get_element_type( );
00496 DynamicType * get_element( uint32_t n );
00504 ReturnCode_t set_max_length( uint32_t n );
00518 ReturnCode_t set_length( uint32_t n );
00524 ReturnCode_t set_element_type( DynamicType * e );
00532 ReturnCode_t set_element( uint32_t n, DynamicType * e );
00533 private:
00534 friend class CoreDX_DynamicType;
00535 };
00536
00540 class COREDX_CPP_CLASS_API EnumConstant {
00541 public:
00542 ~EnumConstant();
00543 char * name;
00544 uint32_t value;
00545 private:
00546 EnumConstant();
00547 friend class CoreDX_DynamicType;
00548 };
00549
00553 class COREDX_CPP_CLASS_API EnumDynamicType : public DynamicType {
00554 public:
00555 EnumDynamicType();
00556 ~EnumDynamicType();
00557
00558 ReturnCode_t set_num_constants ( int32_t n );
00559 ReturnCode_t set_constant ( int32_t n, const char *name, uint32_t val );
00560 ReturnCode_t set_value ( uint32_t c );
00562 int32_t get_num_constants ( void );
00563 EnumConstant * get_constant (int32_t index );
00564 EnumConstant * get_constant_by_name ( const char *name );
00565 EnumConstant * get_constant_by_value ( uint32_t val );
00566 uint32_t get_value ( void );
00567 private:
00568 friend class CoreDX_DynamicType;
00569 };
00570
00571
00575 class COREDX_CPP_CLASS_API StructDynamicType : public DynamicType {
00576 public:
00577 StructDynamicType();
00578 virtual ~StructDynamicType();
00587 uint32_t get_num_fields( );
00594 DynamicType * get_field( uint32_t n );
00601 const char * get_field_name( uint32_t n );
00602
00610 unsigned char get_field_key( uint32_t n );
00616 ReturnCode_t set_num_fields( uint32_t n );
00630 ReturnCode_t set_field( uint32_t n, const char * field_name,
00631 DynamicType * e, unsigned char key );
00632
00633 private:
00634 friend class CoreDX_DynamicType;
00635 };
00636
00640 class COREDX_CPP_CLASS_API UnionDynamicType : public DynamicType {
00641 public:
00642 UnionDynamicType();
00643 virtual ~UnionDynamicType();
00652 uint32_t get_num_fields( );
00659 DynamicType * get_field( uint32_t n );
00666 const char * get_field_name( uint32_t n );
00673 DynamicType * get_discriminator( );
00681 int32_t get_default_field( );
00689 uint32_t get_field_num_labels( uint32_t field );
00698 int32_t get_field_label( uint32_t field, uint32_t label );
00706 DynamicType * get_selected_field( void );
00707
00713 ReturnCode_t set_num_fields( uint32_t n );
00725 ReturnCode_t set_field( uint32_t n, const char * field_name, DynamicType * e );
00741 ReturnCode_t set_discriminator( DynamicType * d );
00752 ReturnCode_t set_default_field( int32_t field );
00767 ReturnCode_t set_field_num_labels( uint32_t field, uint32_t n );
00775 ReturnCode_t set_field_label( uint32_t field, uint32_t label, int32_t val );
00776 private:
00777 friend class CoreDX_DynamicType;
00778 };
00779
00780
00781
00782
00789 class COREDX_CPP_CLASS_API DynamicTypeDataReader : public DataReader
00790 {
00791 public:
00792
00793 ReturnCode_t read( DynamicTypePtrSeq * received_data,
00794 SampleInfoSeq * sample_infos,
00795 int max_samples,
00796 SampleStateMask sample_states,
00797 ViewStateMask view_states,
00798 InstanceStateMask instance_states );
00799 ReturnCode_t take( DynamicTypePtrSeq * received_data,
00800 SampleInfoSeq * sample_infos,
00801 int max_samples,
00802 SampleStateMask sample_states,
00803 ViewStateMask view_states,
00804 InstanceStateMask instance_states );
00805 ReturnCode_t read_w_condition ( DynamicTypePtrSeq * received_data,
00806 SampleInfoSeq * sample_infos,
00807 int max_samples,
00808 ReadCondition * a_condition);
00809 ReturnCode_t take_w_condition ( DynamicTypePtrSeq * received_data,
00810 SampleInfoSeq * sample_infos,
00811 int max_samples,
00812 ReadCondition * a_condition);
00813 ReturnCode_t read_next_sample ( DynamicType * received_data,
00814 SampleInfo * sample_info);
00815 ReturnCode_t take_next_sample ( DynamicType * received_data,
00816 SampleInfo * sample_info);
00817 ReturnCode_t read_instance ( DynamicTypePtrSeq * received_data,
00818 SampleInfoSeq * sample_infos,
00819 int max_samples,
00820 InstanceHandle_t a_handle,
00821 SampleStateMask sample_states,
00822 ViewStateMask view_states,
00823 InstanceStateMask instance_states);
00824 ReturnCode_t take_instance ( DynamicTypePtrSeq * received_data,
00825 SampleInfoSeq * sample_infos,
00826 int max_samples,
00827 InstanceHandle_t a_handle,
00828 SampleStateMask sample_states,
00829 ViewStateMask view_states,
00830 InstanceStateMask instance_states);
00831 ReturnCode_t read_next_instance ( DynamicTypePtrSeq * received_data,
00832 SampleInfoSeq * sample_infos,
00833 int max_samples,
00834 InstanceHandle_t previous_handle,
00835 SampleStateMask sample_states,
00836 ViewStateMask view_states,
00837 InstanceStateMask instance_states);
00838 ReturnCode_t take_next_instance ( DynamicTypePtrSeq * received_data,
00839 SampleInfoSeq * sample_infos,
00840 int max_samples,
00841 InstanceHandle_t previous_handle,
00842 SampleStateMask sample_states,
00843 ViewStateMask view_states,
00844 InstanceStateMask instance_states);
00845 ReturnCode_t read_next_instance_w_condition( DynamicTypePtrSeq * received_data,
00846 SampleInfoSeq * sample_infos,
00847 int max_samples,
00848 InstanceHandle_t previous_handle,
00849 ReadCondition * a_condition);
00850 ReturnCode_t take_next_instance_w_condition( DynamicTypePtrSeq * received_data,
00851 SampleInfoSeq * sample_infos,
00852 int max_samples,
00853 InstanceHandle_t previous_handle,
00854 ReadCondition * a_condition);
00855 ReturnCode_t return_loan ( DynamicTypePtrSeq * received_data,
00856 SampleInfoSeq * sample_infos);
00857 ReturnCode_t get_key_value ( DynamicType * key_holder,
00858 InstanceHandle_t handle);
00859 InstanceHandle_t lookup_instance ( DynamicType * instance_data);
00860 static DynamicTypeDataReader * narrow( DataReader * dr) { return (DynamicTypeDataReader *)dr; }
00861 DynamicTypeDataReader * narrow( void ) { return this; }
00862
00863 private:
00864
00865 DynamicTypeDataReader();
00866 ~DynamicTypeDataReader() {};
00867 friend class DynamicTypeTypeSupport;
00868 };
00869
00870
00871
00872
00878 class COREDX_CPP_CLASS_API DynamicTypeDataWriter : public DataWriter {
00879 public:
00880
00881 InstanceHandle_t register_instance( const DynamicType * instance_data);
00882 InstanceHandle_t register_instance_w_timestamp( const DynamicType * instance_data,
00883 const Time_t source_timestamp);
00884 ReturnCode_t unregister_instance( const DynamicType * instance_data,
00885 const InstanceHandle_t handle);
00886 ReturnCode_t unregister_instance_w_timestamp( const DynamicType * instance_data,
00887 const InstanceHandle_t handle,
00888 const Time_t source_timestamp);
00889 ReturnCode_t write( const DynamicType * instance_data,
00890 const InstanceHandle_t handle);
00891 ReturnCode_t write_w_timestamp( const DynamicType * instance_data,
00892 const InstanceHandle_t handle,
00893 const Time_t source_timestamp);
00894 ReturnCode_t dispose( const DynamicType * instance_data,
00895 const InstanceHandle_t instance_handle);
00896 ReturnCode_t dispose_w_timestamp( const DynamicType * instance_data,
00897 const InstanceHandle_t instance_handle,
00898 const Time_t source_timestamp);
00899 ReturnCode_t get_key_value( DynamicType * key_holder,
00900 const InstanceHandle_t handle);
00901 InstanceHandle_t lookup_instance( const DynamicType * instance_data);
00902 static DynamicTypeDataWriter * narrow( DataWriter * dw) { return (DynamicTypeDataWriter *)dw; }
00903 DynamicTypeDataWriter * narrow( void ) { return this; }
00904
00905 private:
00906
00907 DynamicTypeDataWriter();
00908 ~DynamicTypeDataWriter() {};
00909 friend class DynamicTypeTypeSupport;
00910 };
00911
00912 }
00913 #endif