Program Listing for File RTPSParticipant.hpp

Return to documentation for file (include/fastdds/rtps/participant/RTPSParticipant.hpp)

// Copyright 2016 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.

#ifndef FASTDDS_RTPS_PARTICIPANT__RTPSPARTICIPANT_HPP
#define FASTDDS_RTPS_PARTICIPANT__RTPSPARTICIPANT_HPP

#include <cstdint>
#include <cstdlib>
#include <memory>

#include <fastdds/dds/core/ReturnCode.hpp>
#include <fastdds/dds/publisher/qos/WriterQos.hpp>
#include <fastdds/dds/subscriber/qos/ReaderQos.hpp>
#include <fastdds/rtps/attributes/RTPSParticipantAttributes.hpp>
#include <fastdds/rtps/builtin/data/ContentFilterProperty.hpp>
#include <fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp>
#include <fastdds/rtps/common/Guid.hpp>
#include <fastdds/statistics/IListeners.hpp>
#include <fastdds/fastdds_dll.hpp>

namespace eprosima {

#ifdef FASTDDS_STATISTICS

namespace fastdds {
namespace statistics {

class MonitorServiceStatusData;

namespace rtps {

struct IStatusQueryable;
struct IStatusObserver;

} // namespace rtps
} // namespace statistics
} // namespace fastdds

#endif //FASTDDS_STATISTICS

namespace fastdds {
namespace rtps {

struct PublicationBuiltinTopicData;
class RTPSParticipantImpl;
class RTPSParticipantListener;
class RTPSWriter;
class RTPSReader;
struct SubscriptionBuiltinTopicData;
struct TopicDescription;
class EndpointAttributes;
class WriterAttributes;
class ReaderAttributes;
class ResourceEvent;
class WLP;

class FASTDDS_EXPORTED_API RTPSParticipant
{
    friend class RTPSParticipantImpl;
    friend class RTPSDomain;
    friend class RTPSDomainImpl;

private:

    RTPSParticipant(
            RTPSParticipantImpl* pimpl);

    virtual ~RTPSParticipant();

public:

    const GUID_t& getGuid() const;

    void announceRTPSParticipantState();

    //  //!Method to loose the next change (ONLY FOR TEST). //TODO remove this method because is only for testing
    //  void loose_next_change();

    void stopRTPSParticipantAnnouncement();

    void resetRTPSParticipantAnnouncement();

    bool newRemoteWriterDiscovered(
            const GUID_t& pguid,
            int16_t userDefinedId);
    bool newRemoteReaderDiscovered(
            const GUID_t& pguid,
            int16_t userDefinedId);

    uint32_t getRTPSParticipantID() const;

    bool register_writer(
            RTPSWriter* rtps_writer,
            const TopicDescription& topic,
            const fastdds::dds::WriterQos& qos);

    dds::ReturnCode_t register_writer(
            RTPSWriter* rtps_writer,
            const TopicDescription& topic,
            const PublicationBuiltinTopicData& pub_builtin_topic_data);

    bool register_reader(
            RTPSReader* rtps_reader,
            const TopicDescription& topic,
            const fastdds::dds::ReaderQos& qos,
            const ContentFilterProperty* content_filter = nullptr);

    dds::ReturnCode_t register_reader(
            RTPSReader* rtps_reader,
            const TopicDescription& topic,
            const SubscriptionBuiltinTopicData& sub_builtin_topic_data,
            const ContentFilterProperty* content_filter = nullptr);

    void update_attributes(
            const RTPSParticipantAttributes& patt);

    bool update_writer(
            RTPSWriter* rtps_writer,
            const fastdds::dds::WriterQos& wqos);

    bool update_reader(
            RTPSReader* rtps_reader,
            const fastdds::dds::ReaderQos& rqos,
            const ContentFilterProperty* content_filter = nullptr);

    std::vector<std::string> getParticipantNames() const;

    const RTPSParticipantAttributes& get_attributes() const;

    uint32_t getMaxMessageSize() const;

    uint32_t getMaxDataSize() const;

    ResourceEvent& get_resource_event() const;

    WLP* wlp() const;

    bool get_new_entity_id(
            EntityId_t& entityId);

    void set_check_type_function(
            std::function<bool(const std::string&)>&& check_type);

    void set_listener(
            RTPSParticipantListener* listener);

    uint32_t get_domain_id() const;

    void enable();

    bool ignore_participant(
            const GuidPrefix_t& participant_guid);

    bool ignore_writer(
            const GUID_t& writer_guid);

    bool ignore_reader(
            const GUID_t& reader_guid);

    std::vector<TransportNetmaskFilterInfo> get_netmask_filter_info() const;

    bool get_publication_info(
            fastdds::rtps::PublicationBuiltinTopicData& data,
            const GUID_t& writer_guid) const;

    bool get_subscription_info(
            fastdds::rtps::SubscriptionBuiltinTopicData& data,
            const GUID_t& reader_guid) const;

#if HAVE_SECURITY

    bool is_security_enabled_for_writer(
            const WriterAttributes& writer_attributes);

    bool is_security_enabled_for_reader(
            const ReaderAttributes& reader_attributes);

#endif // if HAVE_SECURITY

#ifdef FASTDDS_STATISTICS

    bool add_statistics_listener(
            std::shared_ptr<fastdds::statistics::IListener> listener,
            uint32_t kind);

    bool remove_statistics_listener(
            std::shared_ptr<fastdds::statistics::IListener> listener,
            uint32_t kind);

    void set_enabled_statistics_writers_mask(
            uint32_t enabled_writers);

    const fastdds::statistics::rtps::IStatusObserver* create_monitor_service(
            fastdds::statistics::rtps::IStatusQueryable& status_queryable);

    bool create_monitor_service();

    bool is_monitor_service_created() const;

    bool enable_monitor_service() const;

    bool disable_monitor_service() const;

    bool fill_discovery_data_from_cdr_message(
            ParticipantBuiltinTopicData& data,
            const fastdds::statistics::MonitorServiceStatusData& msg);

    bool fill_discovery_data_from_cdr_message(
            PublicationBuiltinTopicData& data,
            const fastdds::statistics::MonitorServiceStatusData& msg);

    bool fill_discovery_data_from_cdr_message(
            SubscriptionBuiltinTopicData& data,
            const fastdds::statistics::MonitorServiceStatusData& msg);

#endif // FASTDDS_STATISTICS

protected:

    RTPSParticipantImpl* mp_impl;

};

} // namespace rtps
} // namespace rtps
} // namespace eprosima

#endif // FASTDDS_RTPS_PARTICIPANT__RTPSPARTICIPANT_HPP