123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- /**
- * @file Entity.hpp
- *
- */
- #ifndef _FASTDDS_ENTITY_HPP_
- #define _FASTDDS_ENTITY_HPP_
- #include <fastdds/dds/core/status/StatusMask.hpp>
- #include <fastdds/rtps/common/InstanceHandle.h>
- #include <fastrtps/types/TypesBase.h>
- namespace eprosima {
- namespace fastdds {
- namespace dds {
- /**
- * @brief The Entity class is the abstract base class for all the objects that support QoS policies, a listener and
- * a status condition.
- *
- */
- class Entity
- {
- public:
- /**
- * @brief Constructor
- * @param mask StatusMask (default: all)
- */
- RTPS_DllAPI Entity(
- const StatusMask& mask = StatusMask::all())
- : status_mask_(mask)
- , enable_(false)
- {
- }
- /**
- * @brief This operation enables the Entity
- * @return RETCODE_OK
- */
- virtual fastrtps::types::ReturnCode_t enable()
- {
- enable_ = true;
- return fastrtps::types::ReturnCode_t::RETCODE_OK;
- }
- /**
- * @brief This operation disables the Entity before closing it
- */
- void close()
- {
- enable_ = false;
- }
- /**
- * @brief Retrieves the set of relevant statuses for the Entity
- * @return Reference to the StatusMask with the relevant statuses set to 1
- */
- RTPS_DllAPI const StatusMask& get_status_mask() const
- {
- return status_mask_;
- }
- /**
- * @brief Retrieves the instance handler that represents the Entity
- * @return Reference to the InstanceHandle
- */
- const fastrtps::rtps::InstanceHandle_t& get_instance_handle() const
- {
- return instance_handle_;
- }
- /**
- * @brief Checks if the Entity is enabled
- * @return true if enabled, false if not
- */
- RTPS_DllAPI bool is_enabled() const
- {
- return enable_;
- }
- RTPS_DllAPI bool operator ==(
- const Entity& other) const
- {
- return (this->instance_handle_ == other.instance_handle_);
- }
- protected:
- /**
- * @brief Setter for the Instance Handle
- * @param handle Instance Handle
- */
- RTPS_DllAPI void set_instance_handle(
- const fastrtps::rtps::InstanceHandle_t& handle)
- {
- instance_handle_ = handle;
- }
- //! StatusMask with relevant statuses set to 1
- StatusMask status_mask_;
- //! InstanceHandle associated to the Entity
- fastrtps::rtps::InstanceHandle_t instance_handle_;
- //! Boolean that states if the Entity is enabled or disabled
- bool enable_;
- };
- /**
- * @brief The DomainEntity class is a subclass of Entity created in order to differentiate between DomainParticipants
- * and the rest of Entities
- */
- class DomainEntity : public Entity
- {
- public:
- /**
- * @brief Constructor
- * @param mask StatusMask (default: all)
- */
- RTPS_DllAPI DomainEntity(
- const StatusMask& mask = StatusMask::all())
- : Entity(mask)
- {
- }
- };
- } // namespace dds
- } // namespace fastdds
- } // namespace eprosima
- #endif // _FASTDDS_ENTITY_HPP_
|