OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
ReadConditionImpl.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_CORE_COND_TREADCONDITION_IMPL_HPP_
22 #define OSPL_DDS_CORE_COND_TREADCONDITION_IMPL_HPP_
23 
28 /*
29  * OMG PSM class declaration
30  */
32 #include <org/opensplice/sub/cond/ReadConditionDelegate.hpp>
33 
34 // Implementation
35 
36 namespace dds
37 {
38 namespace sub
39 {
40 namespace cond
41 {
42 
43 
45  const dds::sub::AnyDataReader& dr,
46  const dds::sub::status::DataState& status)
47 {
48  ISOCPP_REPORT_STACK_DDS_BEGIN(dr);
49  this->set_ref(new DELEGATE(dr, status));
50  this->delegate()->init(this->impl_);
51 }
52 
57 template <typename FUN>
59  const dds::sub::AnyDataReader& dr,
60  const dds::sub::status::DataState& status,
61  FUN& functor)
62 {
63  ISOCPP_REPORT_STACK_DDS_BEGIN(dr);
64  this->set_ref(new DELEGATE(dr, status));
65  this->delegate()->init(this->impl_);
66  this->delegate()->set_handler(functor);
67 }
68 
69 
70 template <typename FUN>
72  const dds::sub::AnyDataReader& dr,
73  const dds::sub::status::DataState& status,
74  const FUN& functor)
75 {
76  ISOCPP_REPORT_STACK_DDS_BEGIN(dr);
77  this->set_ref(new DELEGATE(dr, status));
78  this->delegate()->init(this->impl_);
79  this->delegate()->set_handler(functor);
80 }
84 ReadCondition::~ReadCondition() { }
85 
86 
88 {
89  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
90  return this->delegate()->state_filter();
91 }
92 
93 
95 {
96  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
97  return this->delegate()->data_reader();
98 }
99 
100 }
101 }
102 namespace core
103 {
104 namespace cond
105 {
106 
108 {
109  if (h.is_nil()) {
110  /* We got a null object and are not really able to do a typecheck here. */
111  /* So, just set a null object. */
112  *this = dds::core::null;
113  } else {
114  this->::dds::core::Reference::impl_ = OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<DELEGATE_T>(h.delegate());
115  if (h.delegate() != this->::dds::core::Reference::impl_) {
116  throw dds::core::IllegalOperationError(std::string("Attempted invalid cast: ") + typeid(h).name() + " to " + typeid(*this).name());
117  }
118  }
119 }
120 
121 
122 Condition&
124 {
125  if (this != (Condition*)&rhs) {
126  if (rhs.is_nil()) {
127  /* We got a null object and are not really able to do a typecheck here. */
128  /* So, just set a null object. */
129  *this = dds::core::null;
130  } else {
131  Condition other(rhs);
132  /* Dont have to copy when the delegate is the same. */
133  if (other.delegate() != this->::dds::core::Reference::impl_) {
134  *this = other;
135  }
136  }
137  }
138  return *this;
139 }
140 }
141 }
142 }
143 // End of implementation
144 
145 #endif /* OSPL_DDS_CORE_COND_TREADCONDITION_IMPL_HPP_ */
Exception: An operation was invoked on an inappropriate object or at an inappropriate time...
Definition: Exception.hpp:149
Class to hold sample DataState information.
Definition: DataState.hpp:371
Typeless base class for the typed DataReader.
ReadCondition objects are conditions specifically dedicated to read operations and attached to one Da...
const dds::sub::AnyDataReader & data_reader() const
Definition: array.hpp:23
ReadCondition(const dds::sub::AnyDataReader &dr, const dds::sub::status::DataState &status)
const dds::sub::status::DataState state_filter() const