RTI Connext DDS Micro  Version 2.4.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dds_c_wh_plugin.h
Go to the documentation of this file.
1 /*
2  * FILE: dds_c_wh_plugin.h - DDS writer history interface
3  *
4  * (c) Copyright, Real-Time Innovations, 2011-2015.
5  *
6  * All rights reserved.
7  *
8  * No duplications, whole or partial, manual or electronic, may be made
9  * without express written permission. Any such copies, or
10  * revisions thereof, must display this notice unaltered.
11  * This code contains trade secrets of Real-Time Innovations, Inc.
12  *
13  * Modification History
14  * --------------------
15  * 04nov2015,tk MICRO-1505 Reduce memory footprint
16  * 24feb2014,tk MICRO-714: Updated for improved writer history API.
17  * 03feb2014,eh MICRO-714: acknack_sample, on_sample_removed
18  * 16aug2011,tk Written
19  */
20 /*ce
21  * \file
22  * \brief DDS writer history interface
23  */
24 /*ci \defgroup DDSHistoryModule DDS History module
25  * \ingroup DDSCModule
26  */
27 /*ci \defgroup DDSWriterHistoryModule DDS Writer History module
28  * \ingroup DDSHistoryModule
29  */
30 /*ci \addtogroup DDSWriterHistoryModule
31  * @{
32  */
33 #ifndef dds_c_wh_plugin_h
34 #define dds_c_wh_plugin_h
35 
36 #ifndef rt_rt_h
37 #include "rt/rt_rt.h"
38 #endif
39 #ifndef dds_c_topic_h
40 #include "dds_c/dds_c_topic.h"
41 #endif
42 #ifndef dds_c_dll_h
43 #include "dds_c/dds_c_dll.h"
44 #endif
45 #ifndef dds_c_discovery_h
46 #include "dds_c/dds_c_discovery.h"
47 #endif
48 #ifndef dds_c_type_h
49 #include "dds_c/dds_c_type.h"
50 #endif
51 
52 #ifdef __cplusplus
53 extern "C"
54 {
55 #endif
56 
57 /*ce
58  * \brief Default writer history plug-in name
59  */
60 DDSCDllVariable extern const char* const DDSHST_WRITER_DEFAULT_HISTORY_NAME;
61 
62 /*ci
63  * \brief Enumeration of supported writer history events
64  */
65 typedef enum
66 {
67  /*ci
68  * \brief The deadline timer expired, check deadlines
69  */
70  DDSHST_WRITEREVENT_KIND_DEADLINE_EXPIRED = 1,
71 
72  /*ci
73  * \brief A late joiner is requesting historical data
74  */
75  DDSHST_WRITEREVENT_KIND_HISTORICAL_DATA_REQUESTED
76 } DDSHST_WriterEventKind_T;
77 
78 /*ci
79  * \brief A writer history event that can be posted to the cache
80  */
81 struct DDSHST_WriterEvent
82 {
83  /*ci
84  * \brief The event type
85  */
86  DDSHST_WriterEventKind_T kind;
87 };
88 
89 /*ci
90  * \brief Base-class for writer history cache
91  */
92 struct DDSHST_Writer
93 {
94  struct RT_Component _parent;
95 };
96 
97 typedef struct DDSHST_Writer DDSHST_Writer_T;
98 
99 struct DDSHST_WriterSampleEntry;
100 
101 /*ci
102  * \brief Implementation independent reference to a sample in the
103  * writer history cache
104  */
105 typedef struct DDSHST_WriterSampleEntry* DDSHST_WriterSampleEntryRef_T;
106 
107 /*ci
108  * \brief Implementation independent writer cache sample
109  */
110 typedef struct DDSHST_WriterSample
111 {
112  /*ci
113  * \brief Reference to the corresponding entry in the implementation specific
114  * cache
115  */
116  DDSHST_WriterSampleEntryRef_T _ref;
117 } DDSHST_WriterSample_T;
118 
119 /*ci
120  * \brief The current state of the writer cache
121  */
122 struct DDSHST_WriterState
123 {
124  /*ci
125  * \brief The lowest SN available, across all instances
126  */
127  struct REDA_SequenceNumber low_sn;
128 
129  /*ci
130  * \brief The highest SN available, across all instances
131  */
132  struct REDA_SequenceNumber high_sn;
133 
134  /*ci
135  * \brief The lowest historical SN available, across all instances
136  */
137  struct REDA_SequenceNumber history_low_sn;
138 
139  /*ci
140  * \brief The highest historical SN available, across all instances
141  */
142  struct REDA_SequenceNumber history_high_sn;
143 };
144 
145 /*ci
146  * \brief Base-class properties for the DDS writer history cache
147  */
148 struct DDSHST_WriterProperty
149 {
150  /*ci
151  * \brief Inherit from a component
152  */
153  struct RT_ComponentProperty _parent;
154 
155  /*ci
156  * \brief Pointer to the qos policy for the DDS writer that uses the history
157  * cache
158  */
159  struct DDS_DataWriterQos *qos;
160 };
161 
162 /*ci
163  * \brief Constant to initialize \ref DDSHST_WriterProperty
164  */
165 #define DDSHST_WriterProperty_INITIALIZER \
166 {\
167  RT_ComponentProperty_INITIALIZER,\
168  NULL\
169 }
170 
171 /*ci
172  * \brief Enumeration of the different reasons a sample was removed from the
173  * writer cache
174  */
175 typedef enum
176 {
177  /*ci
178  * \brief Normal removal, the cache no longer needs this sample
179  */
180  DDSHST_WRITER_SAMPLE_REMOVED_NORMAL,
181 
182  /*ci
183  * \brief A sample was forcefully removed to make space, 1 or reliable readers
184  * did not receive it
185  */
186  DDSHST_WRITER_SAMPLE_REMOVED_UNACKED,
187 
188  /*ci
189  * \brief The sample was removed because the key was unregistered
190  */
191  DDSHST_WRITER_SAMPLE_REMOVED_KEY_UNREGISTERED,
192 
193  /*ci
194  * \brief The sample was removed because the key was disposed
195  */
196  DDSHST_WRITER_SAMPLE_REMOVED_KEY_DISPOSED,
197 
198  /*ci
199  * \brief The sample was removed because the resource limit for samples
200  * per instance was reached and KEEP_LAST is in effect
201  */
202  DDSHST_WRITER_SAMPLE_REMOVED_MAX_SAMPLES_PER_INSTANCE
203 } DDSHST_WriterSampleRemovedKind_T;
204 
205 /*ci
206  * \brief Enumeration of the different reasons a key was removed from the
207  * writer cache
208  */
209 typedef enum
210 {
211  /*ci
212  * \brief Normal removal, the key is no longer needed
213  */
214  DDSHST_WRITER_KEY_REMOVED_NORMAL,
215 
216  /*ci
217  * \brief The key was removed due to being unregistered
218  */
219  DDSHST_WRITER_KEY_REMOVED_UNREGISTERED,
220 
221  /*ci
222  * \brief The key was removed due to being disposed of
223  */
224  DDSHST_WRITER_KEY_REMOVED_DISPOSED,
225 
226  /*ci
227  * \brief The key was removed due to being deleted
228  */
229  DDSHST_WRITER_KEY_REMOVED_DELETED
230 } DDSHST_WriterKeyRemovedKind_T;
231 
232 /*ci
233  * \brief Enumeration of the different types of queue entries
234  */
235 typedef enum
236 {
237  /*ci
238  * \brief The empty entry, used when an entry is only registered
239  */
240  DDSHST_WRITER_ENTRY_NONE,
241 
242  /*ci
243  * \brief Normal user data entry
244  */
245  DDSHST_WRITER_ENTRY_NORMAL,
246 
247  /*ci
248  * \brief The sample is the result of an unregister operation
249  */
250  DDSHST_WRITER_ENTRY_UNREGISTER,
251 
252  /*ci
253  * \brief The sample is the result of a dispose operation
254  */
255  DDSHST_WRITER_ENTRY_DISPOSE,
256 
257  /*ci
258  * \brief The sample is the result of a unregister and dispose operation
259  */
260  DDSHST_WRITER_ENTRY_UNREGISTER_DISPOSE
261 } DDSHST_WriterEntryKind_T;
262 
263 /*ci
264  * \brief The current state of an instance in the instance cache if it exists
265  */
266 struct DDSHST_InstanceState
267 {
268  /*ci The number of samples owned by the instance
269  */
270  RTI_INT32 sample_count;
271 
272  /*ci The type of the last sample added for the instance
273  */
274  DDSHST_WriterEntryKind_T last_sample_kind;
275 };
276 
277 /*ci
278  * \def DDSHST_WRITER_ACKCOUNT_ANY
279  * \brief Constant to indicate that the number of ACKNACKs for a sample is
280  * not relevant
281  */
282 #define DDSHST_WRITER_ACKCOUNT_ANY (0)
283 
284 /*ci
285  * \brief Definition of the \ref DDSHST_WriterListener on_sample_removed callback
286  *
287  * \details
288  * When the history cache removes a sample it calls this listener if it is
289  * installed.
290  *
291  * \param[in] listener_data Opaque pointer to listener data
292  * \param[in] key The key the sample belonged too
293  * \param[in] sample The sample being removed
294  * \param[in] sn The sequence number of the removed sample
295  * \param[in] kind The reason the sample is removed
296  * \param[in] ack_count The current number of acknowledgment on the sample
297  */
298 typedef void
299 (*DDSHST_WriterListener_OnSampleRemovedFunc)(
300  void *listener_data,
302  struct DDSHST_WriterSample *sample,
303  struct REDA_SequenceNumber *sn,
304  DDSHST_WriterSampleRemovedKind_T kind,
305  DDS_Long ack_count);
306 /*ci
307  * \brief Definition of the \ref DDSHST_WriterListener on_deadline_missed callback
308  *
309  * \details
310  * When an instance is not being updated according to the deadline the cache
311  * calls this listener if it is installed.
312  *
313  * \param[in] listener_data Opaque pointer to listener data
314  * \param[in] key The key that missed its deadline
315  */
316 typedef void
317 (*DDSHST_WriterListener_OnDeadlineMissedFunc)(void *listener_data,
318  DDS_InstanceHandle_t *key);
319 
320 /*ci
321  * \brief Definition of the \ref DDSHST_WriterListener on_key_removed callback
322  *
323  * \details
324  * When the history cache removes a key it calls this listener if it is
325  * installed.
326  *
327  * \param[in] listener_data Opaque pointer to listener data
328  * \param[in] key The key being removed
329  * \param[in] kind The reason for removing the key
330  */
331 typedef void
332 (*DDSHST_WriterListener_OnKeyRemovedFunc)(void *listener_data,
334  DDSHST_WriterKeyRemovedKind_T kind);
335 
336 /*ci
337  * \brief Base-class for DDS Writer history listener
338  */
339 struct DDSHST_WriterListener
340 {
341  /*ci
342  * \brief Inherit from parent class
343  */
344  struct RT_ComponentListener _parent;
345 
346  /*ci
347  * \brief Called when the cache removed a sample
348  */
349  DDSHST_WriterListener_OnSampleRemovedFunc on_sample_removed;
350 
351  /*ci
352  * \brief Called when the cache removed a key
353  */
354  DDSHST_WriterListener_OnKeyRemovedFunc on_key_removed;
355 
356  /*ci
357  * \brief Called when the cache detected deadline missed on an instance
358  */
359  DDSHST_WriterListener_OnDeadlineMissedFunc on_deadline_missed;
360 
361  /*ci
362  * \brief Opaque listener data passed back to listener functions
363  */
364  void *listener_data;
365 };
366 
367 /*ci
368  * \brief Constant to initialize \ref DDSHST_WriterListener
369  */
370 #define DDSHST_WriterListener_INITIALIZE {\
371  RT_ComponentListener_INITIALIZER,\
372  NULL,\
373  NULL,\
374  NULL,\
375  NULL\
376 }
377 
378 /* ------------------------------ Life-cycle -------------------------------- */
379 /*ci
380  * \brief Definition of \ref RT_ComponentFactory delete_component method
381  *
382  * \param[in] self The writer history instance to delete
383  *
384  * \sa \ref RT_ComponentFactoryI
385  */
386 typedef void
387 (*DDSHST_Writer_deleteFunc)(struct DDSHST_Writer *self);
388 
389 /*ci
390  * \brief Definition of \ref RT_ComponentFactory create_component method
391  *
392  * \param[in] property The component property
393  * \param[in] listener The component listener
394  *
395  * \return A reference to a new writer cache on success, NULL otherwise
396  *
397  * \sa \ref RT_ComponentFactoryI
398  */
399 FUNCTION_MUST_TYPEDEF(
400 struct DDSHST_Writer*
401 (*DDSHST_Writer_createFunc) (const struct DDSHST_WriterProperty* const property,
402  const struct DDSHST_WriterListener* const listener)
403 )
404 
405 /* ------------------------------- Methods ---------------------------------- */
406 /*ci
407  * \brief Definition of \ref DDSHST_WriterI get_entry method
408  *
409  * \param[in] self The writer cache to get an entry from
410  * \param[in] key The key to get an entry for
411  * \param[in] kind The kind of entry (dispose, unregister, normal etc.)
412  * \param[in] assert_key If TRUE, assert the key if it does not already exist.
413  * Otherwise return NULL if the key does not exist.
414  * \param[in] source_ts The source time stamp this instance was registered.
415  *
416  * \return A reference to new entry if there is space, NULL otherwise
417  *
418  * \sa \ref DDSHST_Writer_get_entry, \ref DDSHST_WriterI
419  */
420 FUNCTION_MUST_TYPEDEF(
421 DDSHST_WriterSampleEntryRef_T
422 (*DDSHST_Writer_get_entryFunc)(struct DDSHST_Writer *self,
423  const DDS_InstanceHandle_t *const key,
424  DDSHST_WriterEntryKind_T kind, RTI_BOOL assert_key,
425  struct OSAPI_NtpTime *source_ts);
426 )
427 
428 /*ci
429  * \brief Definition of \ref DDSHST_WriterI return_entry method
430  *
431  * \details
432  * Return an entry to the cache
433  *
434  * \param[in] self The history cache
435  * \param[in] entry A reference to the entry to return
436  *
437  * \sa \ref DDSHST_Writer_return_entry, \ref DDSHST_WriterI
438  */
439 typedef void
440 (*DDSHST_Writer_return_entryFunc)(struct DDSHST_Writer *self,
441  DDSHST_WriterSampleEntryRef_T const entry);
442 
443 /*ci
444  * \brief Definition of \ref DDSHST_WriterI commit_entry method
445  *
446  * \details
447  * Method to commit a a sample to the cache
448  *
449  * \param[in] self The history cache
450  * \param[out] sample The requested sample if found, NULL otherwise
451  * \param[in] sn The requested SN
452  * \param[out] sn_ge The first available SN
453  * \param[in] h Whether only historical samples are relevant
454  *
455  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref DDSHST_ReturnCode_T
456  * on failure
457  *
458  * \sa \ref DDSHST_Writer_commit_entry, \ref DDSHST_WriterI
459  */
460 FUNCTION_MUST_TYPEDEF(
461 DDSHST_ReturnCode_T
462 (*DDSHST_Writer_commit_entryFunc)(struct DDSHST_Writer * self,
463  DDSHST_WriterSampleEntryRef_T entry,
464  DDSHST_WriterSample_T *const sample,
465  const struct REDA_SequenceNumber *const sn,
466  DDS_Long ack_count)
467 )
468 
469 /*ci
470  * \brief Definition of \ref DDSHST_WriterI request_sample method
471  *
472  * \details
473  * Method to request a sample from the cache
474  *
475  * \param[in] self The history cache
476  * \param[out] sample The requested sample if found, NULL otherwise
477  * \param[in] sn The requested SN
478  * \param[out] sn_ge The first available SN
479  * \param[in] h Whether only historical samples are relevant
480  *
481  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref DDSHST_ReturnCode_T
482  * on failure
483  *
484  * \sa \ref DDSHST_Writer_request_sample, \ref DDSHST_WriterI
485  */
486 FUNCTION_MUST_TYPEDEF(
487 DDSHST_ReturnCode_T
488 (*DDSHST_Writer_request_sampleFunc)(struct DDSHST_Writer *self,
489  struct DDSHST_WriterSample **sample,
490  const struct REDA_SequenceNumber *const req_sn,
491  struct REDA_SequenceNumber *const sn_ge,
492  DDS_Boolean historical_only)
493 )
494 
495 /*ci
496  * \brief Definition of \ref DDSHST_WriterI acknack_sample method
497  *
498  * \details
499  * Method to ACK or NACK a sample in the queue
500  *
501  * \param[in] self The writer cache
502  * \param[in] sn The SN to ACKNACK
503  * \param[in] nack Whether this is a NACK (DDS_BOOLEAN_TRUE) or ACK
504  * (DDS_BOOLEAN_FALSE)
505  *
506  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref
507  * DDSHST_ReturnCode_T on failure
508  *
509  * \sa \ref DDSHST_Writer_acknack_sample, \ref DDSHST_WriterI
510  */
511 FUNCTION_MUST_TYPEDEF(
512 DDSHST_ReturnCode_T
513 (*DDSHST_Writer_acknack_sampleFunc)(struct DDSHST_Writer *self,
514  const struct REDA_SequenceNumber *const sn,
515  DDS_Boolean nack)
516 )
517 
518 /*ci
519  * \brief Definition of \ref DDSHST_WriterI register_key method
520  *
521  * \details
522  * Method to add a key to the cache if there is space
523  *
524  * \param[in] self The history cache
525  * \param[in] key The key to add to the cache
526  *
527  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref
528  * DDSHST_ReturnCode_T on failure
529  *
530  * \sa \ref DDSHST_Writer_register_key, \ref DDSHST_WriterI
531  */
532 FUNCTION_MUST_TYPEDEF(
533 DDSHST_ReturnCode_T
534 (*DDSHST_Writer_register_keyFunc)(struct DDSHST_Writer *self,
535  const DDS_InstanceHandle_t *const key,
536  const struct OSAPI_NtpTime *timestamp)
537 )
538 
539 /*ci
540  * \brief Definition of \ref DDSHST_WriterI get_state method
541  *
542  * \details
543  * Return the current state of the writer cache.
544  *
545  * \param[in] self The history cache
546  *
547  * \return Pointer to the structure containing the state
548  *
549  * \sa \ref DDSHST_Writer_get_state, \ref DDSHST_WriterI
550  */
551 FUNCTION_MUST_TYPEDEF(
552 struct DDSHST_WriterState*
553 (*DDSHST_Writer_get_stateFunc)(struct DDSHST_Writer *self)
554 )
555 
556 /*ci
557  * \brief Definition of \ref DDSHST_WriterI post_event method
558  *
559  * \details
560  * Handle possible events posted to the cache by the user.
561  *
562  * \param[in] self The history cache
563  * \param[in] event The event
564  * \param[in] now The time of the event
565  *
566  * \sa \ref DDSHST_Writer_post_event, \ref DDSHST_WriterI
567  */
568 typedef void
569 (*DDSHST_Writer_post_eventFunc)(struct DDSHST_Writer *self,
570  struct DDSHST_WriterEvent *event,
571  struct OSAPI_NtpTime *now);
572 
573 /*ci
574  * \brief Definition of \ref DDSHST_WriterI get_instance_state method
575  *
576  * \details
577  * Return the state of an instance if it exists
578  *
579  * \param[in] self The history cache
580  * \param[in] key The key to retrieve state for
581  * \param[out] state The current state of an instance, if found
582  *
583  * \return DDSHST_RETCODE_NOT_EXISTS if the instance does not exist,
584  * DDSHST_RETCODE_OK if the instance exists
585  */
586 typedef DDSHST_ReturnCode_T
587 (*DDSHST_Writer_get_instance_stateFunc)(struct DDSHST_Writer *self,
588  const DDS_InstanceHandle_t *const key,
589  struct DDSHST_InstanceState *state);
590 
591 /*ci
592  * \brief Definition of \ref DDSHST_WriterI unregister_key method
593  *
594  * \details
595  * Unregister a key from the history. Note that this is not the same as a DDS
596  * unregister_instance. Unregistering a key simple deletes it from the
597  * writer's cache without any instance updates.
598  *
599  * \param[in] self The history cache
600  * \param[in] key The key to unregister
601  *
602  * \return DDSHST_RETCODE_OK on success, DDSHST_RETCODE_NOT_EXISTS if the
603  * instance does not exist.
604  */
605 typedef DDSHST_ReturnCode_T
606 (*DDSHST_Writer_unregister_keyFunc)(struct DDSHST_Writer *self,
607  const DDS_InstanceHandle_t *const key);
608 
609 
610 /*ci
611  * \brief Definition of the DDS Writer History interface
612  */
613 struct DDSHST_WriterI
614 {
615  /*ci
616  * \brief Base-class interface
617  */
618  struct RT_ComponentI _parent;
619 
620  /*ci
621  * \brief Method to get an entry from the cache, if available
622  */
623  DDSHST_Writer_get_entryFunc get_entry;
624 
625  /*ci
626  * \brief Method to return an entry back to the cache if not needed
627  */
628  DDSHST_Writer_return_entryFunc return_entry;
629 
630  /*ci
631  * \brief Method to commit an entry to the cache
632  */
633  DDSHST_Writer_commit_entryFunc commit_entry;
634 
635  /*ci
636  * \brief Method to request an entry from the cache
637  */
638  DDSHST_Writer_request_sampleFunc request_sample;
639 
640  /*ci
641  * \brief Method to ACK or NACK an entry in the cache
642  */
643  DDSHST_Writer_acknack_sampleFunc acknack_sample;
644 
645  /*ci
646  * \brief Method to register a key in the cache, if possible
647  */
648  DDSHST_Writer_register_keyFunc register_key;
649 
650  /*ci
651  * \brief Method to get the current state of the writer cache
652  */
653  DDSHST_Writer_get_stateFunc get_state;
654 
655  /*ci
656  * \brief Method to post an event to the writer cache
657  */
658  DDSHST_Writer_post_eventFunc post_event;
659 
660  /*ci
661  * \brief Method to retrieve the instance state
662  */
663  DDSHST_Writer_get_instance_stateFunc get_instance_state;
664 
665  /*ci
666  * \brief Method to unregister a key
667  */
668  DDSHST_Writer_unregister_keyFunc unregister_key;
669 };
670 
671 /*ci
672  * \brief Wrapper to call of the DDSHST_WriterFactory->create_component
673  *
674  * \param[in] f_ The writer history factory
675  * \param[in] p_ The property
676  * \param[in] l_ The listener
677  *
678  * \return A reference to new writer cache on success, NULL otherwise
679  */
680 #define DDSHST_WriterFactory_create_component(f_,p_,l_) \
681  (struct DDSHST_Writer*)((f_)->intf)->create_component(f_,p_,l_)
682 
683 /*ci
684  * \brief Wrapper to call of the DDSHST_WriterFactory->delete_component
685  *
686  * \param[in] f_ The writer history factory
687  * \param[in] c_ The cache to delete
688  */
689 #define DDSHST_WriterFactory_delete_component(f_,c_) \
690  ((f_)->intf)->delete_component(f_,(RT_Component_T*)(c_))
691 
692 /*ci
693  * \brief Wrapper to call of the DDSHST_WriterI->get_entry
694  *
695  * \param[in] self_ The writer cache to get an entry from
696  * \param[in] key_ The key to get an entry for
697  * \param[in] kind_ The kind of entry (dispose, unregister, normal etc.)
698  * \param[in] assert_key_ If TRUE, assert the key if it does not already exist.
699  * Otherwise return NULL if the key does not exist.
700  * \param[in] ts_ The source time stamp for the sample
701  *
702  * \return A reference to new entry if there is space, NULL otherwise
703  */
704 #define DDSHST_Writer_get_entry(self_,key_,kind_,assert_key_,ts_) \
705  ((struct DDSHST_WriterI*)(\
706  (self_)->_parent._intf))->get_entry(self_,key_,kind_,assert_key_,ts_)
707 
708 /*ci
709  * \brief Wrapper to call of the DDSHST_WriterI->return_entry function
710  *
711  * \details
712  * Return an entry to cache, it is unused
713  *
714  * \param[in] self_ The history cache
715  * \param[in] entry_ A reference to the entry to return
716  */
717 #define DDSHST_Writer_return_entry(self_,entry_) \
718  ((struct DDSHST_WriterI*)(\
719  (self_)->_parent._intf))->return_entry(self_,entry_)
720 
721 /*ci
722  * \brief Wrapper to call of the DDSHST_WriterI->commit_entry function
723  *
724  * \details
725  * Commit an entry to the writer cache, updating the state of the cache.
726  * The ack_count_ is the expected number of acknowledgments before the sample
727  * SN can be marked as ACK'ed
728  *
729  * \param[in] self_ The writer cache
730  * \param[in] entry_ A reference to a previously allocated entry
731  * \param[in] sample_ The entries's payload (opaque to the cache)
732  * \param[in] sn_ The sequence number of the entry
733  * \param[in] ack_count_ The expected number of acknowledgment for this sample
734  * based on the number of reliable peers
735  *
736  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref
737  * DDSHST_ReturnCode_T on failure
738  */
739 #define DDSHST_Writer_commit_entry(self_,entry_,sample_,sn_,ack_count_) \
740  ((struct DDSHST_WriterI*)(\
741  (self_)->_parent._intf))->commit_entry(self_,entry_,\
742  sample_,sn_,ack_count_)
743 
744 /*ci
745  * \brief Wrapper to call of the DDSHST_WriterI->request_sample function
746  *
747  * \details
748  * Return a reference to a history sample based on the requested SN.
749  * A sample that is requested is automatically considered
750  * unacknowledged and will not be removed from the queue unless forced by an
751  * ACKNACK. Thus, a sample which was ACK'ed may go back to UNACK'ed state. A
752  * request does not change the history.
753  * \p
754  * The cache can search in all samples or only the historical samples
755  * based on the historical_only flag. This function always returns the next
756  * available SN if the requested cannot be found. If the requested SN is found
757  * the first available is set to the requested SN.
758  *
759  * \param[in] self_ The history cache
760  * \param[out] sample_ The requested sample if found, NULL otherwise
761  * \param[in] sn_ The requested SN
762  * \param[out] sn_ge_ The first available SN
763  * \param[in] h_ Whether only historical samples are relevant
764  *
765  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref DDSHST_ReturnCode_T
766  * on failure
767  */
768 #define DDSHST_Writer_request_sample(self_,sample_,sn_,sn_ge_,h_) \
769  ((struct DDSHST_WriterI*)(\
770  (self_)->_parent._intf))->request_sample(self_,sample_,sn_,sn_ge_,h_)
771 
772 /*ci
773  * \brief Wrapper to call of the DDSHST_WriterI->acknack_sample function
774  *
775  * \details
776  * When a SN is ACK'ed it tells the queue that as far as the external
777  * view is concerned that sample is no longer needed. However, the queue
778  * can be configured to keep samples to delivery to late joiners.
779  *
780  * There are 3 types of sample that can be ACK'ed:
781  * - normal sample: This is regular user-data and does not change the key state.
782  * Normal data samples that are ACK'ed are usually returned to
783  * the buffer-pool or kept around for history.
784  * - unregister sample: An ACK'ed unregister sample means that everybody has
785  * acknowledged the unregistration from this queue. If
786  * there are no more samples in the queue then the
787  * key will be reclaimed. If the key is not empty then
788  * the key resources are not reclaimed.
789  * - dispose sample: An ACK'ed dispose sample means that everybody has
790  * acknowledged the disposal from this queue. However,
791  * disposed keys cannot be reclaimed.
792  *
793  * If NACK is DDS_BOOLEAN true the sample was not delivered to all, but
794  * it can be removed as no further attempts to deliver it will be made.
795  *
796  * \param[in] self_ The writer cache
797  * \param[in] sn_ The SN to ACKNACK
798  * \param[in] nack_ Whether this is a NACK (DDS_BOOLEAN_TRUE) or ACK
799  * (DDS_BOOLEAN_FALSE)
800  *
801  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref
802  * DDSHST_ReturnCode_T on failure
803  */
804 #define DDSHST_Writer_acknack_sample(self_,sn_,nack_) \
805 ((struct DDSHST_WriterI*)(\
806  (self_)->_parent._intf))->acknack_sample(self_,sn_,nack_)
807 
808 /*ci
809  * \brief Wrapper to call of the DDSHST_WriterI->register_key function
810  *
811  * \details
812  * Add a key to the cache if there is space.
813  *
814  * \param[in] self_ The history cache
815  * \param[in] key_ The key to add to the cache
816  * \paran[in] ts_ The timestamp of the operation
817  *
818  * \return DDSHST_RETCODE_SUCCESS on success, one of \ref
819  * DDSHST_ReturnCode_T on failure
820  */
821 #define DDSHST_Writer_register_key(self_,key_,ts_) \
822  ((struct DDSHST_WriterI*)(\
823  (self_)->_parent._intf))->register_key(self_,key_,ts_)
824 
825 /*ci
826  * \brief Wrapper to call the \ref DDSHST_WriterI::get_state function
827  *
828  * \details
829  * Return the current state of the writer cache. This information
830  * is used to determine which sequence numbers are relevant when
831  * the durability is in effect.
832  *
833  * \param[in] self_ The history cache
834  *
835  * \return Pointer to the structure containing the state
836  */
837 #define DDSHST_Writer_get_state(self_) \
838  ((struct DDSHST_WriterI*)(\
839  (self_)->_parent._intf))->get_state(self_)
840 
841 /*ci
842  * \brief Wrapper to call the \ref DDSHST_WriterI ->post_event function
843  *
844  * \details
845  * Handle possible events posted to the cache by the user. The events
846  * handled are deadline tests (the deadline timer is not owned by the cache)
847  * and update expected ACKNACKs when a reliable late joiner as added. Note
848  * that the cache does not keep track of peers, only how many there are.
849  *
850  * \param[in] self_ The history cache
851  * \param[in] event_ The event
852  * \param[in] time_ The time of the event
853  */
854 #define DDSHST_Writer_post_event(self_,event_,time_) \
855  ((struct DDSHST_WriterI*)(\
856  (self_)->_parent._intf))->post_event(self_,event_,time_)
857 
858 /*ci
859  * \brief Wrapper to call \ref DDSHST_WriterI ->get_instance_state method
860  *
861  * \details
862  * Return the state of in instance if it exists
863  *
864  * \param[in] self_ The history cache
865  * \param[in] key_ The key to retrieve state for
866  * \param[out] state_ The current state of an instance, if found
867  *
868  * \return DDSHST_RETCODE_NOT_EXISTS if the instance does not exists,
869  * DDSHST_RETCODE_OK if the instance exists
870  */
871 #define DDSHST_Writer_get_instance_state(self_,key_,state_) \
872  ((struct DDSHST_WriterI*)(\
873  (self_)->_parent._intf))->get_instance_state(self_,key_,state_)
874 
875 /*ci
876  * \brief Wrapper to call \ref DDSHST_WriterI ->unregister_key method
877  *
878  * \details
879  * Unregister a key from the history. Note that this is not the same as a DDS
880  * unregister_instance. Unregistering a key simple deletes it from the
881  * writer's cache without any instance updates.
882  *
883  * \param[in] self_ The history cache
884  * \param[in] key_ The key to unregister
885  *
886  * \return DDSHST_RETCODE_OK on success, DDSHST_RETCODE_NOT_EXISTS if the
887  * instance does not exist.
888  */
889 #define DDSHST_Writer_unregister_key(self_,key_) \
890  ((struct DDSHST_WriterI*)(\
891  (self_)->_parent._intf))->unregister_key(self_,key_)
892 
893 #ifdef __cplusplus
894 } /* extern "C" */
895 #endif
896 
897 
898 #endif /* dds_c_wh_plugin_h */
899 
900 /*ci @} */

RTI Connext DDS Micro Version 2.4.10 Copyright © Fri Jun 30 2017 Real-Time Innovations, Inc