OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
QueryConditionImpl.hpp
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2021 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #ifndef OSPL_DDS_SUB_COND_TQUERYCONDITION_IMPL_HPP_
22 #define OSPL_DDS_SUB_COND_TQUERYCONDITION_IMPL_HPP_
23 
28 /*
29  * OMG PSM class declaration
30  */
32 #include <org/opensplice/sub/cond/QueryConditionDelegate.hpp>
33 
34 // Implementation
35 
36 namespace dds
37 {
38 namespace sub
39 {
40 namespace cond
41 {
42 
43 
45  const dds::sub::Query& query,
46  const dds::sub::status::DataState& status)
47 {
48  ISOCPP_REPORT_STACK_DDS_BEGIN(query);
49 
50  this->set_ref(new DELEGATE(query.data_reader(),
51  query.expression(), query.delegate()->parameters(), status));
52  this->delegate()->init(this->impl_);
53 }
54 
59 template <typename FUN>
61  const dds::sub::Query& query,
62  const dds::sub::status::DataState& status, FUN& functor)
63 {
64  ISOCPP_REPORT_STACK_DDS_BEGIN(query);
65 
66  this->set_ref(new DELEGATE(query.data_reader(),
67  query.expression(), query.delegate()->parameters(), status));
68  this->delegate()->set_handler(functor);
69  this->delegate()->init(this->impl_);
70 
71 }
72 
73 
74 template <typename FUN>
76  const dds::sub::Query& query,
77  const dds::sub::status::DataState& status, const FUN& functor)
78 {
79  ISOCPP_REPORT_STACK_DDS_BEGIN(query);
80 
81  this->set_ref(new DELEGATE(query.data_reader(),
82  query.expression(), query.delegate()->parameters(), status));
83  this->delegate()->set_handler(functor);
84  this->delegate()->init(this->impl_);
85 
86 }
91  const dds::sub::AnyDataReader& dr,
92  const std::string& expression,
93  const std::vector<std::string>& params,
94  const dds::sub::status::DataState& status)
95 {
96  ISOCPP_REPORT_STACK_DDS_BEGIN(dr);
97 
98  this->set_ref(new DELEGATE(dr, expression, params, status));
99  this->delegate()->init(this->impl_);
100 }
101 
106 template <typename FUN>
108  const dds::sub::AnyDataReader& dr,
109  const std::string& expression,
110  const std::vector<std::string>& params,
111  const dds::sub::status::DataState& status,
112  FUN& functor)
113 {
114  ISOCPP_REPORT_STACK_DDS_BEGIN(dr);
115 
116  this->set_ref(new DELEGATE(dr, expression, params, status));
117  this->delegate()->set_handler(functor);
118  this->delegate()->init(this->impl_);
119 }
120 
121 
122 template <typename FUN>
124  const dds::sub::AnyDataReader& dr,
125  const std::string& expression,
126  const std::vector<std::string>& params,
127  const dds::sub::status::DataState& status,
128  const FUN& functor)
129 {
130  ISOCPP_REPORT_STACK_DDS_BEGIN(dr);
131 
132  this->set_ref(new DELEGATE(dr, expression, params, status));
133  this->delegate()->set_handler(functor);
134  this->delegate()->init(this->impl_);
135 }
139 QueryCondition::~QueryCondition()
140 {
141 }
142 
143 
144 template<typename FWIterator>
145 void QueryCondition::parameters(const FWIterator& begin, const FWIterator end)
146 {
147  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
148 
149  std::vector<std::string> params(begin, end);
150  this->delegate()->parameters(params);
151 }
152 
153 
155  const std::string& expr)
156 {
157  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
158 
159  this->delegate()->expression(expr);
160 }
161 
162 
163 const std::string& QueryCondition::expression()
164 {
165  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
166 
167  return this->delegate()->expression();
168 }
169 
170 
172 {
173  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
174 
175  return this->delegate()->begin();
176 }
177 
178 
180 {
181  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
182 
183  return this->delegate()->end();
184 }
185 
186 
188 {
189  return this->delegate()->begin();
190 }
191 
192 
194 {
195  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
196 
197  return this->delegate()->end();
198 }
199 
200 
202  const std::string& param)
203 {
204  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
205 
206  this->delegate()->add_parameter(param);
207 }
208 
209 
211 {
212  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
213 
214  return this->delegate()->parameters_length();
215 }
216 
217 
219 {
220  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
221  return this->delegate()->data_reader();
222 }
223 
224 }
225 }
226 namespace core
227 {
228 namespace cond
229 {
230 
232 {
233  if (h.is_nil()) {
234  /* We got a null object and are not really able to do a typecheck here. */
235  /* So, just set a null object. */
236  *this = dds::core::null;
237  } else {
238  this->::dds::core::Reference::impl_ = OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<DELEGATE_T>(h.delegate());
239  if (h.delegate() != this->::dds::core::Reference::impl_) {
240  throw dds::core::IllegalOperationError(std::string("Attempted invalid cast: ") + typeid(h).name() + " to " + typeid(*this).name());
241  }
242  }
243 }
244 
245 
246 Condition&
248 {
249  if (this != (Condition*)&rhs) {
250  if (rhs.is_nil()) {
251  /* We got a null object and are not really able to do a typecheck here. */
252  /* So, just set a null object. */
253  *this = dds::core::null;
254  } else {
255  Condition other(rhs);
256  /* Dont have to copy when the delegate is the same. */
257  if (other.delegate() != this->::dds::core::Reference::impl_) {
258  *this = other;
259  }
260  }
261  }
262  return *this;
263 }
264 }
265 }
266 }
267 // End of implementation
268 
269 #endif /* OSPL_DDS_SUB_COND_TQUERYCONDITION_IMPL_HPP_ */
void add_parameter(const std::string &param)
QueryCondition objects are specialized ReadCondition objects that allow the application to also speci...
Exception: An operation was invoked on an inappropriate object or at an inappropriate time...
Definition: Exception.hpp:149
Query objects contain expressions that allow the application to specify a filter on the locally avail...
Definition: Query.hpp:61
void parameters(const FWIterator &begin, const FWIterator end)
Definition: QueryImpl.hpp:131
Class to hold sample DataState information.
Definition: DataState.hpp:371
Typeless base class for the typed DataReader.
const AnyDataReader & data_reader() const
Definition: QueryImpl.hpp:165
const dds::sub::AnyDataReader & data_reader() const
void parameters(const FWIterator &begin, const FWIterator end)
Definition: array.hpp:23
const std::string & expression() const
Definition: QueryImpl.hpp:70
DELEGATE::const_iterator const_iterator
QueryCondition(const dds::sub::Query &query, const dds::sub::status::DataState &status)