RTI Connext DDS Micro  Version 2.4.6
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
reda_sequence_decl.h
1 /*
2  * FILE: reda_sequence_decl.h - Typed Sequence API
3  *
4  * Copyright 2008-2015 Real-Time Innovations, Inc.
5  *
6  * No duplications, whole or partial, manual or electronic, may be made
7  * without express written permission. Any such copies, or
8  * revisions thereof, must display this notice unaltered.
9  * This code contains trade secrets of Real-Time Innovations, Inc.
10  *
11  * Modification History
12  * --------------------
13  * 19may2015,as MICRO-1193 Refactoring of Sequence API levels
14  * 18feb2015,tk Factored out sequence declarations from reda_sequence.h
15  */
16 /*ci
17  * \file
18  *
19  * \brief The REDA Sequence API provides a strongly typed vector API.
20  *
21  * \defgroup REDASequenceClass REDA Sequence
22  * \ingroup REDAModule
23  *
24  * \details
25  *
26  * The REDA sequence API provides a strongly typed API to manage variable
27  * size vectors/arrays of the same type. The typing is achieved by encapsulating
28  * generic function in a typed wrapper using macro's. The documentation
29  * is for the generic functions.
30  */
31 /*ci
32  * \addtogroup REDASequenceClass
33  * @{
34  */
35 #ifndef reda_dll_h
36 #include "reda/reda_dll.h"
37 #endif
38 #ifndef osapi_types_h
39 #include "osapi/osapi_types.h"
40 #endif
41 #include "reda/reda_sequence.h"
42 
43 #if defined(RTI_WIN32) || defined(RTI_WINCE30)
44 #ifdef RTI_EXPORT_REDA_SEQUENCE
45 #ifdef REDADllExport
46 #undef REDADllExport
47 #endif
48 #define REDADllExport __declspec( dllexport )
49 #endif
50 #endif
51 
52 #define concatenate(A, B) A ## B
53 
54 #ifndef T
55 #define T RTI_INT32
56 #endif
57 
58 #ifdef REDA_SEQUENCE_USER_API
59 #ifndef REDA_SEQUENCE_API
60 #define REDA_SEQUENCE_API REDA_SEQUENCE_API_USER_DEFAULT
61 #else
62 #if REDA_SEQUENCE_API < REDA_SEQUENCE_API_BASIC
63 #error "REDA_SEQUENCE_USER_API defined along with API level < REDA_SEQUENCE_API_BASIC"
64 #endif
65 #endif
66 #endif /* REDA_SEQUENCE_USER_API */
67 
68 #ifndef REDA_SEQUENCE_API
69 #define REDA_SEQUENCE_API REDA_SEQUENCE_API_DEFAULT
70 #endif /* REDA_SEQUENCE_API */
71 
72 #if REDA_SEQUENCE_API < REDA_SEQUENCE_API_UNTYPED
73 #error "REDA_SEQUENCE_API_UNTYPED <= REDA_SEQUENCE_API <= REDA_SEQUENCE_API_FULL"
74 #endif
75 
76 /* This corresponds to the BASIC API, the lowest level */
77 #if REDA_SEQUENCE_API > REDA_SEQUENCE_API_UNTYPED
78 #ifndef TSeq_initialize
79 #define TSeq_initialize
80 #endif
81 #ifndef TSeq_get_maximum
82 #define TSeq_get_maximum
83 #endif
84 #ifndef TSeq_set_maximum
85 #define TSeq_set_maximum
86 #endif
87 #ifndef TSeq_get_length
88 #define TSeq_get_length
89 #endif
90 #ifndef TSeq_set_length
91 #define TSeq_set_length
92 #endif
93 #ifndef TSeq_get_reference
94 #define TSeq_get_reference
95 #endif
96 #ifndef RTI_CERT
97 #ifndef TSeq_finalize
98 #define TSeq_finalize
99 #endif
100 #endif /* RTI_CERT */
101 #ifdef REDA_SEQUENCE_USER_API
102 #ifndef TSeq_copy
103 #define TSeq_copy
104 #endif
105 #endif /* REDA_SEQUENCE_USER_API */
106 #endif /* REDA_SEQUENCE_API > REDA_SEQUENCE_API_UNTYPED */
107 
108 /* The FULL API adds the following methods */
109 #if REDA_SEQUENCE_API > REDA_SEQUENCE_API_BASIC
110 #ifndef TSeq_copy
111 #define TSeq_copy
112 #endif
113 #ifndef TSeq_is_equal
114 #define TSeq_is_equal
115 #endif
116 #ifndef TSeq_loan_contiguous
117 #define TSeq_loan_contiguous
118 #endif
119 #ifndef TSeq_loan_discontiguous
120 #define TSeq_loan_discontiguous
121 #endif
122 #ifndef TSeq_has_ownership
123 #define TSeq_has_ownership
124 #endif
125 #ifndef TSeq_has_discontiguous_buffer
126 #define TSeq_has_discontiguous_buffer
127 #endif
128 #ifndef TSeq_get_contiguous_buffer
129 #define TSeq_get_contiguous_buffer
130 #endif
131 #ifndef TSeq_get_discontiguous_buffer
132 #define TSeq_get_discontiguous_buffer
133 #endif
134 #ifndef TSeq_set_contiguous_buffer
135 #define TSeq_set_contiguous_buffer
136 #endif
137 #ifndef TSeq_unloan
138 #define TSeq_unloan
139 #endif
140 #ifndef TSeq_set_token
141 #define TSeq_set_token
142 #endif
143 #ifndef TSeq_get_token
144 #define TSeq_get_token
145 #endif
146 #ifndef TSeq_ensure_length
147 #define TSeq_ensure_length
148 #endif
149 #ifndef TSeq_from_array
150 #define TSeq_from_array
151 #endif
152 #ifndef TSeq_to_array
153 #define TSeq_to_array
154 #endif
155 #endif /* REDA_SEQUENCE_API > REDA_SEQUENCE_API_BASIC */
156 
157 #if REDA_SEQUENCE_API > REDA_SEQUENCE_API_FULL
158 #error "REDA_SEQUENCE_API_UNTYPED <= REDA_SEQUENCE_API <= REDA_SEQUENCE_API_FULL"
159 #endif /* REDA_SEQUENCE_API > REDA_SEQUENCE_API_FULL */
160 
161 /*ci
162  * \addtogroup REDASequenceClass
163  * @{
164  */
165 #ifndef REDA_SEQUENCE_EXCLUDE_STRUCT
166 
167 struct REDADllExport TSeq
168 {
169  T* _contiguous_buffer;
170  RTI_INT32 _maximum;
171  RTI_INT32 _length;
172  RTI_INT32 _element_size;
173  RTI_UINT8 _flags;
174  void *_token1;
175  void *_token2;
176 #ifdef RTI_CPP
177 public:
178 #ifdef TSeq_get_maximum
179  RTI_INT32 maximum() const;
180 #endif
181 #ifdef TSeq_set_maximum
182  bool maximum(RTI_INT32 new_max);
183 #endif
184 #ifdef TSeq_get_length
185  RTI_INT32 length() const;
186 #endif
187 #ifdef TSeq_set_length
188  bool length(RTI_INT32 new_length);
189 #endif
190 #ifdef TSeq_get_reference
191  T* get_reference(RTI_INT32 i);
192 #endif
193 #ifdef TSeq_copy
194  bool copy(const TSeq& src_seq);
195 #endif
196 #ifdef TSeq_is_equal
197  bool is_equal(const TSeq& other);
198 #endif
199 #ifdef TSeq_loan_contiguous
200  bool loan_contiguous(void* buffer, RTI_INT32 new_length, RTI_INT32 new_max);
201 #endif
202 #ifdef TSeq_loan_discontiguous
203  bool loan_discontiguous(void* buffer, RTI_INT32 new_length, RTI_INT32 new_max);
204 #endif
205 #ifdef TSeq_unloan
206  bool unloan();
207 #endif
208 #ifdef TSeq_has_ownership
209  bool has_ownership();
210 #endif
211 #ifdef TSeq_get_contiguous_buffer
212  T* get_contiguous_buffer() const;
213 #endif
214 #ifdef TSeq_set_contiguous_buffer
215  bool set_contiguous_buffer(T* buffer);
216 #endif
217 #ifdef TSeq_has_discontiguous_buffer
218  bool has_discontiguous_buffer();
219 #endif
220 #ifdef TSeq_set_token
221  void set_token(void *token1,void *token2);
222 #endif
223 #ifdef TSeq_get_token
224  void get_token(void **token1,void **token2);
225 #endif
226 #ifdef TSeq_ensure_length
227  bool ensure_length(RTI_INT32 length, RTI_INT32 max);
228 #endif
229 #ifdef TSeq_from_array
230  bool from_array(const T elv[], RTI_INT32 length);
231 #endif
232 #ifdef TSeq_to_array
233  bool to_array(T elv[], RTI_INT32 length);
234 #endif
235  TSeq();
236  ~TSeq();
237 
238 #ifdef RTI_CERT
239 private:
240 #else
241 public:
242 #endif /* RTI_CERT */
243  TSeq(const TSeq& seq);
244 #ifdef TSeq_copy
245  TSeq& operator=(const TSeq& src_seq);
246 #endif
247 #ifdef TSeq_get_reference
248  T& operator[] (RTI_INT32 index);
249 #endif
250 #ifdef TSeq_is_equal
251  bool operator==(const TSeq& other);\
252  bool operator!=(const TSeq& other);
253 #endif
254 
255 #endif /* RTI_CPP */
256 };
257 
258 /* REDA_DEFINE_SEQUENCE_OVERLOADED_METHODS(TSeq,T) */
259 
260 #if REDA_SEQUENCE_API > REDA_SEQUENCE_API_FULL
261 #error "REDA_SEQUENCE_API_UNTYPED <= REDA_SEQUENCE_API <= REDA_SEQUENCE_API_FULL"
262 #endif
263 #endif /* REDA_SEQUENCE_EXCLUDE_STRUCT */
264 
265 #ifndef REDA_SEQUENCE_EXCLUDE_C_METHODS
266 #ifdef __cplusplus
267 extern "C"
268 {
269 #endif
270 
271 #ifdef TSeq_initialize
272 #undef TSeq_initialize
273 #define _initialize(TSeq) concatenate(TSeq, _initialize)
274 #define TSeq_initialize _initialize(TSeq)
275 /*ci
276  * \brief Initialize a sequence of type T
277  *
278  * \details
279  *
280  * Initializes a sequence structure TSeq based on the element size of
281  * sequence type T. The initialization may call a type specific T_initialize
282  * for each element type T if it is defined.
283  *
284  * \return RTI_TRUE on success, RTI_FALSE on failure
285  *
286  * \param[in] self Sequence structure to initialize
287  *
288  * \sa TSeq_finalize
289  */
290 REDADllExport RTI_BOOL
291 TSeq_initialize(struct TSeq* self);
292 #undef _initialize
293 #undef TSeq_initialize
294 #endif
295 
296 #ifdef TSeq_finalize
297 #undef TSeq_finalize
298 #define _finalize(TSeq) concatenate(TSeq, _finalize)
299 #define TSeq_finalize _finalize(TSeq)
300 /*ci
301  * \brief Finalize a sequence of type T
302  *
303  * \details
304  *
305  * Finalizes a sequence TSeq based and releases all memory allocated to it.
306  * Each sequence element may be finalized individually if T_finalize is defined
307  * for the sequence type.
308  *
309  * \return RTI_TRUE on success, RTI_FALSE on failure
310  *
311  * \param[in] self Sequence structure to finalize
312  *
313  * \sa TSeq_finalize
314  */
315 REDADllExport RTI_BOOL
316 TSeq_finalize(struct TSeq *self);
317 #undef _finalize
318 #undef TSeq_finalize
319 #endif
320 
321 #ifdef TSeq_get_maximum
322 #undef TSeq_get_maximum
323 #define _get_maximum(TSeq) concatenate(TSeq, _get_maximum)
324 #define TSeq_get_maximum _get_maximum(TSeq)
325 REDADllExport RTI_INT32
326 TSeq_get_maximum(const struct TSeq *self);
327 #undef _get_maximum
328 #undef TSeq_get_maximum
329 #endif
330 
331 #ifdef TSeq_set_maximum
332 #undef TSeq_set_maximum
333 #define _set_maximum(TSeq) concatenate(TSeq, _set_maximum)
334 #define TSeq_set_maximum _set_maximum(TSeq)
335 #ifndef TSeq_isCDRStringType
336 REDADllExport RTI_BOOL
337 TSeq_set_maximum(struct TSeq *self, RTI_INT32 new_max);
338 #else
339 REDADllExport RTI_BOOL
340 TSeq_set_maximum(struct TSeq *self, RTI_INT32 new_max, RTI_UINT32 max_str_len);
341 #endif
342 #undef _set_maximum
343 #undef TSeq_set_maximum
344 #endif
345 
346 #ifdef TSeq_get_length
347 #undef TSeq_get_length
348 #define _get_length(TSeq) concatenate(TSeq, _get_length)
349 #define TSeq_get_length _get_length(TSeq)
350 REDADllExport RTI_INT32
351 TSeq_get_length(const struct TSeq *self);
352 #undef _get_length
353 #undef TSeq_get_length
354 #endif
355 
356 #ifdef TSeq_set_length
357 #undef TSeq_set_length
358 #define _set_length(TSeq) concatenate(TSeq, _set_length)
359 #define TSeq_set_length _set_length(TSeq)
360 REDADllExport RTI_BOOL
361 TSeq_set_length(struct TSeq *self, RTI_INT32 new_length);
362 #undef _set_length
363 #undef TSeq_set_length
364 #endif
365 
366 #ifdef TSeq_get_reference
367 #undef TSeq_get_reference
368 #define _get_reference(TSeq) concatenate(TSeq, _get_reference)
369 #define TSeq_get_reference _get_reference(TSeq)
370 REDADllExport T*
371 TSeq_get_reference(const struct TSeq *self, RTI_INT32 i);
372 #undef _get_reference
373 #undef TSeq_get_reference
374 #endif
375 
376 #ifdef TSeq_copy
377 #undef TSeq_copy
378 #define _copy(TSeq) concatenate(TSeq, _copy)
379 #define TSeq_copy _copy(TSeq)
380 #ifndef TSeq_isCDRStringType
381 REDADllExport struct TSeq*
382 TSeq_copy(struct TSeq *self, const struct TSeq *src);
383 #else
384 REDADllExport struct TSeq*
385 TSeq_copy(struct TSeq *self, const struct TSeq *src, RTI_UINT32 max_str_len);
386 #endif
387 #undef _copy
388 #undef TSeq_copy
389 #endif
390 
391 #ifdef TSeq_is_equal
392 #undef TSeq_is_equal
393 #define _is_equal(TSeq) concatenate(TSeq, _is_equal)
394 #define TSeq_is_equal _is_equal(TSeq)
395 REDADllExport RTI_BOOL
396 TSeq_is_equal(const struct TSeq *left, const struct TSeq *right);
397 #undef _is_equal
398 #undef TSeq_is_equal
399 #endif
400 
401 #ifdef TSeq_loan_contiguous
402 #undef TSeq_loan_contiguous
403 #define _loan_contiguous(TSeq) concatenate(TSeq, _loan_contiguous)
404 #define TSeq_loan_contiguous _loan_contiguous(TSeq)
405 REDADllExport RTI_BOOL
406 TSeq_loan_contiguous(struct TSeq *self, void *buffer,
407  RTI_INT32 new_length, RTI_INT32 new_max);
408 #undef _loan_contiguous
409 #undef TSeq_loan_contiguous
410 #endif
411 
412 #ifdef TSeq_loan_discontiguous
413 #undef TSeq_loan_discontiguous
414 #define _loan_discontiguous(TSeq) concatenate(TSeq, _loan_discontiguous)
415 #define TSeq_loan_discontiguous _loan_discontiguous(TSeq)
416 REDADllExport RTI_BOOL
417 TSeq_loan_discontiguous(struct TSeq *self, void *buffer,
418  RTI_INT32 new_length, RTI_INT32 new_max);
419 #undef _loan_discontiguous
420 #undef TSeq_loan_discontiguous
421 #endif /* TSeq_loan_discontiguous */
422 
423 #ifdef TSeq_unloan
424 #undef TSeq_unloan
425 #define _unloan(TSeq) concatenate(TSeq, _unloan)
426 #define TSeq_unloan _unloan(TSeq)
427 REDADllExport RTI_BOOL
428 TSeq_unloan(struct TSeq *self);
429 #undef _unloan
430 #undef TSeq_unloan
431 #endif /* TSeq_unloan */
432 
433 #ifdef TSeq_has_ownership
434 #undef TSeq_has_ownership
435 #define _has_ownership(TSeq) concatenate(TSeq, _has_ownership)
436 #define TSeq_has_ownership _has_ownership(TSeq)
437 REDADllExport RTI_BOOL
438 TSeq_has_ownership(const struct TSeq *self);
439 #undef _has_ownership
440 #undef TSeq_has_ownership
441 #endif /* TSeq_has_ownership */
442 
443 #ifdef TSeq_get_contiguous_buffer
444 #undef TSeq_get_contiguous_buffer
445 #define _get_contiguous_buffer(TSeq) concatenate(TSeq, _get_contiguous_buffer)
446 #define TSeq_get_contiguous_buffer _get_contiguous_buffer(TSeq)
447 REDADllExport T*
448 TSeq_get_contiguous_buffer(const struct TSeq *self);
449 #undef _get_contiguous_buffer
450 #undef TSeq_get_contiguous_buffer
451 #endif /* TSeq_get_buffer */
452 
453 #ifdef TSeq_get_discontiguous_buffer
454 #undef TSeq_get_discontiguous_buffer
455 #define _get_discontiguous_buffer(TSeq) concatenate(TSeq, TSeq_get_discontiguous_buffer)
456 #define TSeq_get_discontiguous_buffer _get_discontiguous_buffer(TSeq)
457 REDADllExport T*
458 TSeq_get_discontiguous_buffer(const struct TSeq *self);
459 #undef _get_discontiguous_buffer
460 #undef TSeq_get_discontiguous_buffer
461 #endif /* TSeq_get_discontiguous_buffer */
462 
463 #ifdef TSeq_set_contiguous_buffer
464 #undef TSeq_set_contiguous_buffer
465 #define _set_contiguous_buffer(TSeq) concatenate(TSeq, _set_contiguous_buffer)
466 #define TSeq_set_contiguous_buffer _set_contiguous_buffer(TSeq)
467 REDADllExport RTI_BOOL
468 TSeq_set_contiguous_buffer(struct TSeq *self, T *buffer);
469 #undef _set_contiguous_buffer
470 #undef TSeq_set_contiguous_buffer
471 #endif /* TSeq_set_buffer */
472 
473 #ifdef TSeq_has_discontiguous_buffer
474 #undef TSeq_has_discontiguous_buffer
475 #define _has_discontiguous_buffer(TSeq) concatenate(TSeq, _has_discontiguous_buffer)
476 #define TSeq_has_discontiguous_buffer _has_discontiguous_buffer(TSeq)
477 REDADllExport RTI_BOOL
478 TSeq_has_discontiguous_buffer(const struct TSeq *self);
479 #undef _has_discontiguous_buffer
480 #undef TSeq_has_discontiguous_buffer
481 #endif /* TSeq_has_discontiguous_buffer */
482 
483 #ifdef TSeq_set_token
484 #undef TSeq_set_token
485 #define _set_token(TSeq) concatenate(TSeq, _set_token)
486 #define TSeq_set_token _set_token(TSeq)
487 REDADllExport void
488 TSeq_set_token(struct TSeq *self,void *token1,void *token2);
489 #undef _set_token
490 #undef TSeq_set_token
491 #endif /* TSeq_set_token */
492 
493 #ifdef TSeq_get_token
494 #undef TSeq_get_token
495 #define _get_token(TSeq) concatenate(TSeq, _get_token)
496 #define TSeq_get_token _get_token(TSeq)
497 REDADllExport void
498 TSeq_get_token(struct TSeq *self,void **token1,void **token2);
499 #undef _get_token
500 #undef TSeq_get_token
501 #endif /* TSeq_get_token */
502 
503 #ifdef TSeq_ensure_length
504 #undef TSeq_ensure_length
505 #define _ensure_length(TSeq) concatenate(TSeq, _ensure_length)
506 #define TSeq_ensure_length _ensure_length(TSeq)
507 #ifndef TSeq_isCDRStringType
508 REDADllExport RTI_BOOL
509 TSeq_ensure_length(struct TSeq *self,RTI_INT32 length, RTI_INT32 max);
510 #else
511 REDADllExport RTI_BOOL
512 TSeq_ensure_length(struct TSeq *self,RTI_INT32 length, RTI_INT32 max,
513  RTI_INT32 max_str_len);
514 #endif
515 #undef _ensure_length
516 #undef TSeq_ensure_length
517 #endif /* TSeq_ensure_length */
518 
519 #ifdef TSeq_from_array
520 #undef TSeq_from_array
521 #define _from_array(TSeq) concatenate(TSeq, _from_array)
522 #define TSeq_from_array _from_array(TSeq)
523 #ifndef TSeq_isCDRStringType
524 REDADllExport RTI_BOOL
525 TSeq_from_array(struct TSeq *self, const T elms_seq[], RTI_INT32 length);
526 #else
527 REDADllExport RTI_BOOL
528 TSeq_from_array(struct TSeq *self, const T elms_seq[], RTI_INT32 length,RTI_INT32 max_str_len);
529 #endif
530 #undef _from_array
531 #undef TSeq_from_array
532 #endif /* TSeq_from_array */
533 
534 #ifdef TSeq_to_array
535 #undef TSeq_to_array
536 #define _to_array(TSeq) concatenate(TSeq, _to_array)
537 #define TSeq_to_array _to_array(TSeq)
538 #ifndef TSeq_isCDRStringType
539 REDADllExport RTI_BOOL
540 TSeq_to_array(struct TSeq *self,T elms_seq[], RTI_INT32 length);
541 #else
542 REDADllExport RTI_BOOL
543 TSeq_to_array(struct TSeq *self,T elms_seq[], RTI_INT32 length,RTI_INT32 max_str_len);
544 #endif
545 #undef _to_array
546 #undef TSeq_to_array
547 #endif /* TSeq_to_array */
548 
549 #ifdef __cplusplus
550 } /* extern "C" */
551 #endif
552 
553 #endif /* REDA_SEQUENCE_EXCLUDE_C_METHODS */
554 
555 #undef TSeq
556 #undef T
557 #undef REDA_SEQUENCE_API
558 #undef concatenate
559 #undef TSeq_isCDRStringType
560 #undef REDA_SEQUENCE_EXCLUDE_STRUCT
561 #undef REDA_SEQUENCE_EXCLUDE_C_METHODS
562 #undef REDA_SEQUENCE_USER_API
563 
564 /*ci @} */

RTI Connext DDS Micro Version 2.4.6 Copyright © Sun Jan 24 2016 Real-Time Innovations, Inc