Fast DDS  Version 3.6.1.0
Fast DDS
Entity.hpp
1 // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
20 #ifndef FASTDDS_DDS_CORE__ENTITY_HPP
21 #define FASTDDS_DDS_CORE__ENTITY_HPP
22 
23 #include <fastdds/dds/common/InstanceHandle.hpp>
24 #include <fastdds/dds/core/condition/StatusCondition.hpp>
25 #include <fastdds/dds/core/ReturnCode.hpp>
26 #include <fastdds/dds/core/status/StatusMask.hpp>
27 
28 namespace eprosima {
29 namespace fastdds {
30 namespace dds {
31 
37 class Entity
38 {
39 public:
40 
46  FASTDDS_EXPORTED_API Entity(
47  const StatusMask& mask = StatusMask::all())
48  : status_mask_(mask)
49  , status_condition_(this)
50  , enable_(false)
51  {
52  }
53 
59  virtual ReturnCode_t enable()
60  {
61  enable_ = true;
62  return RETCODE_OK;
63  }
64 
68  void close()
69  {
70  enable_ = false;
71  }
72 
78  FASTDDS_EXPORTED_API const StatusMask& get_status_mask() const
79  {
80  return status_mask_;
81  }
82 
97  FASTDDS_EXPORTED_API const StatusMask& get_status_changes() const;
98 
105  {
106  return instance_handle_;
107  }
108 
114  FASTDDS_EXPORTED_API bool is_enabled() const
115  {
116  return enable_;
117  }
118 
119  FASTDDS_EXPORTED_API bool operator ==(
120  const Entity& other) const
121  {
122  return (this->instance_handle_ == other.instance_handle_);
123  }
124 
130  FASTDDS_EXPORTED_API StatusCondition& get_statuscondition()
131  {
132  return status_condition_;
133  }
134 
140  FASTDDS_EXPORTED_API const StatusCondition& get_statuscondition() const
141  {
142  return status_condition_;
143  }
144 
145 protected:
146 
152  FASTDDS_EXPORTED_API void set_instance_handle(
153  const InstanceHandle_t& handle)
154  {
155  instance_handle_ = handle;
156  }
157 
160 
163 
166 
168  bool enable_;
169 };
170 
175 class DomainEntity : public Entity
176 {
177 public:
178 
185  const StatusMask& mask = StatusMask::all())
186  : Entity(mask)
187  {
188  }
189 
190 };
191 
192 } // namespace dds
193 } // namespace fastdds
194 } // namespace eprosima
195 
196 #endif // FASTDDS_DDS_CORE__ENTITY_HPP
The DomainEntity class is a subclass of Entity created in order to differentiate between DomainPartic...
Definition: Entity.hpp:176
DomainEntity(const StatusMask &mask=StatusMask::all())
Constructor.
Definition: Entity.hpp:184
The Entity class is the abstract base class for all the objects that support QoS policies,...
Definition: Entity.hpp:38
FASTDDS_EXPORTED_API bool is_enabled() const
Checks if the Entity is enabled.
Definition: Entity.hpp:114
InstanceHandle_t instance_handle_
InstanceHandle associated to the Entity.
Definition: Entity.hpp:165
StatusMask status_mask_
StatusMask with relevant statuses set to 1.
Definition: Entity.hpp:159
StatusCondition status_condition_
Condition associated to the Entity.
Definition: Entity.hpp:162
virtual ReturnCode_t enable()
This operation enables the Entity.
Definition: Entity.hpp:59
FASTDDS_EXPORTED_API bool operator==(const Entity &other) const
Definition: Entity.hpp:119
void close()
This operation disables the Entity before closing it.
Definition: Entity.hpp:68
const InstanceHandle_t & get_instance_handle() const
Retrieves the instance handler that represents the Entity.
Definition: Entity.hpp:104
FASTDDS_EXPORTED_API const StatusMask & get_status_mask() const
Retrieves the set of relevant statuses for the Entity.
Definition: Entity.hpp:78
bool enable_
Boolean that states if the Entity is enabled or disabled.
Definition: Entity.hpp:168
FASTDDS_EXPORTED_API void set_instance_handle(const InstanceHandle_t &handle)
Setter for the Instance Handle.
Definition: Entity.hpp:152
FASTDDS_EXPORTED_API Entity(const StatusMask &mask=StatusMask::all())
Constructor.
Definition: Entity.hpp:46
FASTDDS_EXPORTED_API const StatusCondition & get_statuscondition() const
Allows access to the StatusCondition associated with the Entity.
Definition: Entity.hpp:140
FASTDDS_EXPORTED_API const StatusMask & get_status_changes() const
Retrieves the set of triggered statuses in the Entity.
FASTDDS_EXPORTED_API StatusCondition & get_statuscondition()
Allows access to the StatusCondition associated with the Entity.
Definition: Entity.hpp:130
The StatusCondition class is a specific Condition that is associated with each Entity.
Definition: StatusCondition.hpp:45
StatusMask is a bitmap or bitset field.
Definition: StatusMask.hpp:48
static StatusMask all()
Get all StatusMasks.
Definition: StatusMask.hpp:104
Definition: DomainParticipant.hpp:46
const ReturnCode_t RETCODE_OK
Definition: DDSReturnCode.hpp:61
int32_t ReturnCode_t
Definition: DDSReturnCode.hpp:59
Struct InstanceHandle_t, used to contain the key for WITH_KEY topics.
Definition: InstanceHandle.hpp:154