CoreDX Data Distribution Service
The High Performance, Small Footprint DDS from Twin Oaks Computing, Inc
dds_dtype.h
Go to the documentation of this file.
1 /*****************************************************************
2  *
3  * file: dds_dtype.h
4  * desc: CDX Dynamic Type API.
5  * NOTE: this API is deprecated. The preferred
6  * DynamicType API is provided in xtypes_dtype.h
7  *
8  *****************************************************************
9  *
10  * Copyright(C) 2010-2020 Twin Oaks Computing, Inc
11  * All rights reserved. Castle Rock, CO 80108
12  *
13  *****************************************************************
14  *
15  * This software has been provided pursuant to a License Agreement
16  * containing restrictions on its use. This software contains
17  * valuable trade secrets and proprietary information of
18  * Twin Oaks Computing, Inc and is protected by law. It may not be
19  * copied or distributed in any form or medium, disclosed to third
20  * parties, reverse engineered or used in any manner not provided
21  * for in said License Agreement except with the prior written
22  * authorization from Twin Oaks Computing, Inc.
23  *
24  *****************************************************************/
25 #ifndef COREDX_DYNTYPE_H
26 #define COREDX_DYNTYPE_H
27 
28 #include <dds/dds_types.h>
29 #include <dds/dds_typecode.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 
35  typedef struct _TypeDefinition * CDX_TypeDefinition;
36  typedef struct cdx_DynamicType * CDX_DynamicType;
37 
55  typedef struct CDX_DynamicType_EnumConstant {
56  char * name;
57  uint32_t value;
58  } CDX_DynamicType_EnumConstant_t;
59 
60  typedef struct CDX_DynamicType_BitsetFlag {
61  char * name;
62  uint64_t value;
63  } CDX_DynamicType_BitsetFlag_t;
64 
82  COREDX_C_ADD_API DDS_TypeCodeKind CDX_DynamicType_get_type( CDX_DynamicType t );
83 
84  /* access basic types: */
89  COREDX_C_ADD_API unsigned char CDX_DynamicType_get_octet( CDX_DynamicType t );
94  COREDX_C_ADD_API unsigned char CDX_DynamicType_get_boolean( CDX_DynamicType t );
99  COREDX_C_ADD_API char CDX_DynamicType_get_char( CDX_DynamicType t );
104  COREDX_C_ADD_API int16_t CDX_DynamicType_get_short( CDX_DynamicType t );
109  COREDX_C_ADD_API uint16_t CDX_DynamicType_get_ushort( CDX_DynamicType t );
114  COREDX_C_ADD_API int32_t CDX_DynamicType_get_long( CDX_DynamicType t );
119  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_ulong( CDX_DynamicType t );
124  COREDX_C_ADD_API int64_t CDX_DynamicType_get_longlong( CDX_DynamicType t );
129  COREDX_C_ADD_API uint64_t CDX_DynamicType_get_ulonglong( CDX_DynamicType t );
134  COREDX_C_ADD_API float CDX_DynamicType_get_float( CDX_DynamicType t );
139  COREDX_C_ADD_API double CDX_DynamicType_get_double( CDX_DynamicType t );
140  /* ! @relates CDX_DynamicType
141  * @brief Provides access to data held in an LONG DOUBLE DynamicType object.
142  * @retval long double the data value held by 't'.
143  * @notyet Long Double data types are not supported by CoreDX DDS.
144  */
145  /* COREDX_C_ADD_API long double CDX_DynamicType_get_longdouble( CDX_DynamicType t ); */
146 
147 
153  COREDX_C_ADD_API int32_t CDX_DynamicType_enum_get_size( CDX_DynamicType t );
159  COREDX_C_ADD_API int32_t CDX_DynamicType_enum_get_num_constants( CDX_DynamicType t);
160 
168  COREDX_C_ADD_API void CDX_DynamicType_EnumConstant_delete( CDX_DynamicType_EnumConstant_t * ec);
169 
176  COREDX_C_ADD_API CDX_DynamicType_EnumConstant_t * CDX_DynamicType_enum_get_constant( CDX_DynamicType t,
177  int32_t index );
184  COREDX_C_ADD_API CDX_DynamicType_EnumConstant_t * CDX_DynamicType_enum_get_constant_by_name( CDX_DynamicType t,
185  const char * name);
192  COREDX_C_ADD_API CDX_DynamicType_EnumConstant_t * CDX_DynamicType_enum_get_constant_by_value( CDX_DynamicType t,
193  uint32_t val);
197  COREDX_C_ADD_API uint32_t CDX_DynamicType_enum_get_value( CDX_DynamicType t );
198 
204  COREDX_C_ADD_API int32_t CDX_DynamicType_bitset_get_size( CDX_DynamicType t );
208  COREDX_C_ADD_API uint64_t CDX_DynamicType_bitset_get_value( CDX_DynamicType t );
214  COREDX_C_ADD_API int32_t CDX_DynamicType_bitset_get_num_flags( CDX_DynamicType t);
215 
222  COREDX_C_ADD_API void CDX_DynamicType_BitsetFlag_delete( CDX_DynamicType_BitsetFlag_t * bf);
223 
230  COREDX_C_ADD_API CDX_DynamicType_BitsetFlag_t * CDX_DynamicType_bitset_get_flag( CDX_DynamicType t,
231  int32_t index );
238  COREDX_C_ADD_API CDX_DynamicType_BitsetFlag_t * CDX_DynamicType_bitset_get_flag_by_name( CDX_DynamicType t,
239  const char * name);
240 
241  /* access container types: */
242 
243  /* STRINGS: */
248  COREDX_C_ADD_API const char * CDX_DynamicType_get_string( CDX_DynamicType t );
249 
250  /* ARRAYS / SEQUENCES / STRINGS: */
260  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_max_length(CDX_DynamicType t);
261 
262  /* ARRAYS / SEQUENCES */
270  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_length(CDX_DynamicType t);
278  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_element_type(CDX_DynamicType t);
286  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_element(CDX_DynamicType t, uint32_t n);
287 
288  /* STRUCTS / UNIONS */
289  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_flags( CDX_DynamicType t );
290 
299  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_num_fields(CDX_DynamicType t);
306  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_field(CDX_DynamicType t, uint32_t n);
313  COREDX_C_ADD_API const char * CDX_DynamicType_get_field_name(CDX_DynamicType t, uint32_t n);
314 
315  /* STRUCTS */
323  COREDX_C_ADD_API unsigned char CDX_DynamicType_get_field_key(CDX_DynamicType t, uint32_t n);
324 
325  /* UNION */
332  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_discriminator(CDX_DynamicType t);
340  COREDX_C_ADD_API int32_t CDX_DynamicType_get_default_field(CDX_DynamicType t); /* -1 indicates no default case */
348  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_field_num_labels(CDX_DynamicType t, uint32_t field);
357  COREDX_C_ADD_API int32_t CDX_DynamicType_get_field_label(CDX_DynamicType t, uint32_t field, uint32_t label_idx);
363  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_selected_field(CDX_DynamicType t);
364 
365 
366  /******************************/
367  /* DynamicType TypeSupport */
368  /******************************/
373  COREDX_C_API CDX_TypeDefinition DDS_create_type_definition(const unsigned char *typecodes,
374  uint32_t tc_len,
375  unsigned char tc_encoding);
384  COREDX_C_API CDX_TypeDefinition DDS_create_type_definition_from_typecode(const unsigned char *typecodes,
385  uint32_t tc_len,
386  unsigned char tc_encoding);
393  COREDX_C_API CDX_TypeDefinition DDS_create_type_definition_from_dynamictype(CDX_DynamicType dtype);
394 
400  COREDX_C_API CDX_DynamicType CDX_TypeDefinition_create_dynamictype(CDX_TypeDefinition type_def);
401 
402  DECLARE_SEQ( CDX_DynamicType , CDX_DynamicTypePtrSeq );
403 
404 
405  /***********************************/
406  /* DynamicType Data Creation */
407  /***********************************/
408 
413  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc(DDS_TypeCodeKind type_code);
419  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_basic(DDS_TypeCodeKind type_code);
429  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_enum();
438  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_bitset();
444  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_string();
455  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_array();
465  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_sequence();
472  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_struct();
490  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_union();
491 
500  COREDX_C_API void CDX_DynamicType_free(CDX_DynamicType t);
501 
502  /* set basic types: */
508  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_octet( CDX_DynamicType t, unsigned char c );
514  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_boolean( CDX_DynamicType t, unsigned char c );
520  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_char( CDX_DynamicType t, char c );
526  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_short( CDX_DynamicType t, short c );
532  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_ushort( CDX_DynamicType t, unsigned short c );
538  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_long( CDX_DynamicType t, long c );
544  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_ulong( CDX_DynamicType t, unsigned long c );
550  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_longlong( CDX_DynamicType t, int64_t c );
556  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_ulonglong( CDX_DynamicType t, uint64_t c );
562  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_float( CDX_DynamicType t, float c );
568  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_double( CDX_DynamicType t, double c );
569  /* ! @relates CDX_DynamicType
570  * @brief Assigns a value to the provided LONGDOUBLE DynamicType.
571  * @retval BAD_PARAMETER if 't' is not of type LONGDOUBLE.
572  * @retval OK upon success.
573  * @notyet Long Double data types are not supported by CoreDX DDS.
574  */
575  /* COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_longdouble( CDX_DynamicType t,long double c ); */
576 
582  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_size( CDX_DynamicType t, int32_t size /* in bytes */ );
589  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_num_constants( CDX_DynamicType t, int32_t num );
598  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_constant( CDX_DynamicType t, int32_t n,
599  const char *name, uint32_t val );
605  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_value( CDX_DynamicType t, uint32_t val);
606 
612  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_size( CDX_DynamicType t, int32_t size /* in bytes */ );
619  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_num_flags( CDX_DynamicType t, int32_t num );
627  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_flag( CDX_DynamicType t, int32_t n,
628  const char *name, uint64_t val );
634  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_value( CDX_DynamicType t, uint64_t val);
635 
636  /* STRINGS: */
646  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_string( CDX_DynamicType t, const char * c );
647 
648  /* ARRAYS / SEQUENCES / STRINGS: */
656  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_max_length(CDX_DynamicType t, uint32_t n);
657 
658  /* set ARRAYS / SEQUENCES */
672  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_length(CDX_DynamicType t, uint32_t n);
678  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_element_type(CDX_DynamicType t, CDX_DynamicType e);
686  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_element(CDX_DynamicType t, uint32_t n, CDX_DynamicType e);
687 
688  /* set STRUCTS / UNIONS */
689  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_flags( CDX_DynamicType t, uint32_t f);
695  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_num_fields(CDX_DynamicType t, uint32_t n);
709  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_field(CDX_DynamicType t, uint32_t n, const char * field_name,
710  CDX_DynamicType e, unsigned char key);
711 
712  /* set UNION */
728  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_discriminator(CDX_DynamicType t, CDX_DynamicType d);
739  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_default_field(CDX_DynamicType t, int field); /* -1 indicates no default case */
754  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_field_num_labels(CDX_DynamicType t, uint32_t field, uint32_t n);
762  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_field_label(CDX_DynamicType t, uint32_t field, uint32_t label, int32_t val);
763 
764 
765 
766 
767 #ifdef __cplusplus
768 }
769 #endif /* __cplusplus */
770 
771 
772 #include <dds/dds_dtype_ts.h>
773 #include <dds/dds_dtype_dr.h>
774 #include <dds/dds_dtype_dw.h>
775 
776 #endif
CDX_DynamicType is an object that enhances CoreDX DDS with the facilities to process dynamic data typ...
int DDS_ReturnCode_t
Definition: dds_types.h:56
DDS_TypeCodeKind
Identifies the different data types supported by DDS_DynamicType objects.
Definition: dds_typecode.h:43
DECLARE_SEQ(DDS_DynamicTypeMember, DDS_DynamicTypeMemberSeq)
A DDS_DynamicTypeMemberSeq instance is a sequence of DDS_DynamicTypeMember&#39;s.

© 2009-2020 Twin Oaks Computing, Inc
Castle Rock, CO 80104
All rights reserved.