-
Notifications
You must be signed in to change notification settings - Fork 365
/
dds.h
4049 lines (3868 loc) · 161 KB
/
dds.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef DDS_H
#define DDS_H
/** @file
*
* @brief Eclipse Cyclone DDS C header
*/
#if defined (__cplusplus)
#define restrict
#endif
#include "dds/export.h"
#include "dds/features.h"
#include "dds/ddsc/dds_basic_types.h"
/* Sub components */
#include "dds/ddsrt/time.h"
#include "dds/ddsrt/retcode.h"
#include "dds/ddsrt/log.h"
#include "dds/ddsc/dds_public_impl.h"
#include "dds/ddsc/dds_public_alloc.h"
#include "dds/ddsc/dds_public_qos.h"
#include "dds/ddsc/dds_public_error.h"
#include "dds/ddsc/dds_public_status.h"
#include "dds/ddsc/dds_public_listener.h"
#if defined (__cplusplus)
extern "C" {
#endif
typedef struct ddsi_typeid dds_typeid_t;
typedef struct ddsi_typeobj dds_typeobj_t;
struct dds_rhc;
struct ddsi_plist;
struct ddsi_sertype;
struct ddsi_serdata;
struct ddsi_sertopic; // deprecated, binary compatibility only
/** Indicates that the library uses ddsi_sertype (as a replacement for ddsi_sertopic). If sertype
* is used, the function dds_create_topic_sertype requires a topic name parameter, as this field
* is not included in ddsi_sertype. */
#define DDS_HAS_DDSI_SERTYPE 1
/**
* \defgroup builtintopic_constants Convenience constants for referring to builtin topics
* These constants can be used in place of an actual dds_topic_t, when creating
* readers or writers for builtin-topics.
*
* @{
*/
#define DDS_BUILTIN_TOPIC_DCPSPARTICIPANT ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 1))
#define DDS_BUILTIN_TOPIC_DCPSTOPIC ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 2))
#define DDS_BUILTIN_TOPIC_DCPSPUBLICATION ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 3))
#define DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 4))
/** @}*/
/** Special handle representing the entity which forces the dds_data_allocator to allocate on heap */
#define DDS_DATA_ALLOCATOR_ALLOC_ON_HEAP ((dds_entity_t) (DDS_MIN_PSEUDO_HANDLE + 257))
/** @name Communication Status definitions
@{**/
typedef enum dds_status_id {
DDS_INCONSISTENT_TOPIC_STATUS_ID,
DDS_OFFERED_DEADLINE_MISSED_STATUS_ID,
DDS_REQUESTED_DEADLINE_MISSED_STATUS_ID,
DDS_OFFERED_INCOMPATIBLE_QOS_STATUS_ID,
DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS_ID,
DDS_SAMPLE_LOST_STATUS_ID,
DDS_SAMPLE_REJECTED_STATUS_ID,
DDS_DATA_ON_READERS_STATUS_ID,
DDS_DATA_AVAILABLE_STATUS_ID,
DDS_LIVELINESS_LOST_STATUS_ID,
DDS_LIVELINESS_CHANGED_STATUS_ID,
DDS_PUBLICATION_MATCHED_STATUS_ID,
DDS_SUBSCRIPTION_MATCHED_STATUS_ID
} dds_status_id_t;
#define DDS_STATUS_ID_MAX (DDS_SUBSCRIPTION_MATCHED_STATUS_ID)
/** Another topic exists with the same name but with different characteristics. */
#define DDS_INCONSISTENT_TOPIC_STATUS (1u << DDS_INCONSISTENT_TOPIC_STATUS_ID)
/** The deadline that the writer has committed through its deadline QoS policy was not respected for a specific instance. */
#define DDS_OFFERED_DEADLINE_MISSED_STATUS (1u << DDS_OFFERED_DEADLINE_MISSED_STATUS_ID)
/** The deadline that the reader was expecting through its deadline QoS policy was not respected for a specific instance. */
#define DDS_REQUESTED_DEADLINE_MISSED_STATUS (1u << DDS_REQUESTED_DEADLINE_MISSED_STATUS_ID)
/** A QoS policy setting was incompatible with what was requested. */
#define DDS_OFFERED_INCOMPATIBLE_QOS_STATUS (1u << DDS_OFFERED_INCOMPATIBLE_QOS_STATUS_ID)
/** A QoS policy setting was incompatible with what is offered. */
#define DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS (1u << DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS_ID)
/** A sample has been lost (never received). */
#define DDS_SAMPLE_LOST_STATUS (1u << DDS_SAMPLE_LOST_STATUS_ID)
/** A (received) sample has been rejected. */
#define DDS_SAMPLE_REJECTED_STATUS (1u << DDS_SAMPLE_REJECTED_STATUS_ID)
/** New information is available. */
#define DDS_DATA_ON_READERS_STATUS (1u << DDS_DATA_ON_READERS_STATUS_ID)
/** New information is available. */
#define DDS_DATA_AVAILABLE_STATUS (1u << DDS_DATA_AVAILABLE_STATUS_ID)
/** The liveliness that the DDS_DataWriter has committed through its liveliness QoS policy was not respected; thus readers will consider the writer as no longer "alive". */
#define DDS_LIVELINESS_LOST_STATUS (1u << DDS_LIVELINESS_LOST_STATUS_ID)
/** The liveliness of one or more writers, that were writing instances read through the readers has changed. Some writers have become "alive" or "not alive". */
#define DDS_LIVELINESS_CHANGED_STATUS (1u << DDS_LIVELINESS_CHANGED_STATUS_ID)
/** The writer has found a reader that matches the topic and has a compatible QoS. */
#define DDS_PUBLICATION_MATCHED_STATUS (1u << DDS_PUBLICATION_MATCHED_STATUS_ID)
/** The reader has found a writer that matches the topic and has a compatible QoS. */
#define DDS_SUBSCRIPTION_MATCHED_STATUS (1u << DDS_SUBSCRIPTION_MATCHED_STATUS_ID)
/** @}*/
/** Read state for a data value */
typedef enum dds_sample_state
{
DDS_SST_READ = DDS_READ_SAMPLE_STATE, /**<DataReader has already accessed the sample by read */
DDS_SST_NOT_READ = DDS_NOT_READ_SAMPLE_STATE /**<DataReader has not accessed the sample before */
}
dds_sample_state_t;
/** View state of an instance relative to the samples */
typedef enum dds_view_state
{
/** DataReader is accessing the sample for the first time when the instance is alive */
DDS_VST_NEW = DDS_NEW_VIEW_STATE,
/** DataReader accessed the sample before */
DDS_VST_OLD = DDS_NOT_NEW_VIEW_STATE
}
dds_view_state_t;
/** Defines the state of the instance */
typedef enum dds_instance_state
{
/** Samples received for the instance from the live data writers */
DDS_IST_ALIVE = DDS_ALIVE_INSTANCE_STATE,
/** Instance was explicitly disposed by the data writer */
DDS_IST_NOT_ALIVE_DISPOSED = DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE,
/** Instance has been declared as not alive by data reader as there are no live data writers writing that instance */
DDS_IST_NOT_ALIVE_NO_WRITERS = DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE
}
dds_instance_state_t;
/** Contains information about the associated data value */
typedef struct dds_sample_info
{
/** Sample state */
dds_sample_state_t sample_state;
/** View state */
dds_view_state_t view_state;
/** Instance state */
dds_instance_state_t instance_state;
/** Indicates whether there is a data associated with a sample
* - true, indicates the data is valid
* - false, indicates the data is invalid, no data to read */
bool valid_data;
/** timestamp of a data instance when it is written */
dds_time_t source_timestamp;
/** handle to the data instance */
dds_instance_handle_t instance_handle;
/** handle to the publisher */
dds_instance_handle_t publication_handle;
/** count of instance state change from NOT_ALIVE_DISPOSED to ALIVE */
uint32_t disposed_generation_count;
/** count of instance state change from NOT_ALIVE_NO_WRITERS to ALIVE */
uint32_t no_writers_generation_count;
/** indicates the number of samples of the same instance that follow the current one in the collection */
uint32_t sample_rank;
/** difference in generations between the sample and most recent sample of the same instance that appears in the returned collection */
uint32_t generation_rank;
/** difference in generations between the sample and most recent sample of the same instance when read/take was called */
uint32_t absolute_generation_rank;
}
dds_sample_info_t;
typedef struct dds_builtintopic_guid
{
uint8_t v[16];
}
dds_builtintopic_guid_t;
/* "dds_builtintopic_guid_t" is a bit of a weird name for what everyone just calls a GUID,
so let us try and switch to using the more logical one */
typedef struct dds_builtintopic_guid dds_guid_t;
typedef struct dds_builtintopic_participant
{
dds_guid_t key;
dds_qos_t *qos;
}
dds_builtintopic_participant_t;
typedef struct dds_builtintopic_topic_key {
unsigned char d[16];
} dds_builtintopic_topic_key_t;
typedef struct dds_builtintopic_topic
{
dds_builtintopic_topic_key_t key;
char *topic_name;
char *type_name;
dds_qos_t *qos;
}
dds_builtintopic_topic_t;
typedef struct dds_builtintopic_endpoint
{
dds_guid_t key;
dds_guid_t participant_key;
dds_instance_handle_t participant_instance_handle;
char *topic_name;
char *type_name;
dds_qos_t *qos;
}
dds_builtintopic_endpoint_t;
/*
All entities are represented by a process-private handle, with one
call to enable an entity when it was created disabled.
An entity is created enabled by default.
Note: disabled creation is currently not supported.
*/
/**
* @brief Enable entity.
*
* @note Delayed entity enabling is not supported yet (CHAM-96).
*
* This operation enables the dds_entity_t. Created dds_entity_t objects can start in
* either an enabled or disabled state. This is controlled by the value of the
* entityfactory policy on the corresponding parent entity for the given
* entity. Enabled entities are immediately activated at creation time meaning
* all their immutable QoS settings can no longer be changed. Disabled Entities are not
* yet activated, so it is still possible to change their immutable QoS settings. However,
* once activated the immutable QoS settings can no longer be changed.
* Creating disabled entities can make sense when the creator of the DDS_Entity
* does not yet know which QoS settings to apply, thus allowing another piece of code
* to set the QoS later on.
*
* The default setting of DDS_EntityFactoryQosPolicy is such that, by default,
* entities are created in an enabled state so that it is not necessary to explicitly call
* dds_enable on newly-created entities.
*
* The dds_enable operation produces the same results no matter how
* many times it is performed. Calling dds_enable on an already
* enabled DDS_Entity returns DDS_RETCODE_OK and has no effect.
*
* If an Entity has not yet been enabled, the only operations that can be invoked
* on it are: the ones to set, get or copy the QosPolicy settings, the ones that set
* (or get) the Listener, the ones that get the Status and the dds_get_status_changes
* operation (although the status of a disabled entity never changes). Other operations
* will return the error DDS_RETCODE_NOT_ENABLED.
*
* Entities created with a parent that is disabled, are created disabled regardless of
* the setting of the entityfactory policy.
*
* If the entityfactory policy has autoenable_created_entities
* set to TRUE, the dds_enable operation on the parent will
* automatically enable all child entities created with the parent.
*
* The Listeners associated with an Entity are not called until the
* Entity is enabled. Conditions associated with an Entity that
* is not enabled are "inactive", that is, have a trigger_value which is FALSE.
*
* @param[in] entity The entity to enable.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* The listeners of to the entity have been successfully been copied
* into the specified listener parameter.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* The parent of the given Entity is not enabled.
*/
DDS_EXPORT dds_return_t
dds_enable(dds_entity_t entity);
/*
All entities are represented by a process-private handle, with one
call to delete an entity and all entities it logically contains.
That is, it is equivalent to combination of
delete_contained_entities and delete_xxx in the DCPS API.
*/
/**
* @brief Delete given entity.
*
* This operation will delete the given entity. It will also automatically
* delete all its children, childrens' children, etc entities.
*
* @param[in] entity Entity to delete.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* The entity and its children (recursive are deleted).
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to generic dds entity relations documentation. */
DDS_EXPORT dds_return_t
dds_delete(dds_entity_t entity);
/**
* @brief Get entity publisher.
*
* This operation returns the publisher to which the given entity belongs.
* For instance, it will return the Publisher that was used when
* creating a DataWriter (when that DataWriter was provided here).
*
* @param[in] writer Entity from which to get its publisher.
*
* @returns A valid entity or an error code.
*
* @retval >0
* A valid publisher handle.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to generic dds entity relations documentation. */
DDS_EXPORT dds_entity_t
dds_get_publisher(dds_entity_t writer);
/**
* @brief Get entity subscriber.
*
* This operation returns the subscriber to which the given entity belongs.
* For instance, it will return the Subscriber that was used when
* creating a DataReader (when that DataReader was provided here).
*
* @param[in] entity Entity from which to get its subscriber.
*
* @returns A valid subscriber handle or an error code.
*
* @retval >0
* A valid subscriber handle.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to generic dds entity relations documentation. */
DDS_EXPORT dds_entity_t
dds_get_subscriber(dds_entity_t entity);
/**
* @brief Get entity datareader.
*
* This operation returns the datareader to which the given entity belongs.
* For instance, it will return the DataReader that was used when
* creating a ReadCondition (when that ReadCondition was provided here).
*
* @param[in] condition Entity from which to get its datareader.
*
* @returns A valid reader handle or an error code.
*
* @retval >0
* A valid reader handle.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to generic dds entity relations documentation. */
DDS_EXPORT dds_entity_t
dds_get_datareader(dds_entity_t condition);
/**
* @brief Get the mask of a condition.
*
* This operation returns the mask that was used to create the given
* condition.
*
* @param[in] condition Read or Query condition that has a mask.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success (given mask is set).
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* The mask arg is NULL.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_mask(dds_entity_t condition, uint32_t *mask);
/**
* @brief Returns the instance handle that represents the entity.
*
* @param[in] entity Entity of which to get the instance handle.
* @param[out] ihdl Pointer to dds_instance_handle_t.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
*/
/* TODO: Check list of return codes is complete. */
DDS_EXPORT dds_return_t
dds_get_instance_handle(dds_entity_t entity, dds_instance_handle_t *ihdl);
/**
* @brief Returns the GUID that represents the entity in the network,
* and therefore only supports participants, readers and writers.
*
* @param[in] entity Entity of which to get the instance handle.
* @param[out] guid Where to store the GUID.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
*/
/* TODO: Check list of return codes is complete. */
DDS_EXPORT dds_return_t
dds_get_guid (dds_entity_t entity, dds_guid_t *guid);
/*
All entities have a set of "status conditions" (following the DCPS
spec), read peeks, take reads & resets (analogously to read & take
operations on reader). The "mask" allows operating only on a subset
of the statuses. Enabled status analogously to DCPS spec.
*/
/**
* @brief Read the status set for the entity
*
* This operation reads the status(es) set for the entity based on
* the enabled status and mask set. It does not clear the read status(es).
*
* @param[in] entity Entity on which the status has to be read.
* @param[out] status Returns the status set on the entity, based on the enabled status.
* @param[in] mask Filter the status condition to be read, 0 means all statuses
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success.
* @retval DDS_RETCODE_BAD_PARAMETER
* The entity parameter is not a valid parameter, status is a null pointer or
* mask has bits set outside the status range.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object or mask has status
* bits set that are undefined for the type of entity.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_read_status(dds_entity_t entity, uint32_t *status, uint32_t mask);
/**
* @brief Read the status set for the entity
*
* This operation reads the status(es) set for the entity based on the enabled
* status and mask set. It clears the status set after reading.
*
* @param[in] entity Entity on which the status has to be read.
* @param[out] status Returns the status set on the entity, based on the enabled status.
* @param[in] mask Filter the status condition to be read, 0 means all statuses
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success.
* @retval DDS_RETCODE_BAD_PARAMETER
* The entity parameter is not a valid parameter, status is a null pointer or
* mask has bits set outside the status range.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object or mask has status
* bits set that are undefined for the type of entity.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_take_status(dds_entity_t entity, uint32_t *status, uint32_t mask);
/**
* @brief Get changed status(es)
*
* This operation returns the status changes since they were last read.
*
* @param[in] entity Entity on which the statuses are read.
* @param[out] status Returns the current set of triggered statuses.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success.
* @retval DDS_RETCODE_BAD_PARAMETER
* The entity parameter is not a valid parameter.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_status_changes(dds_entity_t entity, uint32_t *status);
/**
* @brief Get enabled status on entity
*
* This operation returns the status enabled on the entity
*
* @param[in] entity Entity to get the status.
* @param[out] mask Mask of enabled statuses set on the entity.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success.
* @retval DDS_RETCODE_BAD_PARAMETER
* The entity parameter is not a valid parameter.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_status_mask(dds_entity_t entity, uint32_t *mask);
DDS_DEPRECATED_EXPORT dds_return_t
dds_get_enabled_status(dds_entity_t entity, uint32_t *mask);
/**
* @brief Set status enabled on entity
*
* This operation enables the status(es) based on the mask set
*
* @param[in] entity Entity to enable the status.
* @param[in] mask Status value that indicates the status to be enabled.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Success.
* @retval DDS_RETCODE_BAD_PARAMETER
* The entity parameter is not a valid parameter.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_set_status_mask(dds_entity_t entity, uint32_t mask);
DDS_DEPRECATED_EXPORT dds_return_t
dds_set_enabled_status(dds_entity_t entity, uint32_t mask);
/*
Almost all entities have get/set qos operations defined on them,
again following the DCPS spec. But unlike the DCPS spec, the
"present" field in qos_t allows one to initialize just the one QoS
one wants to set & pass it to set_qos.
*/
/**
* @brief Get entity QoS policies.
*
* This operation allows access to the existing set of QoS policies
* for the entity.
*
* @param[in] entity Entity on which to get qos.
* @param[out] qos Pointer to the qos structure that returns the set policies.
*
* @returns A dds_return_t indicating success or failure. The QoS object will have
* at least all QoS relevant for the entity present and the corresponding dds_qget_...
* will return true.
*
* @retval DDS_RETCODE_OK
* The existing set of QoS policy values applied to the entity
* has successfully been copied into the specified qos parameter.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* The qos parameter is NULL.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to generic QoS information documentation. */
DDS_EXPORT dds_return_t
dds_get_qos(dds_entity_t entity, dds_qos_t *qos);
/**
* @brief Set entity QoS policies.
*
* This operation replaces the existing set of Qos Policy settings for an
* entity. The parameter qos must contain the struct with the QosPolicy
* settings which is checked for self-consistency.
*
* The set of QosPolicy settings specified by the qos parameter are applied on
* top of the existing QoS, replacing the values of any policies previously set
* (provided, the operation returned DDS_RETCODE_OK).
*
* Not all policies are changeable when the entity is enabled.
*
* @note Currently only Latency Budget and Ownership Strength are changeable QoS
* that can be set.
*
* @param[in] entity Entity from which to get qos.
* @param[in] qos Pointer to the qos structure that provides the policies.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* The new QoS policies are set.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* The qos parameter is NULL.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
* @retval DDS_RETCODE_IMMUTABLE_POLICY
* The entity is enabled and one or more of the policies of the QoS
* are immutable.
* @retval DDS_RETCODE_INCONSISTENT_POLICY
* A few policies within the QoS are not consistent with each other.
*/
/* TODO: Link to generic QoS information documentation. */
DDS_EXPORT dds_return_t
dds_set_qos(dds_entity_t entity, const dds_qos_t * qos);
/*
Get or set listener associated with an entity, type of listener
provided much match type of entity.
*/
/**
* @brief Get entity listeners.
*
* This operation allows access to the existing listeners attached to
* the entity.
*
* @param[in] entity Entity on which to get the listeners.
* @param[out] listener Pointer to the listener structure that returns the
* set of listener callbacks.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* The listeners of to the entity have been successfully been
* copied into the specified listener parameter.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* The listener parameter is NULL.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to (generic) Listener and status information. */
DDS_EXPORT dds_return_t
dds_get_listener(dds_entity_t entity, dds_listener_t * listener);
/**
* @brief Set entity listeners.
*
* This operation attaches a dds_listener_t to the dds_entity_t. Only one
* Listener can be attached to each Entity. If a Listener was already
* attached, this operation will replace it with the new one. In other
* words, all related callbacks are replaced (possibly with NULL).
*
* When listener parameter is NULL, all listener callbacks that were possibly
* set on the Entity will be removed.
*
* @note Not all listener callbacks are related to all entities.
*
* <b><i>Communication Status</i></b><br>
* For each communication status, the StatusChangedFlag flag is initially set to
* FALSE. It becomes TRUE whenever that plain communication status changes. For
* each plain communication status activated in the mask, the associated
* Listener callback is invoked and the communication status is reset
* to FALSE, as the listener implicitly accesses the status which is passed as a
* parameter to that operation.
* The status is reset prior to calling the listener, so if the application calls
* the get_<status_name> from inside the listener it will see the
* status already reset.
*
* <b><i>Status Propagation</i></b><br>
* In case a related callback within the Listener is not set, the Listener of
* the Parent entity is called recursively, until a Listener with the appropriate
* callback set has been found and called. This allows the application to set
* (for instance) a default behaviour in the Listener of the containing Publisher
* and a DataWriter specific behaviour when needed. In case the callback is not
* set in the Publishers' Listener either, the communication status will be
* propagated to the Listener of the DomainParticipant of the containing
* DomainParticipant. In case the callback is not set in the DomainParticipants'
* Listener either, the Communication Status flag will be set, resulting in a
* possible WaitSet trigger.
*
* @param[in] entity Entity on which to get the listeners.
* @param[in] listener Pointer to the listener structure that contains the
* set of listener callbacks (maybe NULL).
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* The listeners of to the entity have been successfully been
* copied into the specified listener parameter.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to (generic) Listener and status information. */
DDS_EXPORT dds_return_t
dds_set_listener(dds_entity_t entity, const dds_listener_t * listener);
/*
Creation functions for various entities. Creating a subscriber or
publisher is optional: if one creates a reader as a descendant of a
participant, it is as if a subscriber is created specially for
that reader.
QoS default values are those of the DDS specification, but the
inheritance rules are different:
* publishers and subscribers inherit from the participant QoS
* readers and writers always inherit from the topic QoS
* the QoS's present in the "qos" parameter override the inherited values
*/
/**
* @brief Creates a new instance of a DDS participant in a domain
*
* If domain is set (not DDS_DOMAIN_DEFAULT) then it must match if the domain has also
* been configured or an error status will be returned.
* Currently only a single domain can be configured by providing configuration file.
* If no configuration file exists, the default domain is configured as 0.
*
*
* @param[in] domain The domain in which to create the participant (can be DDS_DOMAIN_DEFAULT). DDS_DOMAIN_DEFAULT is for using the domain in the configuration.
* @param[in] qos The QoS to set on the new participant (can be NULL).
* @param[in] listener Any listener functions associated with the new participant (can be NULL).
* @returns A valid participant handle or an error code.
*
* @retval >0
* A valid participant handle.
* @retval DDS_RETCODE_NOT_ALLOWED_BY_SECURITY
* An invalid DDS Security configuration was specified (whether
* that be missing or incorrect entries, expired certificates,
* or anything else related to the security settings and
* implementation).
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* Some security properties specified in the QoS, but the Cyclone
* build does not include support for DDS Security.
* @retval DDS_RETCODE_OUT_OF_RESOURCES
* Some resource limit (maximum participants, memory, handles,
* &c.) prevented creation of the participant.
* @retval DDS_RETCODE_ERROR
* The "CYCLONEDDS_URI" environment variable lists non-existent
* or invalid configuration files, or contains invalid embedded
* configuration items; or an unspecified internal error has
* occurred.
*/
DDS_EXPORT dds_entity_t
dds_create_participant(
const dds_domainid_t domain,
const dds_qos_t *qos,
const dds_listener_t *listener);
/**
* @brief Creates a domain with a given configuration
*
* To explicitly create a domain based on a configuration passed as a string.
*
* It will not be created if a domain with the given domain id already exists.
* This could have been created implicitly by a dds_create_participant().
*
* Please be aware that the given domain_id always takes precedence over the
* configuration.
*
* | domain_id | domain id in config | result
* +-----------+---------------------+----------
* | n | any (or absent) | n, config is used
* | n | m == n | n, config is used
* | n | m != n | n, config is ignored: default
*
* Config models:
* 1: <CycloneDDS>
* <Domain id="X">...</Domain>
* <Domain .../>
* </CycloneDDS>
* where ... is all that can today be set in children of CycloneDDS
* with the exception of the id
* 2: <CycloneDDS>
* <Domain><Id>X</Id></Domain>
* ...
* </CycloneDDS>
* legacy form, domain id must be the first element in the file with
* a value (if nothing has been set previously, it a warning is good
* enough)
*
* Using NULL or "" as config will create a domain with default settings.
*
*
* @param[in] domain The domain to be created. DEFAULT_DOMAIN is not allowed.
* @param[in] config A configuration string containing file names and/or XML fragments representing the configuration.
*
* @returns A valid entity handle or an error code.
*
* @retval DDS_RETCODE_BAD_PARAMETER
* Illegal value for domain id or the configfile parameter is NULL.
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* The domain already existed and cannot be created again.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
*/
DDS_EXPORT dds_entity_t
dds_create_domain(const dds_domainid_t domain, const char *config);
struct ddsi_config;
/**
* @brief Creates a domain with a given configuration, specified as an
* initializer (unstable interface)
*
* To explicitly create a domain based on a configuration passed as a raw
* initializer rather than as an XML string. This allows bypassing the XML
* parsing, but tightly couples the initializing to implementation. See
* dds/ddsi/ddsi_config.h:ddsi_config_init_default for a way to initialize
* the default configuration.
*
* It will not be created if a domain with the given domain id already exists.
* This could have been created implicitly by a dds_create_participant().
*
* Please be aware that the given domain_id always takes precedence over the
* configuration.
*
* @param[in] domain The domain to be created. DEFAULT_DOMAIN is not allowed.
* @param[in] config A configuration initializer. The lifetime of any pointers
* in config must be at least that of the lifetime of the domain.
*
* @returns A valid entity handle or an error code.
*
* @retval DDS_RETCODE_BAD_PARAMETER
* Illegal value for domain id or the config parameter is NULL.
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* The domain already existed and cannot be created again.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
*/
DDS_EXPORT dds_entity_t
dds_create_domain_with_rawconfig(const dds_domainid_t domain, const struct ddsi_config *config);
/**
* @brief Get entity parent.
*
* This operation returns the parent to which the given entity belongs.
* For instance, it will return the Participant that was used when
* creating a Publisher (when that Publisher was provided here).
*
* When a reader or a writer are created with a participant, then a
* subscriber or publisher are created implicitly.
* This function will return the implicit parent and not the used
* participant.
*
* @param[in] entity Entity from which to get its parent.
*
* @returns A valid entity handle or an error code.
*
* @retval >0
* A valid entity handle.
* @retval DDS_ENTITY_NIL
* Called with a participant.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to generic dds entity relations documentation. */
DDS_EXPORT dds_entity_t
dds_get_parent(dds_entity_t entity);
/**
* @brief Get entity participant.
*
* This operation returns the participant to which the given entity belongs.
* For instance, it will return the Participant that was used when
* creating a Publisher that was used to create a DataWriter (when that
* DataWriter was provided here).
*
* TODO: Link to generic dds entity relations documentation.
*
* @param[in] entity Entity from which to get its participant.
*
* @returns A valid entity or an error code.
*
* @retval >0
* A valid participant handle.
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_entity_t
dds_get_participant(dds_entity_t entity);
/**
* @brief Get entity children.
*
* This operation returns the children that the entity contains.
* For instance, it will return all the Topics, Publishers and Subscribers
* of the Participant that was used to create those entities (when that
* Participant is provided here).
*
* This functions takes a pre-allocated list to put the children in and
* will return the number of found children. It is possible that the given
* size of the list is not the same as the number of found children. If
* less children are found, then the last few entries in the list are
* untouched. When more children are found, then only 'size' number of
* entries are inserted into the list, but still complete count of the
* found children is returned. Which children are returned in the latter
* case is undefined.
*
* When supplying NULL as list and 0 as size, you can use this to acquire
* the number of children without having to pre-allocate a list.
*
* When a reader or a writer are created with a participant, then a
* subscriber or publisher are created implicitly.
* When used on the participant, this function will return the implicit
* subscriber and/or publisher and not the related reader/writer.
*
* @param[in] entity Entity from which to get its children.
* @param[out] children Pre-allocated array to contain the found children.
* @param[in] size Size of the pre-allocated children's list.
*
* @returns Number of children or an error code.
*
* @retval >=0
* Number of found children (can be larger than 'size').
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* The children parameter is NULL, while a size is provided.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
/* TODO: Link to generic dds entity relations documentation. */
DDS_EXPORT dds_return_t
dds_get_children(dds_entity_t entity, dds_entity_t *children, size_t size);
/**
* @brief Get the domain id to which this entity is attached.
*
* When creating a participant entity, it is attached to a certain domain.
* All the children (like Publishers) and childrens' children (like
* DataReaders), etc are also attached to that domain.
*
* This function will return the original domain ID when called on
* any of the entities within that hierarchy. For entities not associated