Program Listing for File LivelinessData.h

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

// Copyright 2016-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_LIVELINESS_DATA_H_
#define _FASTDDS_RTPS_LIVELINESS_DATA_H_

#include <fastrtps/qos/QosPolicies.h>
#include <fastdds/rtps/common/Time_t.h>

#include <chrono>

namespace eprosima {
namespace fastrtps {
namespace rtps {

struct LivelinessData
{
    enum WriterStatus
    {
        NOT_ASSERTED = 0,
        ALIVE = 1,
        NOT_ALIVE = 2
    };

    LivelinessData(
            GUID_t guid_in,
            LivelinessQosPolicyKind kind_in,
            Duration_t lease_duration_in)
        : guid(guid_in)
        , kind(kind_in)
        , lease_duration(lease_duration_in)
        , status(WriterStatus::NOT_ASSERTED)
    {}

    LivelinessData()
        : guid()
        , kind(LivelinessQosPolicyKind::AUTOMATIC_LIVELINESS_QOS)
        , lease_duration(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS)
        , status(WriterStatus::NOT_ASSERTED)
    {}

    ~LivelinessData()
    {}

    bool operator==(
            const LivelinessData& other) const
    {
        return ((guid == other.guid) &&
               (kind == other.kind) &&
               (lease_duration == other.lease_duration));
    }

    bool operator!=(
            const LivelinessData& other) const
    {
        return (!operator==(other));
    }

    GUID_t guid;

    LivelinessQosPolicyKind kind;

    Duration_t lease_duration;

    unsigned int count = 1;

    WriterStatus status;

    std::chrono::steady_clock::time_point time;
};

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

#endif /* _FASTDDS_RTPS_LIVELINESS_DATA_H_ */