Program Listing for File TypeLookupManager.hpp

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/dds/builtin/typelookup/TypeLookupManager.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_TYPELOOKUP_SERVICE_MANAGER_HPP
#define _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

#include <vector>
#include <mutex>

#include <fastdds/dds/builtin/typelookup/TypeLookupRequestListener.hpp>
#include <fastdds/dds/builtin/typelookup/TypeLookupReplyListener.hpp>
#include <fastdds/dds/builtin/typelookup/common/TypeLookupTypes.hpp>

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

namespace eprosima {
namespace fastrtps {

namespace rtps {

class BuiltinProtocols;
class ReaderHistory;
class RTPSParticipantImpl;
class StatefulReader;
class StatefulWriter;
class ParticipantProxyData;
class WriterHistory;

} // namespace rtps
} // namespace fastrtps

namespace fastdds {
namespace dds {
namespace builtin {

extern const fastrtps::rtps::SampleIdentity INVALID_SAMPLE_IDENTITY;

class TypeLookupManager
{
    friend class TypeLookupRequestListener;
    friend class TypeLookupReplyListener;

public:

    TypeLookupManager(
            fastrtps::rtps::BuiltinProtocols* prot);

    virtual ~TypeLookupManager();

    bool init_typelookup_service(
            fastrtps::rtps::RTPSParticipantImpl* p);

    bool assign_remote_endpoints(
            const fastrtps::rtps::ParticipantProxyData& pdata);

    void remove_remote_endpoints(
            fastrtps::rtps::ParticipantProxyData* pdata);

    fastrtps::rtps::BuiltinProtocols* get_builtin_protocols()
    {
        return builtin_protocols_;
    }

    fastrtps::rtps::StatefulWriter* get_builtin_request_writer();

    fastrtps::rtps::StatefulWriter* get_builtin_reply_writer();

    fastrtps::rtps::WriterHistory* get_builtin_request_writer_history();

    fastrtps::rtps::WriterHistory* get_builtin_reply_writer_history();

    fastrtps::rtps::StatefulReader* get_builtin_request_reader();

    fastrtps::rtps::StatefulReader* get_builtin_reply_reader();

    fastrtps::rtps::ReaderHistory* get_builtin_request_reader_history();

    fastrtps::rtps::ReaderHistory* get_builtin_reply_reader_history();

    /* TODO Uncomment if security is implemented.
     #if HAVE_SECURITY
        bool pairing_remote_reader_with_local_writer_after_security(
                const fastrtps::rtps::GUID_t& local_writer,
                const fastrtps::rtps::ReaderProxyData& remote_reader_data);

        bool pairing_remote_writer_with_local_reader_after_security(
                const fastrtps::rtps::GUID_t& local_reader,
                const fastrtps::rtps::WriterProxyData& remote_writer_data);
     #endif
     */

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

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

private:

    bool create_endpoints();

    inline fastrtps::rtps::RTPSParticipantImpl* get_RTPS_participant()
    {
        return participant_;
    }

    std::string get_instanceName() const;

    bool send_request(
            TypeLookup_Request& req) const;

    bool send_reply(
            TypeLookup_Reply& rep) const;

    bool recv_request(
            fastrtps::rtps::CacheChange_t& change,
            TypeLookup_Request& req) const;

    bool recv_reply(
            fastrtps::rtps::CacheChange_t& change,
            TypeLookup_Reply& rep) const;

    const fastrtps::rtps::GUID_t& get_builtin_request_writer_guid() const;

    fastrtps::rtps::RTPSParticipantImpl* participant_;

    fastrtps::rtps::BuiltinProtocols* builtin_protocols_;

    fastrtps::rtps::StatefulWriter* builtin_request_writer_;

    fastrtps::rtps::StatefulReader* builtin_request_reader_;

    fastrtps::rtps::StatefulWriter* builtin_reply_writer_;

    fastrtps::rtps::StatefulReader* builtin_reply_reader_;

    fastrtps::rtps::WriterHistory* builtin_request_writer_history_;

    fastrtps::rtps::WriterHistory* builtin_reply_writer_history_;

    fastrtps::rtps::ReaderHistory* builtin_request_reader_history_;

    fastrtps::rtps::ReaderHistory* builtin_reply_reader_history_;

    TypeLookupRequestListener* request_listener_;

    TypeLookupReplyListener* reply_listener_;

    std::mutex temp_data_lock_;
    fastrtps::rtps::ReaderProxyData temp_reader_proxy_data_;
    fastrtps::rtps::WriterProxyData temp_writer_proxy_data_;

    mutable fastrtps::rtps::SequenceNumber_t request_seq_number_;

    mutable TypeLookup_RequestTypeSupport request_type_;

    mutable TypeLookup_ReplyTypeSupport reply_type_;

    /* TODO Uncomment if security is implemented.
     #if HAVE_SECURITY
        fastrtps::rtps::StatefulWriter* builtin_request_writer_secure_;

        fastrtps::rtps::StatefulWriter* builtin_reply_writer_secure_;

        fastrtps::rtps::StatefulReader* builtin_request_reader_secure_;

        fastrtps::rtps::StatefulReader* builtin_reply_reader_secure_;

        fastrtps::rtps::WriterHistory* builtin_request_writer_secure_history_;

        fastrtps::rtps::WriterHistory* builtin_reply_writer_secure_history_;

        fastrtps::rtps::ReaderHistory* builtin_request_reader_secure_history_;

        fastrtps::rtps::ReaderHistory* builtin_reply_reader_secure_history_;

        bool create_secure_endpoints();
     #endif
     */
};

} /* namespace builtin */
} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP */