| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
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
19
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
104 const InstanceHandle_t& get_instance_handle() const
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
159 StatusMask status_mask_;
160
162 StatusCondition status_condition_;
163
165 InstanceHandle_t instance_handle_;
166
168 bool enable_;
169};
170
175 class DomainEntity : public Entity
176{
177 public:
178
184 DomainEntity(
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
eprosima::fastdds::dds::DomainEntity::DomainEntity
DomainEntity(const StatusMask &mask=StatusMask::all())
Constructor.
Definition Entity.hpp:184
eprosima::fastdds::dds::Entity::is_enabled
FASTDDS_EXPORTED_API bool is_enabled() const
Checks if the Entity is enabled.
Definition Entity.hpp:114
eprosima::fastdds::dds::Entity::get_status_changes
FASTDDS_EXPORTED_API const StatusMask & get_status_changes() const
Retrieves the set of triggered statuses in the Entity.
eprosima::fastdds::dds::Entity::instance_handle_
InstanceHandle_t instance_handle_
InstanceHandle associated to the Entity.
Definition Entity.hpp:165
eprosima::fastdds::dds::Entity::status_mask_
StatusMask status_mask_
StatusMask with relevant statuses set to 1.
Definition Entity.hpp:159
eprosima::fastdds::dds::Entity::status_condition_
StatusCondition status_condition_
Condition associated to the Entity.
Definition Entity.hpp:162
eprosima::fastdds::dds::Entity::get_statuscondition
FASTDDS_EXPORTED_API const StatusCondition & get_statuscondition() const
Allows access to the StatusCondition associated with the Entity.
Definition Entity.hpp:140
eprosima::fastdds::dds::Entity::get_statuscondition
FASTDDS_EXPORTED_API StatusCondition & get_statuscondition()
Allows access to the StatusCondition associated with the Entity.
Definition Entity.hpp:130
eprosima::fastdds::dds::Entity::enable
virtual ReturnCode_t enable()
This operation enables the Entity.
Definition Entity.hpp:59
eprosima::fastdds::dds::Entity::operator==
FASTDDS_EXPORTED_API bool operator==(const Entity &other) const
Definition Entity.hpp:119
eprosima::fastdds::dds::Entity::close
void close()
This operation disables the Entity before closing it.
Definition Entity.hpp:68
eprosima::fastdds::dds::Entity::get_instance_handle
const InstanceHandle_t & get_instance_handle() const
Retrieves the instance handler that represents the Entity.
Definition Entity.hpp:104
eprosima::fastdds::dds::Entity::enable_
bool enable_
Boolean that states if the Entity is enabled or disabled.
Definition Entity.hpp:168
eprosima::fastdds::dds::Entity::set_instance_handle
FASTDDS_EXPORTED_API void set_instance_handle(const InstanceHandle_t &handle)
Setter for the Instance Handle.
Definition Entity.hpp:152
eprosima::fastdds::dds::Entity::get_status_mask
FASTDDS_EXPORTED_API const StatusMask & get_status_mask() const
Retrieves the set of relevant statuses for the Entity.
Definition Entity.hpp:78
eprosima::fastdds::dds::Entity::Entity
FASTDDS_EXPORTED_API Entity(const StatusMask &mask=StatusMask::all())
Constructor.
Definition Entity.hpp:46
eprosima::fastdds::dds::StatusCondition
The StatusCondition class is a specific Condition that is associated with each Entity.
Definition StatusCondition.hpp:45
eprosima::fastdds::dds::StatusMask
StatusMask is a bitmap or bitset field.
Definition StatusMask.hpp:48
eprosima::fastdds::dds::StatusMask::all
static StatusMask all()
Get all StatusMasks.
Definition StatusMask.hpp:104
eprosima::fastdds::dds
Definition BuiltinTopicKey.hpp:26
eprosima::fastdds::dds::InstanceHandle_t
eprosima::fastdds::rtps::InstanceHandle_t InstanceHandle_t
Definition InstanceHandle.hpp:31
eprosima::fastdds::dds::RETCODE_OK
const ReturnCode_t RETCODE_OK
Definition DDSReturnCode.hpp:61
eprosima::fastdds::dds::ReturnCode_t
int32_t ReturnCode_t
Definition DDSReturnCode.hpp:59
eprosima::fastdds
eprosima
eProsima namespace.