Program Listing for File BuiltinProtocols.h

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/rtps/builtin/BuiltinProtocols.h)

// 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_BUILTINPROTOCOLS_H_
#define _FASTDDS_RTPS_BUILTINPROTOCOLS_H_
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

#include <list>

#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
#include <fastdds/rtps/builtin/data/ContentFilterProperty.hpp>
#include <fastdds/rtps/network/NetworkFactory.h>

#include <fastrtps/utils/shared_mutex.hpp>

namespace eprosima {

namespace fastdds {
namespace dds {
namespace builtin {

class TypeLookupManager;

} // namespace builtin

class ReaderQos;
class WriterQos;
} // namespace dds
} // namespace fastdds

namespace fastrtps {

class TopicAttributes;

namespace rtps {

class PDP;
class WLP;
class RTPSParticipantImpl;
class RTPSWriter;
class RTPSReader;

class BuiltinProtocols
{
    friend class RTPSParticipantImpl;

private:

    BuiltinProtocols();
    virtual ~BuiltinProtocols();

    /*
     * Mutex to protect the m_DiscoveryServers collection. Element access is not protected by this mutex, the PDP mutex
     * needs to be used when querying or modifying mutable members of the collection.
     */
    mutable eprosima::shared_mutex discovery_mutex_;

public:

    bool initBuiltinProtocols(
            RTPSParticipantImpl* p_part,
            BuiltinAttributes& attributes);

    void enable();

    bool updateMetatrafficLocators(
            LocatorList_t& loclist);

    void transform_server_remote_locators(
            NetworkFactory& nf);

    BuiltinAttributes m_att;
    RTPSParticipantImpl* mp_participantImpl;
    PDP* mp_PDP;
    WLP* mp_WLP;
    fastdds::dds::builtin::TypeLookupManager* tlm_;
    LocatorList_t m_metatrafficMulticastLocatorList;
    LocatorList_t m_metatrafficUnicastLocatorList;
    LocatorList_t m_initialPeersList;
    std::list<eprosima::fastdds::rtps::RemoteServerAttributes> m_DiscoveryServers;

    bool addLocalWriter(
            RTPSWriter* w,
            const TopicAttributes& topicAtt,
            const fastdds::dds::WriterQos& wqos);
    bool addLocalReader(
            RTPSReader* R,
            const TopicAttributes& topicAtt,
            const fastdds::dds::ReaderQos& rqos,
            const fastdds::rtps::ContentFilterProperty* content_filter = nullptr);

    bool updateLocalWriter(
            RTPSWriter* W,
            const TopicAttributes& topicAtt,
            const fastdds::dds::WriterQos& wqos);
    bool updateLocalReader(
            RTPSReader* R,
            const TopicAttributes& topicAtt,
            const fastdds::dds::ReaderQos& qos,
            const fastdds::rtps::ContentFilterProperty* content_filter = nullptr);
    bool removeLocalWriter(
            RTPSWriter* W);
    bool removeLocalReader(
            RTPSReader* R);

    void announceRTPSParticipantState();
    void stopRTPSParticipantAnnouncement();
    void resetRTPSParticipantAnnouncement();

    inline eprosima::shared_mutex& getDiscoveryMutex() const
    {
        return discovery_mutex_;
    }

};

} // namespace rtps
} /* namespace rtps */
} /* namespace eprosima */
#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* _FASTDDS_RTPS_BUILTINPROTOCOLS_H_ */