Program Listing for File Subscriber.hpp

Return to documentation for file (include/fastdds/dds/subscriber/Subscriber.hpp)

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

#ifndef FASTDDS_DDS_SUBSCRIBER__SUBSCRIBER_HPP
#define FASTDDS_DDS_SUBSCRIBER__SUBSCRIBER_HPP

#include <fastdds/dds/core/Entity.hpp>
#include <fastdds/dds/core/ReturnCode.hpp>
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/subscriber/InstanceState.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
#include <fastdds/dds/subscriber/SampleState.hpp>
#include <fastdds/dds/subscriber/ViewState.hpp>
#include <fastdds/dds/topic/qos/TopicQos.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>

namespace dds {
namespace sub {

class Subscriber;

} // namespace sub
} // namespace dds

namespace eprosima {
namespace fastdds {
namespace rtps {

class IPayloadPool;

} // namespace rtps

namespace dds {

class DomainParticipant;
class SubscriberListener;
class SubscriberImpl;
class DataReader;
class DataReaderListener;
class DataReaderQos;
class TopicDescription;
class Subscriber : public DomainEntity
{
protected:

    friend class SubscriberImpl;
    friend class DomainParticipantImpl;

    Subscriber(
            SubscriberImpl* pimpl,
            const StatusMask& mask = StatusMask::all());

    Subscriber(
            DomainParticipant* dp,
            const SubscriberQos& qos = SUBSCRIBER_QOS_DEFAULT,
            SubscriberListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

public:

    virtual ~Subscriber()
    {
    }

    FASTDDS_EXPORTED_API ReturnCode_t enable() override;

    FASTDDS_EXPORTED_API const SubscriberQos& get_qos() const;

    FASTDDS_EXPORTED_API ReturnCode_t get_qos(
            SubscriberQos& qos) const;

    FASTDDS_EXPORTED_API ReturnCode_t set_qos(
            const SubscriberQos& qos);

    FASTDDS_EXPORTED_API const SubscriberListener* get_listener() const;

    FASTDDS_EXPORTED_API ReturnCode_t set_listener(
            SubscriberListener* listener);

    FASTDDS_EXPORTED_API ReturnCode_t set_listener(
            SubscriberListener* listener,
            const StatusMask& mask);
    FASTDDS_EXPORTED_API DataReader* create_datareader(
            TopicDescription* topic,
            const DataReaderQos& reader_qos,
            DataReaderListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all(),
            std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool = nullptr);

    FASTDDS_EXPORTED_API DataReader* create_datareader_with_profile(
            TopicDescription* topic,
            const std::string& profile_name,
            DataReaderListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all(),
            std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool = nullptr);

    FASTDDS_EXPORTED_API ReturnCode_t delete_datareader(
            const DataReader* reader);

    FASTDDS_EXPORTED_API DataReader* lookup_datareader(
            const std::string& topic_name) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareaders(
            std::vector<DataReader*>& readers) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareaders(
            std::vector<DataReader*>& readers,
            const std::vector<SampleStateKind>& sample_states,
            const std::vector<ViewStateKind>& view_states,
            const std::vector<InstanceStateKind>& instance_states) const;

    FASTDDS_EXPORTED_API bool has_datareaders() const;

    FASTDDS_EXPORTED_API ReturnCode_t begin_access();

    FASTDDS_EXPORTED_API ReturnCode_t end_access();


    FASTDDS_EXPORTED_API ReturnCode_t notify_datareaders() const;

    FASTDDS_EXPORTED_API ReturnCode_t delete_contained_entities();

    FASTDDS_EXPORTED_API ReturnCode_t set_default_datareader_qos(
            const DataReaderQos& qos);

    FASTDDS_EXPORTED_API const DataReaderQos& get_default_datareader_qos() const;


    FASTDDS_EXPORTED_API DataReaderQos& get_default_datareader_qos();

    FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos(
            DataReaderQos& qos) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile(
            const std::string& profile_name,
            DataReaderQos& qos) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile(
            const std::string& profile_name,
            DataReaderQos& qos,
            std::string& topic_name) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
            const std::string& xml,
            DataReaderQos& qos) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
            const std::string& xml,
            DataReaderQos& qos,
            std::string& topic_name) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
            const std::string& xml,
            DataReaderQos& qos,
            const std::string& profile_name) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
            const std::string& xml,
            DataReaderQos& qos,
            std::string& topic_name,
            const std::string& profile_name) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml(
            const std::string& xml,
            DataReaderQos& qos) const;

    FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml(
            const std::string& xml,
            DataReaderQos& qos,
            std::string& topic_name) const;

    FASTDDS_EXPORTED_API static ReturnCode_t copy_from_topic_qos(
            DataReaderQos& reader_qos,
            const TopicQos& topic_qos);

    FASTDDS_EXPORTED_API const DomainParticipant* get_participant() const;

    FASTDDS_EXPORTED_API const InstanceHandle_t& get_instance_handle() const;

protected:

    SubscriberImpl* impl_;

    friend class ::dds::sub::Subscriber;
};

} // namespace dds
} // namespace fastdds
} // namespace eprosima

#endif // FASTDDS_DDS_SUBSCRIBER__SUBSCRIBER_HPP