Program Listing for File LocatorSelectorEntry.hpp

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/rtps/common/LocatorSelectorEntry.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_RTPS_COMMON_LOCATORSELECTORENTRY_HPP_
#define _FASTDDS_RTPS_COMMON_LOCATORSELECTORENTRY_HPP_

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

#include <fastdds/rtps/common/Guid.h>
#include <fastdds/rtps/common/Locator.h>
#include <fastrtps/utils/collections/ResourceLimitedVector.hpp>

namespace eprosima {
namespace fastrtps {
namespace rtps {

struct LocatorSelectorEntry
{
    struct EntryState
    {
        EntryState(
                size_t max_unicast_locators,
                size_t max_multicast_locators)
            : unicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_unicast_locators))
            , multicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_multicast_locators))
        {
        }

        ResourceLimitedVector<size_t> unicast;
        ResourceLimitedVector<size_t> multicast;
    };

    LocatorSelectorEntry(
            size_t max_unicast_locators,
            size_t max_multicast_locators)
        : remote_guid(c_Guid_Unknown)
        , unicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_unicast_locators))
        , multicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_multicast_locators))
        , state(max_unicast_locators, max_multicast_locators)
        , enabled(false)
        , transport_should_process(false)
    {
    }

    void enable(
            bool should_enable)
    {
        enabled = should_enable && remote_guid != c_Guid_Unknown;
    }

    void reset()
    {
        state.unicast.clear();
        state.multicast.clear();
    }

    GUID_t remote_guid;
    ResourceLimitedVector<Locator_t> unicast;
    ResourceLimitedVector<Locator_t> multicast;
    EntryState state;
    bool enabled;
    bool transport_should_process;
};

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

#endif /* DOXYGEN_SHOULD_SKIP_THIS_PUBLIC */
#endif /* _FASTDDS_RTPS_COMMON_LOCATORSELECTORENTRY_HPP_ */