OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
GuardConditionImpl.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_TGUARDCONDITION_IMPL_HPP_
22 #define OSPL_DDS_CORE_COND_TGUARDCONDITION_IMPL_HPP_
23 
28 /*
29  * OMG PSM class declaration
30  */
32 #include <org/opensplice/core/cond/GuardConditionDelegate.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_NC_BEGIN();
47  this->set_ref(new DELEGATE);
48  this->delegate()->init(this->impl_);
49 }
50 
55 template <typename FUN>
57 {
58  ISOCPP_REPORT_STACK_NC_BEGIN();
59  this->set_ref(new DELEGATE);
60  this->delegate()->init(this->impl_);
61  this->delegate()->set_handler(functor);
62 }
63 
64 
65 template <typename FUN>
66 GuardCondition::GuardCondition(const FUN& functor)
67 {
68  ISOCPP_REPORT_STACK_NC_BEGIN();
69  this->set_ref(new DELEGATE);
70  this->delegate()->init(this->impl_);
71  this->delegate()->set_handler(functor);
72 }
76 GuardCondition::~GuardCondition()
77 {
78 }
79 
80 
82 {
83  ISOCPP_REPORT_STACK_NC_BEGIN();
84  this->delegate()->trigger_value(value);
85 }
86 
87 
89 {
90  return Condition::trigger_value();
91 }
92 
93 
95 {
96  ISOCPP_REPORT_STACK_NC_BEGIN();
97  if (h.is_nil()) {
98  /* We got a null object and are not really able to do a typecheck here. */
99  /* So, just set a null object. */
100  *this = dds::core::null;
101  } else {
102  this->::dds::core::Reference::impl_ = OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<DELEGATE_T>(h.delegate());
103  if (h.delegate() != this->::dds::core::Reference::impl_) {
104  throw dds::core::IllegalOperationError(std::string("Attempted invalid cast: ") + typeid(h).name() + " to " + typeid(*this).name());
105  }
106  }
107 }
108 
109 
110 Condition&
112 {
113  ISOCPP_REPORT_STACK_NC_BEGIN();
114  if (this != (Condition*)&rhs) {
115  if (rhs.is_nil()) {
116  /* We got a null object and are not really able to do a typecheck here. */
117  /* So, just set a null object. */
118  *this = dds::core::null;
119  } else {
120  Condition other(rhs);
121  /* Dont have to copy when the delegate is the same. */
122  if (other.delegate() != this->::dds::core::Reference::impl_) {
123  *this = other;
124  }
125  }
126  }
127  return *this;
128 }
129 
130 }
131 }
132 }
133 // End of implementation
134 
135 #endif /* OSPL_DDS_CORE_COND_TGUARDCONDITION_IMPL_HPP_ */
Exception: An operation was invoked on an inappropriate object or at an inappropriate time...
Definition: Exception.hpp:149
void value(DDT &dd, uint32_t mid, const T &v)
Reference & operator=(const Reference< D > &that)
Definition: array.hpp:23
A GuardCondition object is a specific Condition whose trigger_value is completely under the control o...
This class is the base class for all the conditions that may be attached to a dds::core::cond::WaitSe...
Definition: Condition.hpp:58