OpenDDS  Snapshot(2023/04/28-20:55)
EntityImpl.cpp
Go to the documentation of this file.
1 /*
2  *
3  * Distributed under the OpenDDS License.
4  * See: http://www.opendds.org/license.html
5  */
6 
7 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
8 
9 #include "EntityImpl.h"
10 
11 #include "DomainParticipantImpl.h"
12 #include "StatusConditionImpl.h"
14 
16 
17 namespace OpenDDS {
18 namespace DCPS {
19 
21  : enabled_(false)
22  , entity_deleted_(false)
23  , status_changes_(0)
24  , status_condition_(new StatusConditionImpl(this))
25  , observer_()
26  , events_(Observer::e_NONE)
27  , instance_handle_(DDS::HANDLE_NIL)
28 {
29 }
30 
32 {
34  if (participant) {
35  participant->return_handle(instance_handle_);
36  }
37 }
38 
41 {
42  enabled_ = true;
43 
44  return DDS::RETCODE_OK;
45 }
46 
47 bool
49 {
50  return enabled_;
51 }
52 
53 DDS::StatusCondition_ptr
55 {
57  return DDS::StatusCondition::_duplicate(status_condition_);
58 }
59 
62 {
64  return status_changes_;
65 }
66 
67 void
69  DDS::StatusKind status,
70  bool status_changed_flag)
71 {
73 
74  if (status_changed_flag) {
75  status_changes_ |= status;
76 
77  } else {
78  status_changes_ &= ~status;
79  }
80 }
81 
82 void
84 {
86 }
87 
88 bool
90 {
91  return entity_deleted_;
92 }
93 
95 {
97  return (observer_ && (events_ & e)) ? observer_ :
98  parent() ? parent()->get_observer(e) : Observer_rch();
99 }
100 
101 void
103 {
104  DDS::StatusCondition_var sc_var;
105  {
107 
108  sc_var = DDS::StatusCondition::_duplicate(status_condition_);
109  }
110 
111  StatusConditionImpl* sci = dynamic_cast<StatusConditionImpl*>(sc_var.in());
112  if (sci) {
113  sci->signal_all();
114  } else {
115  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ")
116  ACE_TEXT("EntityImpl::notify_status_condition: ")
117  ACE_TEXT("failed to obtain the StatusConditionImpl.\n")));
118  }
119 }
120 
121 void
123 {
125  transport_config_ = cfg;
126 }
127 
130 {
132  return transport_config_;
133 }
134 
136 {
138  observer_ = observer;
139  events_ = e;
140 }
141 
143  const RcHandle<DomainParticipantImpl>& participant)
144 {
146 
148  return instance_handle_;
149  }
150 
151  if (!participant) {
152  return DDS::HANDLE_NIL;
153  }
154 
155  participant_for_instance_handle_ = participant;
156  return instance_handle_ = participant->assign_handle(id);
157 }
158 
159 } // namespace DCPS
160 } // namespace OpenDDS
161 
void set_status_changed_flag(DDS::StatusKind status, bool status_changed_flag)
Definition: EntityImpl.cpp:68
TransportConfig_rch transport_config_
Definition: EntityImpl.h:96
#define ACE_ERROR(X)
#define ACE_GUARD(MUTEX, OBJ, LOCK)
DDS::ReturnCode_t set_enabled()
Definition: EntityImpl.cpp:40
const InstanceHandle_t HANDLE_NIL
Observer_rch get_observer(Observer::Event e)
Definition: EntityImpl.cpp:94
AtomicBool entity_deleted_
The flag indicates the entity is being deleted.
Definition: EntityImpl.h:85
WeakRcHandle< DomainParticipantImpl > participant_for_instance_handle_
Definition: EntityImpl.h:104
YARD is all original work While it may rely on standard YARD does not include code from other sources We have chosen to release our work as public domain code This means that YARD has been released outside the copyright system Feel free to use the code in any way you wish especially in an academic plagiarism has very little to do with copyright In an academic or in any situation where you are expected to give credit to other people s you will need to cite YARD as a source The author is Christopher and the appropriate date is December the release date for we can t make any promises regarding whether YARD will do what you or whether we will make any changes you ask for You are free to hire your own expert for that If you choose to distribute YARD you ll probably want to read up on the laws covering warranties in your state
Definition: COPYING.txt:14
Observer_rch observer_
Definition: EntityImpl.h:98
void set_deleted(bool state)
Definition: EntityImpl.cpp:83
RcHandle< TransportConfig > TransportConfig_rch
DDS::StatusMask status_changes_
Definition: EntityImpl.h:93
ACE_Thread_Mutex lock_
Definition: EntityImpl.h:101
TransportConfig_rch transport_config() const
Definition: EntityImpl.cpp:129
unsigned long Event
Definition: Observer.h:39
RcHandle< Observer > Observer_rch
Definition: Observer.h:101
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)
Observer::Event events_
Definition: EntityImpl.h:99
The End User API.
DDS::InstanceHandle_t instance_handle_
Definition: EntityImpl.h:103
DDS::StatusCondition_var status_condition_
Definition: EntityImpl.h:94
DDS::InstanceHandle_t get_entity_instance_handle(const GUID_t &id, const RcHandle< DomainParticipantImpl > &participant)
Definition: EntityImpl.cpp:142
HANDLE_TYPE_NATIVE InstanceHandle_t
Definition: DdsDcpsCore.idl:51
ACE_TEXT("TCP_Factory")
virtual RcHandle< EntityImpl > parent() const
Definition: EntityImpl.h:66
unsigned long StatusMask
AtomicBool enabled_
The flag indicates the entity is enabled.
Definition: EntityImpl.h:82
void set_observer(Observer_rch observer, Observer::Event e)
Definition: EntityImpl.cpp:135
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
const ReturnCode_t RETCODE_OK
unsigned long StatusKind
virtual DDS::StatusMask get_status_changes()
Definition: EntityImpl.cpp:61
LM_ERROR
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
virtual DDS::StatusCondition_ptr get_statuscondition()
Definition: EntityImpl.cpp:54