Program Listing for File DomainParticipant.hpp

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/dds/domain/DomainParticipant.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_DOMAIN_PARTICIPANT_HPP_
#define _FASTDDS_DOMAIN_PARTICIPANT_HPP_

#include <functional>
#include <string>
#include <utility>
#include <vector>

#include <fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp>
#include <fastdds/dds/builtin/topic/TopicBuiltinTopicData.hpp>
#include <fastdds/dds/core/status/StatusMask.hpp>
#include <fastdds/dds/core/Entity.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/topic/ContentFilteredTopic.hpp>
#include <fastdds/dds/topic/IContentFilterFactory.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
#include <fastdds/dds/topic/Topic.hpp>
#include <fastdds/dds/topic/TopicListener.hpp>
#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
#include <fastdds/rtps/common/Guid.h>
#include <fastdds/rtps/common/SampleIdentity.h>
#include <fastdds/rtps/common/Time_t.h>
#include <fastrtps/types/TypesBase.h>
#include <fastrtps/types/TypeIdentifier.h>

using eprosima::fastrtps::types::ReturnCode_t;

namespace dds {
namespace domain {
class DomainParticipant;
} // namespace domain
} // namespace dds

namespace eprosima {
namespace fastrtps {
namespace rtps {
class ResourceEvent;
} // namespace rtps

namespace types {
class TypeInformation;
} // namespace types

class ParticipantAttributes;
class PublisherAttributes;
class SubscriberAttributes;

} //namespace fastrtps

namespace fastdds {
namespace dds {

class DomainParticipantImpl;
class DomainParticipantListener;
class Publisher;
class PublisherQos;
class PublisherListener;
class Subscriber;
class SubscriberQos;
class SubscriberListener;
class TopicQos;

// Not implemented classes
class MultiTopic;

class DomainParticipant : public Entity
{
public:

    virtual ~DomainParticipant();

    // Superclass methods

    RTPS_DllAPI ReturnCode_t get_qos(
            DomainParticipantQos& qos) const;

    RTPS_DllAPI const DomainParticipantQos& get_qos() const;

    RTPS_DllAPI ReturnCode_t set_qos(
            const DomainParticipantQos& qos) const;

    RTPS_DllAPI const DomainParticipantListener* get_listener() const;

    RTPS_DllAPI ReturnCode_t set_listener(
            DomainParticipantListener* listener);

    RTPS_DllAPI ReturnCode_t set_listener(
            DomainParticipantListener* listener,
            const std::chrono::seconds timeout);

    RTPS_DllAPI ReturnCode_t set_listener(
            DomainParticipantListener* listener,
            const StatusMask& mask);

    RTPS_DllAPI ReturnCode_t set_listener(
            DomainParticipantListener* listener,
            const StatusMask& mask,
            const std::chrono::seconds timeout);

    RTPS_DllAPI ReturnCode_t enable() override;

    // DomainParticipant specific methods from DDS API

    RTPS_DllAPI Publisher* create_publisher(
            const PublisherQos& qos,
            PublisherListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI Publisher* create_publisher_with_profile(
            const std::string& profile_name,
            PublisherListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI ReturnCode_t delete_publisher(
            const Publisher* publisher);

    RTPS_DllAPI Subscriber* create_subscriber(
            const SubscriberQos& qos,
            SubscriberListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI Subscriber* create_subscriber_with_profile(
            const std::string& profile_name,
            SubscriberListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI ReturnCode_t delete_subscriber(
            const Subscriber* subscriber);

    RTPS_DllAPI Topic* create_topic(
            const std::string& topic_name,
            const std::string& type_name,
            const TopicQos& qos,
            TopicListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI Topic* create_topic_with_profile(
            const std::string& topic_name,
            const std::string& type_name,
            const std::string& profile_name,
            TopicListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI ReturnCode_t delete_topic(
            const Topic* topic);

    RTPS_DllAPI ContentFilteredTopic* create_contentfilteredtopic(
            const std::string& name,
            Topic* related_topic,
            const std::string& filter_expression,
            const std::vector<std::string>& expression_parameters);

    RTPS_DllAPI ContentFilteredTopic* create_contentfilteredtopic(
            const std::string& name,
            Topic* related_topic,
            const std::string& filter_expression,
            const std::vector<std::string>& expression_parameters,
            const char* filter_class_name);

    RTPS_DllAPI ReturnCode_t delete_contentfilteredtopic(
            const ContentFilteredTopic* a_contentfilteredtopic);

    RTPS_DllAPI MultiTopic* create_multitopic(
            const std::string& name,
            const std::string& type_name,
            const std::string& subscription_expression,
            const std::vector<std::string>& expression_parameters);

    RTPS_DllAPI ReturnCode_t delete_multitopic(
            const MultiTopic* a_multitopic);

    RTPS_DllAPI Topic* find_topic(
            const std::string& topic_name,
            const fastrtps::Duration_t& timeout);

    RTPS_DllAPI TopicDescription* lookup_topicdescription(
            const std::string& topic_name) const;

    RTPS_DllAPI const Subscriber* get_builtin_subscriber() const;

    RTPS_DllAPI ReturnCode_t ignore_participant(
            const InstanceHandle_t& handle);

    RTPS_DllAPI ReturnCode_t ignore_topic(
            const InstanceHandle_t& handle);

    RTPS_DllAPI ReturnCode_t ignore_publication(
            const InstanceHandle_t& handle);

    RTPS_DllAPI ReturnCode_t ignore_subscription(
            const InstanceHandle_t& handle);

    RTPS_DllAPI DomainId_t get_domain_id() const;

    RTPS_DllAPI ReturnCode_t delete_contained_entities();

    RTPS_DllAPI ReturnCode_t assert_liveliness();

    RTPS_DllAPI ReturnCode_t set_default_publisher_qos(
            const PublisherQos& qos);

    RTPS_DllAPI const PublisherQos& get_default_publisher_qos() const;

    RTPS_DllAPI ReturnCode_t get_default_publisher_qos(
            PublisherQos& qos) const;

    RTPS_DllAPI ReturnCode_t get_publisher_qos_from_profile(
            const std::string& profile_name,
            PublisherQos& qos) const;

    RTPS_DllAPI ReturnCode_t set_default_subscriber_qos(
            const SubscriberQos& qos);

    RTPS_DllAPI const SubscriberQos& get_default_subscriber_qos() const;

    RTPS_DllAPI ReturnCode_t get_default_subscriber_qos(
            SubscriberQos& qos) const;

    RTPS_DllAPI ReturnCode_t get_subscriber_qos_from_profile(
            const std::string& profile_name,
            SubscriberQos& qos) const;

    RTPS_DllAPI ReturnCode_t set_default_topic_qos(
            const TopicQos& qos);

    RTPS_DllAPI const TopicQos& get_default_topic_qos() const;

    RTPS_DllAPI ReturnCode_t get_default_topic_qos(
            TopicQos& qos) const;

    RTPS_DllAPI ReturnCode_t get_topic_qos_from_profile(
            const std::string& profile_name,
            TopicQos& qos) const;

    RTPS_DllAPI ReturnCode_t get_discovered_participants(
            std::vector<InstanceHandle_t>& participant_handles) const;

    RTPS_DllAPI ReturnCode_t get_discovered_participant_data(
            builtin::ParticipantBuiltinTopicData& participant_data,
            const InstanceHandle_t& participant_handle) const;

    RTPS_DllAPI ReturnCode_t get_discovered_topics(
            std::vector<InstanceHandle_t>& topic_handles) const;

    RTPS_DllAPI ReturnCode_t get_discovered_topic_data(
            builtin::TopicBuiltinTopicData& topic_data,
            const InstanceHandle_t& topic_handle) const;

    RTPS_DllAPI bool contains_entity(
            const InstanceHandle_t& a_handle,
            bool recursive = true) const;

    RTPS_DllAPI ReturnCode_t get_current_time(
            fastrtps::Time_t& current_time) const;

    // DomainParticipant methods specific from Fast-DDS

    RTPS_DllAPI ReturnCode_t register_type(
            TypeSupport type,
            const std::string& type_name);

    RTPS_DllAPI ReturnCode_t register_type(
            TypeSupport type);

    RTPS_DllAPI ReturnCode_t unregister_type(
            const std::string& typeName);

    RTPS_DllAPI TypeSupport find_type(
            const std::string& type_name) const;

    RTPS_DllAPI const InstanceHandle_t& get_instance_handle() const;

    // From here legacy RTPS methods.

    RTPS_DllAPI const fastrtps::rtps::GUID_t& guid() const;

    RTPS_DllAPI std::vector<std::string> get_participant_names() const;

    RTPS_DllAPI bool new_remote_endpoint_discovered(
            const fastrtps::rtps::GUID_t& partguid,
            uint16_t userId,
            fastrtps::rtps::EndpointKind_t kind);

    RTPS_DllAPI fastrtps::rtps::ResourceEvent& get_resource_event() const;

    RTPS_DllAPI fastrtps::rtps::SampleIdentity get_type_dependencies(
            const fastrtps::types::TypeIdentifierSeq& in) const;

    RTPS_DllAPI fastrtps::rtps::SampleIdentity get_types(
            const fastrtps::types::TypeIdentifierSeq& in) const;

    RTPS_DllAPI ReturnCode_t register_remote_type(
            const fastrtps::types::TypeInformation& type_information,
            const std::string& type_name,
            std::function<void(const std::string& name, const fastrtps::types::DynamicType_ptr type)>& callback);

    RTPS_DllAPI ReturnCode_t register_content_filter_factory(
            const char* filter_class_name,
            IContentFilterFactory* const filter_factory);

    RTPS_DllAPI IContentFilterFactory* lookup_content_filter_factory(
            const char* filter_class_name);

    RTPS_DllAPI ReturnCode_t unregister_content_filter_factory(
            const char* filter_class_name);

    bool has_active_entities();

protected:

    DomainParticipant(
            const StatusMask& mask = StatusMask::all());

    DomainParticipantImpl* impl_;

    friend class DomainParticipantFactory;

    friend class DomainParticipantImpl;

    friend class ::dds::domain::DomainParticipant;
};

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

#endif /* _FASTDDS_DOMAIN_PARTICIPANT_HPP_ */