Program Listing for File EDPSimple.h

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/rtps/builtin/discovery/endpoint/EDPSimple.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_EDPSIMPLE_H_
#define _FASTDDS_RTPS_EDPSIMPLE_H_
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

#include <fastdds/rtps/builtin/discovery/endpoint/EDP.h>
#include <fastdds/rtps/builtin/data/WriterProxyData.h>
#include <fastdds/rtps/builtin/data/ReaderProxyData.h>

namespace eprosima {
namespace fastrtps {
namespace rtps {

class StatefulReader;
class StatefulWriter;
class RTPSWriter;
class RTPSReader;
class ReaderHistory;
class WriterHistory;
class HistoryAttributes;
class ReaderAttributes;
class WriterAttributes;
class EDPListener;
class ITopicPayloadPool;

class EDPSimple : public EDP
{
    using t_p_StatefulWriter = std::pair<StatefulWriter*, WriterHistory*>;
    using t_p_StatefulReader = std::pair<StatefulReader*, ReaderHistory*>;

public:

    typedef std::set<InstanceHandle_t> key_list;

    EDPSimple(
            PDP* p,
            RTPSParticipantImpl* part);

    virtual ~EDPSimple();
    BuiltinAttributes m_discovery;
    t_p_StatefulWriter publications_writer_;
    t_p_StatefulWriter subscriptions_writer_;
    t_p_StatefulReader publications_reader_;
    t_p_StatefulReader subscriptions_reader_;

#if HAVE_SECURITY
    t_p_StatefulWriter publications_secure_writer_;

    t_p_StatefulReader publications_secure_reader_;

    t_p_StatefulWriter subscriptions_secure_writer_;

    t_p_StatefulReader subscriptions_secure_reader_;
#endif // if HAVE_SECURITY

    EDPListener* publications_listener_;

    EDPListener* subscriptions_listener_;

    bool initEDP(
            BuiltinAttributes& attributes) override;
    void assignRemoteEndpoints(
            const ParticipantProxyData& pdata) override;
    void removeRemoteEndpoints(
            ParticipantProxyData* pdata) override;

    bool areRemoteEndpointsMatched(
            const ParticipantProxyData* pdata) override;

    bool processLocalReaderProxyData(
            RTPSReader* reader,
            ReaderProxyData* rdata) override;
    bool processLocalWriterProxyData(
            RTPSWriter* writer,
            WriterProxyData* wdata) override;
    bool removeLocalReader(
            RTPSReader* R) override;
    bool removeLocalWriter(
            RTPSWriter* W) override;

protected:

    virtual void set_builtin_reader_history_attributes(
            HistoryAttributes& attributes);

    virtual void set_builtin_writer_history_attributes(
            HistoryAttributes& attributes);

    virtual void set_builtin_reader_attributes(
            ReaderAttributes& attributes);

    virtual void set_builtin_writer_attributes(
            WriterAttributes& attributes);

    virtual bool createSEDPEndpoints();

    bool serialize_writer_proxy_data(
            const WriterProxyData& data,
            const t_p_StatefulWriter& writer,
            bool remove_same_instance,
            CacheChange_t** created_change);

    bool serialize_reader_proxy_data(
            const ReaderProxyData& data,
            const t_p_StatefulWriter& writer,
            bool remove_same_instance,
            CacheChange_t** created_change);

    void processPersistentData(
            t_p_StatefulReader& reader,
            t_p_StatefulWriter& writer,
            key_list& demises);

    std::shared_ptr<ITopicPayloadPool> pub_writer_payload_pool_;
    std::shared_ptr<ITopicPayloadPool> pub_reader_payload_pool_;
    std::shared_ptr<ITopicPayloadPool> sub_writer_payload_pool_;
    std::shared_ptr<ITopicPayloadPool> sub_reader_payload_pool_;

#if HAVE_SECURITY
    std::shared_ptr<ITopicPayloadPool> sec_pub_writer_payload_pool_;
    std::shared_ptr<ITopicPayloadPool> sec_pub_reader_payload_pool_;
    std::shared_ptr<ITopicPayloadPool> sec_sub_writer_payload_pool_;
    std::shared_ptr<ITopicPayloadPool> sec_sub_reader_payload_pool_;
#endif // if HAVE_SECURITY

private:

    template<typename ProxyData>
    bool serialize_proxy_data(
            const ProxyData& data,
            const t_p_StatefulWriter& writer,
            bool remove_same_instance,
            CacheChange_t** created_change);

#if HAVE_SECURITY
    bool create_sedp_secure_endpoints();

    bool pairing_remote_writer_with_local_builtin_reader_after_security(
            const GUID_t& local_reader,
            const WriterProxyData& remote_writer_data) override;

    bool pairing_remote_reader_with_local_builtin_writer_after_security(
            const GUID_t& local_writer,
            const ReaderProxyData& remote_reader_data) override;
#endif // if HAVE_SECURITY
};

} /* namespace rtps */
} /* namespace fastrtps */
} /* namespace eprosima */

#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* _FASTDDS_RTPS_EDPSIMPLE_H_ */