CoreDX DDS C Reference Manual
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-2016 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 
54  typedef struct CDX_DynamicType_EnumConstant {
55  char * name;
56  uint32_t value;
57  } CDX_DynamicType_EnumConstant_t;
58 
59  typedef struct CDX_DynamicType_BitsetFlag {
60  char * name;
61  uint64_t value;
62  } CDX_DynamicType_BitsetFlag_t;
63 
81  COREDX_C_ADD_API DDS_TypeCodeKind CDX_DynamicType_get_type( CDX_DynamicType t );
82 
83  /* access basic types: */
88  COREDX_C_ADD_API unsigned char CDX_DynamicType_get_octet( CDX_DynamicType t );
93  COREDX_C_ADD_API unsigned char CDX_DynamicType_get_boolean( CDX_DynamicType t );
98  COREDX_C_ADD_API char CDX_DynamicType_get_char( CDX_DynamicType t );
103  COREDX_C_ADD_API int16_t CDX_DynamicType_get_short( CDX_DynamicType t );
108  COREDX_C_ADD_API uint16_t CDX_DynamicType_get_ushort( CDX_DynamicType t );
113  COREDX_C_ADD_API int32_t CDX_DynamicType_get_long( CDX_DynamicType t );
118  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_ulong( CDX_DynamicType t );
123  COREDX_C_ADD_API int64_t CDX_DynamicType_get_longlong( CDX_DynamicType t );
128  COREDX_C_ADD_API uint64_t CDX_DynamicType_get_ulonglong( CDX_DynamicType t );
133  COREDX_C_ADD_API float CDX_DynamicType_get_float( CDX_DynamicType t );
138  COREDX_C_ADD_API double CDX_DynamicType_get_double( CDX_DynamicType t );
139  /* ! @relates CDX_DynamicType
140  * @brief Provides access to data held in an LONG DOUBLE DynamicType object.
141  * @retval long double the data value held by 't'.
142  * @notyet Long Double data types are not supported by CoreDX DDS.
143  */
144  /* COREDX_C_ADD_API long double CDX_DynamicType_get_longdouble( CDX_DynamicType t ); */
145 
146 
152  COREDX_C_ADD_API int32_t CDX_DynamicType_enum_get_size( CDX_DynamicType t );
158  COREDX_C_ADD_API int32_t CDX_DynamicType_enum_get_num_constants( CDX_DynamicType t);
159 
167  COREDX_C_ADD_API void CDX_DynamicType_EnumConstant_delete( CDX_DynamicType_EnumConstant_t * ec);
168 
175  COREDX_C_ADD_API CDX_DynamicType_EnumConstant_t * CDX_DynamicType_enum_get_constant( CDX_DynamicType t,
176  int32_t index );
183  COREDX_C_ADD_API CDX_DynamicType_EnumConstant_t * CDX_DynamicType_enum_get_constant_by_name( CDX_DynamicType t,
184  const char * name);
191  COREDX_C_ADD_API CDX_DynamicType_EnumConstant_t * CDX_DynamicType_enum_get_constant_by_value( CDX_DynamicType t,
192  uint32_t val);
196  COREDX_C_ADD_API uint32_t CDX_DynamicType_enum_get_value( CDX_DynamicType t );
197 
203  COREDX_C_ADD_API int32_t CDX_DynamicType_bitset_get_size( CDX_DynamicType t );
207  COREDX_C_ADD_API uint64_t CDX_DynamicType_bitset_get_value( CDX_DynamicType t );
213  COREDX_C_ADD_API int32_t CDX_DynamicType_bitset_get_num_flags( CDX_DynamicType t);
214 
221  COREDX_C_ADD_API void CDX_DynamicType_BitsetFlag_delete( CDX_DynamicType_BitsetFlag_t * bf);
222 
229  COREDX_C_ADD_API CDX_DynamicType_BitsetFlag_t * CDX_DynamicType_bitset_get_flag( CDX_DynamicType t,
230  int32_t index );
237  COREDX_C_ADD_API CDX_DynamicType_BitsetFlag_t * CDX_DynamicType_bitset_get_flag_by_name( CDX_DynamicType t,
238  const char * name);
239 
240  /* access container types: */
241 
242  /* STRINGS: */
247  COREDX_C_ADD_API const char * CDX_DynamicType_get_string( CDX_DynamicType t );
248 
249  /* ARRAYS / SEQUENCES / STRINGS: */
259  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_max_length(CDX_DynamicType t);
260 
261  /* ARRAYS / SEQUENCES */
269  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_length(CDX_DynamicType t);
277  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_element_type(CDX_DynamicType t);
285  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_element(CDX_DynamicType t, uint32_t n);
286 
287  /* STRUCTS / UNIONS */
288  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_flags( CDX_DynamicType t );
289 
298  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_num_fields(CDX_DynamicType t);
305  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_field(CDX_DynamicType t, uint32_t n);
312  COREDX_C_ADD_API const char * CDX_DynamicType_get_field_name(CDX_DynamicType t, uint32_t n);
313 
314  /* STRUCTS */
322  COREDX_C_ADD_API unsigned char CDX_DynamicType_get_field_key(CDX_DynamicType t, uint32_t n);
323 
324  /* UNION */
331  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_discriminator(CDX_DynamicType t);
339  COREDX_C_ADD_API int32_t CDX_DynamicType_get_default_field(CDX_DynamicType t); /* -1 indicates no default case */
347  COREDX_C_ADD_API uint32_t CDX_DynamicType_get_field_num_labels(CDX_DynamicType t, uint32_t field);
356  COREDX_C_ADD_API int32_t CDX_DynamicType_get_field_label(CDX_DynamicType t, uint32_t field, uint32_t label_idx);
362  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_get_selected_field(CDX_DynamicType t);
363 
364 
365  /******************************/
366  /* DynamicType TypeSupport */
367  /******************************/
372  COREDX_C_API CDX_TypeDefinition DDS_create_type_definition(const unsigned char *typecodes,
373  uint32_t tc_len,
374  unsigned char tc_encoding);
383  COREDX_C_API CDX_TypeDefinition DDS_create_type_definition_from_typecode(const unsigned char *typecodes,
384  uint32_t tc_len,
385  unsigned char tc_encoding);
392  COREDX_C_API CDX_TypeDefinition DDS_create_type_definition_from_dynamictype(CDX_DynamicType dtype);
393 
399  COREDX_C_API CDX_DynamicType CDX_TypeDefinition_create_dynamictype(CDX_TypeDefinition type_def);
400 
401  DECLARE_SEQ( CDX_DynamicType , CDX_DynamicTypePtrSeq );
402 
403 
404  /***********************************/
405  /* DynamicType Data Creation */
406  /***********************************/
407 
412  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc(DDS_TypeCodeKind type_code);
418  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_basic(DDS_TypeCodeKind type_code);
428  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_enum();
437  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_bitset();
443  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_string();
454  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_array();
464  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_sequence();
471  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_struct();
489  COREDX_C_ADD_API CDX_DynamicType CDX_DynamicType_alloc_union();
490 
499  COREDX_C_API void CDX_DynamicType_free(CDX_DynamicType t);
500 
501  /* set basic types: */
507  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_octet( CDX_DynamicType t, unsigned char c );
513  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_boolean( CDX_DynamicType t, unsigned char c );
519  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_char( CDX_DynamicType t, char c );
525  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_short( CDX_DynamicType t, short c );
531  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_ushort( CDX_DynamicType t, unsigned short c );
537  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_long( CDX_DynamicType t, long c );
543  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_ulong( CDX_DynamicType t, unsigned long c );
549  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_longlong( CDX_DynamicType t, int64_t c );
555  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_ulonglong( CDX_DynamicType t, uint64_t c );
561  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_float( CDX_DynamicType t, float c );
567  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_double( CDX_DynamicType t, double c );
568  /* ! @relates CDX_DynamicType
569  * @brief Assigns a value to the provided LONGDOUBLE DynamicType.
570  * @retval BAD_PARAMETER if 't' is not of type LONGDOUBLE.
571  * @retval OK upon success.
572  * @notyet Long Double data types are not supported by CoreDX DDS.
573  */
574  /* COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_longdouble( CDX_DynamicType t,long double c ); */
575 
581  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_size( CDX_DynamicType t, int32_t size /* in bytes */ );
588  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_num_constants( CDX_DynamicType t, int32_t num );
597  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_constant( CDX_DynamicType t, int32_t n,
598  const char *name, uint32_t val );
604  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_enum_set_value( CDX_DynamicType t, uint32_t val);
605 
611  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_size( CDX_DynamicType t, int32_t size /* in bytes */ );
618  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_num_flags( CDX_DynamicType t, int32_t num );
626  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_flag( CDX_DynamicType t, int32_t n,
627  const char *name, uint64_t val );
633  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_bitset_set_value( CDX_DynamicType t, uint64_t val);
634 
635  /* STRINGS: */
645  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_string( CDX_DynamicType t, const char * c );
646 
647  /* ARRAYS / SEQUENCES / STRINGS: */
655  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_max_length(CDX_DynamicType t, uint32_t n);
656 
657  /* set ARRAYS / SEQUENCES */
671  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_length(CDX_DynamicType t, uint32_t n);
677  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_element_type(CDX_DynamicType t, CDX_DynamicType e);
685  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_element(CDX_DynamicType t, uint32_t n, CDX_DynamicType e);
686 
687  /* set STRUCTS / UNIONS */
688  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_flags( CDX_DynamicType t, uint32_t f);
694  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_num_fields(CDX_DynamicType t, uint32_t n);
708  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_field(CDX_DynamicType t, uint32_t n, const char * field_name,
709  CDX_DynamicType e, unsigned char key);
710 
711  /* set UNION */
727  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_discriminator(CDX_DynamicType t, CDX_DynamicType d);
738  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_default_field(CDX_DynamicType t, int field); /* -1 indicates no default case */
753  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_field_num_labels(CDX_DynamicType t, uint32_t field, uint32_t n);
761  COREDX_C_ADD_API DDS_ReturnCode_t CDX_DynamicType_set_field_label(CDX_DynamicType t, uint32_t field, uint32_t label, int32_t val);
762 
763 
764 
765 
766 #ifdef __cplusplus
767 }
768 #endif /* __cplusplus */
769 
770 
771 #include <dds/dds_dtype_ts.h>
772 #include <dds/dds_dtype_dr.h>
773 #include <dds/dds_dtype_dw.h>
774 
775 #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-2017 Twin Oaks Computing, Inc
Castle Rock, CO 80108
All rights reserved.