Program Listing for File DomainParticipantFactory.hpp

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

#include <fastrtps/attributes/ParticipantAttributes.h>
#include <fastrtps/types/TypesBase.h>
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
#include <fastdds/dds/core/status/StatusMask.hpp>

#include <map>
#include <memory>
#include <mutex>

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

namespace eprosima {

namespace fastrtps {
namespace rtps {

class RTPSDomainImpl;

namespace detail {
class TopicPayloadPoolRegistry;
}  // namespace detail
}  // namespace rtps
}  // namespace fastrtps

namespace fastdds {
namespace dds {

class DomainParticipantListener;
class DomainParticipant;
class DomainParticipantImpl;

namespace detail {
struct LogResources;
}  // namespace detail

class DomainParticipantFactory
{

public:

    RTPS_DllAPI static DomainParticipantFactory* get_instance();

    RTPS_DllAPI static std::shared_ptr<DomainParticipantFactory> get_shared_instance();

    RTPS_DllAPI DomainParticipant* create_participant(
            DomainId_t domain_id,
            const DomainParticipantQos& qos,
            DomainParticipantListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI DomainParticipant* create_participant_with_profile(
            DomainId_t domain_id,
            const std::string& profile_name,
            DomainParticipantListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI DomainParticipant* create_participant_with_profile(
            const std::string& profile_name,
            DomainParticipantListener* listener = nullptr,
            const StatusMask& mask = StatusMask::all());

    RTPS_DllAPI DomainParticipant* lookup_participant(
            DomainId_t domain_id) const;

    RTPS_DllAPI std::vector<DomainParticipant*> lookup_participants(
            DomainId_t domain_id) const;

    RTPS_DllAPI ReturnCode_t get_default_participant_qos(
            DomainParticipantQos& qos) const;

    RTPS_DllAPI const DomainParticipantQos& get_default_participant_qos() const;

    RTPS_DllAPI ReturnCode_t set_default_participant_qos(
            const DomainParticipantQos& qos);

    RTPS_DllAPI ReturnCode_t get_participant_qos_from_profile(
            const std::string& profile_name,
            DomainParticipantQos& qos) const;

    RTPS_DllAPI ReturnCode_t delete_participant(
            DomainParticipant* part);

    RTPS_DllAPI ReturnCode_t load_profiles();

    RTPS_DllAPI ReturnCode_t load_XML_profiles_file(
            const std::string& xml_profile_file);

    RTPS_DllAPI ReturnCode_t load_XML_profiles_string(
            const char* data,
            size_t length);

    RTPS_DllAPI ReturnCode_t check_xml_static_discovery(
            std::string& xml_file);

    RTPS_DllAPI ReturnCode_t get_qos(
            DomainParticipantFactoryQos& qos) const;

    RTPS_DllAPI ReturnCode_t set_qos(
            const DomainParticipantFactoryQos& qos);

protected:

    friend class DomainParticipant;

    std::map<DomainId_t, std::vector<DomainParticipantImpl*>> participants_;

    DomainParticipantFactory();

    virtual ~DomainParticipantFactory();

    DomainParticipantFactory (
            const DomainParticipantFactory&) = delete;

    void operator = (
            const DomainParticipantFactory&) = delete;

    void reset_default_participant_qos();

    static void set_qos(
            DomainParticipantFactoryQos& to,
            const DomainParticipantFactoryQos& from,
            bool first_time);

    static ReturnCode_t check_qos(
            const DomainParticipantFactoryQos& qos);

    static bool can_qos_be_updated(
            const DomainParticipantFactoryQos& to,
            const DomainParticipantFactoryQos& from);

    void participant_has_been_deleted(
            DomainParticipantImpl* part);

    mutable std::mutex mtx_participants_;

    mutable bool default_xml_profiles_loaded;

    DomainParticipantFactoryQos factory_qos_;

    DomainParticipantQos default_participant_qos_;

    std::shared_ptr<fastrtps::rtps::detail::TopicPayloadPoolRegistry> topic_pool_;

    std::shared_ptr<fastrtps::rtps::RTPSDomainImpl> rtps_domain_;

    std::shared_ptr<detail::LogResources> log_resources_;
};

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

#endif /* _FASTDDS_DOMAINPARTICIPANT_HPP_*/