OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
StatusConditionImpl.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_TSTATUSCONDITION_IMPL_HPP_
22 #define OSPL_DDS_CORE_COND_TSTATUSCONDITION_IMPL_HPP_
23 
28 /*
29  * OMG PSM class declaration
30  */
32 #include <org/opensplice/core/cond/StatusConditionDelegate.hpp>
33 #include <org/opensplice/core/ReportUtils.hpp>
34 
35 // Implementation
36 namespace dds
37 {
38 namespace core
39 {
40 namespace cond
41 {
42 
43 
45 {
46  ISOCPP_REPORT_STACK_DDS_BEGIN(e);
47  dds::core::Reference::impl_=
48  OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<org::opensplice::core::cond::StatusConditionDelegate>(
49  e.delegate()->get_statusCondition());
50 }
51 
56 template <typename FUN>
58 {
59  ISOCPP_REPORT_STACK_DDS_BEGIN(e);
60  dds::core::Reference::impl_=
61  OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<org::opensplice::core::cond::StatusConditionDelegate>(
62  e.delegate()->get_statusCondition());
63  this->delegate()->set_handler(functor);
64 }
65 
66 
67 template <typename FUN>
68 StatusCondition::StatusCondition(const dds::core::Entity& e, const FUN& functor)
69 {
70  ISOCPP_REPORT_STACK_DDS_BEGIN(e);
71  dds::core::Reference::impl_=
72  OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<org::opensplice::core::cond::StatusConditionDelegate>(
73  e.delegate()->get_statusCondition());
74  this->delegate()->set_handler(functor);
75 }
79 StatusCondition::~StatusCondition() { }
80 
81 
83 {
84  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
85  this->delegate()->enabled_statuses(status);
86 }
87 
88 
90 {
91  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
92  return this->delegate()->enabled_statuses();
93 }
94 
95 
97 {
98  ISOCPP_REPORT_STACK_DDS_BEGIN(*this);
99  return this->delegate()->entity();
100 }
101 
102 
103 
105 {
106  if (h.is_nil()) {
107  /* We got a null object and are not really able to do a typecheck here. */
108  /* So, just set a null object. */
109  *this = dds::core::null;
110  } else {
111  ISOCPP_REPORT_STACK_DDS_BEGIN(h);
112 
113  this->::dds::core::Reference::impl_ = OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<DELEGATE_T>(h.delegate());
114  if (h.delegate() != this->::dds::core::Reference::impl_) {
115  throw dds::core::IllegalOperationError(std::string("Attempted invalid cast: ") + typeid(h).name() + " to " + typeid(*this).name());
116  }
117  }
118 }
119 
120 
121 Condition&
123 {
124  if (this != (Condition*)&rhs) {
125  if (rhs.is_nil()) {
126  /* We got a null object and are not really able to do a typecheck here. */
127  /* So, just set a null object. */
128  *this = dds::core::null;
129  } else {
130  Condition other(rhs);
131  /* Dont have to copy when the delegate is the same. */
132  if (other.delegate() != this->::dds::core::Reference::impl_) {
133  *this = other;
134  }
135  }
136  }
137  return *this;
138 }
139 
140 
141 }
142 }
143 }
144 // End of implementation
145 
146 #endif /* OSPL_DDS_CORE_COND_TSTATUSCONDITION_IMPL_HPP_ */
A StatusCondition object is a specific Condition that is associated with each Entity.
StatusCondition(const dds::core::Entity &e)
This class is the abstract base class for all the DCPS objects.
Definition: Entity.hpp:55
const ::dds::core::status::StatusMask enabled_statuses() const
Exception: An operation was invoked on an inappropriate object or at an inappropriate time...
Definition: Exception.hpp:149
Reference & operator=(const Reference< D > &that)
Definition: array.hpp:23
StatusMask is a bitmap or bitset field.
Definition: State.hpp:144
const dds::core::Entity & entity() const
This class is the base class for all the conditions that may be attached to a dds::core::cond::WaitSe...
Definition: Condition.hpp:58