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
|
#ifndef CONDITIONMANAGER_H_
#define CONDITIONMANAGER_H_
#include "dds4ccm/idl/dds4ccm_BaseC.h"
#include "dds4ccm/impl/dds4ccm_conf.h"
#if (CIAO_DDS4CCM_NDDS==1)
#include "dds4ccm/impl/ndds/WaitSet.h"
#elif (CIAO_DDS4CCM_OPENDDS==1)
#include "dds/DCPS/WaitSet.h"
#endif
#include "dds4ccm/impl/dds4ccm_dds_impl_export.h"
namespace CCM_DDS
{
struct QueryFilter;
}
namespace CIAO
{
namespace DDS4CCM
{
/**
* @class ConditionManager
*
* @brief Helper class
*
* Manages the read and query conditions for the Getter,
* Reader and listeners.
*/
class DDS4CCM_DDS_IMPL_Export ConditionManager
{
public:
/// Constructor
ConditionManager (void);
/// Destructor
~ConditionManager (void);
/// Returns the read condition in general
::DDS::ReadCondition_ptr get_readcondition (void);
/// Returns the query condition for the getter
::DDS::QueryCondition_ptr get_querycondition_getter (void);
/// Returns the query condition for the reader
::DDS::QueryCondition_ptr get_querycondition_reader (void);
/// Returns the query condition for the listener
::DDS::QueryCondition_ptr get_querycondition_listener (void);
/**
* Proxy method.
* See WaitSet::check_handle in ndds/WaitSet.h
* for more information on this.
*
* If WaitSet::check_handle set 'error' to true, a
* ::CCM_DDS::InternalError exception is called.
* Error will be ::DDS::RETCODE_ERROR
*
* If WaitSet::check_handle set 'non_existent' to true,
* a ::CCM_DDS::NonExistent exception is thrown.
*/
::DDS::InstanceHandle_t check_handle (
DDS_INSTANCE_HANDLE_T_IN instance_handle,
DDS_INSTANCE_HANDLE_T_IN lookup_handle);
/**
* Getter functionality.
* Creates a read_condition for the getter.
* It will also initialize the waitset and attaches the
* read_condition to the waitset.
*/
void init_readcondition (void);
/**
* Getter functionality, waits for the attached conditions.
* Only returns true when one of the getter conditions has triggered
* and we have data
*/
bool wait (const ::DDS::Duration_t & time_out);
/**
* Returns the internal filter. This is the DDS4CCM QueryFilter
* (a representation of the DDS query).
*
* If the QueryFilter hasn't been initialized, a ::CCM_DDS::InternalError
* exception with error code ::DDS::RETCODE_ERROR is thrown.
*/
::CCM_DDS::QueryFilter * query (void);
/**
* Sets the DDS4CCM query filter.
* The following rules apply when a filter is set:
*
* If there's a read condition set, this will be removed.
* The read condition is replaced by a query condition.
*
* If there're no query conditions yet (i.e. the filter hasn't
* been set before), three query conditions are created:
* 1. One for the Getter
* 2. One for the Reader
* 3. One for the Listener
* Each query condition has it's own sample_state,
* instance_state and view_state set but the filters are
* the same.
*
* Off course the query condition for the getter will be
* attached to the waitset.
*
* If the internal filter has already been set, this method sets
* the new parameters for this filter on all three query conditions.
*
* If the filter expression (the actual query) is empty, all three query
* conditions will be removed (the query condition for the getter will be
* detached from the waitset first) and the initial read condition will
* created (see init_readcondition()).
*/
void query (const ::CCM_DDS::QueryFilter & filter);
/**
* Sets the internal datareader.
* Applies to Getter, Reader and Listener
*/
void set_dds_entity (::DDS::DataReader_ptr dr);
/**
* Retrieves the internal datareader.
*/
::DDS::DataReader_ptr get_dds_entity (void);
/**
* Detaches conditions from the waitset and
* removes all conditions by calling
* delete_readcondition on the DataReader.
*/
void passivate (void);
private:
::DDS::DataReader_var dr_;
//TODO: Not allowed
#if (CIAO_DDS4CCM_NDDS==1)
::CIAO::NDDS::DDS_WaitSet_i ws_;
#elif (CIAO_DDS4CCM_OPENDDS==1)
::DDS::WaitSet ws_;
#endif
/**
* Different QueryConditions since the sample mask
* differs for all entities.
*/
::DDS::QueryCondition_var qc_reader_;
::DDS::QueryCondition_var qc_getter_;
::DDS::QueryCondition_var qc_listener_;
::DDS::ReadCondition_var rd_condition_;
/**
* Internal getter for the DataReader.
* If the internal dds_entity is not set before this method
* is called, a CORBA::BAD_INV_ORDER exception is thrown.
*/
::DDS::DataReader_ptr dds_entity (void);
/**
* Removes the internal (read/query) condition by invoking
* delete_condition on the DataReader.
*/
void remove_condition (::DDS::QueryCondition_ptr qc,
const char * type);
/**
* Calling 'remove_condition' for each query and read
* condition.
*
* The query condition for the getter will be detached from
* the waitset first.
*/
void remove_conditions (void);
/**
* Getter functionality.
*
* Attaches the query condition for the getter to the
* waitset. It the waitset doesn't exist, it will be
* created.
*/
void attach_querycondition (void);
/**
* Generic method which sets the parameters of the given
* filter on the given query condition.
*/
void set_parameters (const ::CCM_DDS::QueryFilter & filter,
::DDS::QueryCondition_ptr qc);
};
}
}
#endif /* CONDITIONMANAGER_H_ */
|