Program Listing for File TopicAttributes.h

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastrtps/attributes/TopicAttributes.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 TOPICPARAMETERS_H_
#define TOPICPARAMETERS_H_

#include <string>

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


namespace eprosima {
namespace fastrtps{

class TopicAttributes
{
public:

    TopicAttributes()
        : topicKind(rtps::NO_KEY)
        , topicName("UNDEF")
        , topicDataType("UNDEF")
        , auto_fill_type_object(true)
        , auto_fill_type_information(true)
    {
    }

    TopicAttributes(
            const char* name,
            const char* dataType,
            rtps::TopicKind_t tKind= rtps::NO_KEY)
        {
            topicKind = tKind;
            topicName = name;
            topicDataType = dataType;
            auto_fill_type_object = true;
            auto_fill_type_information = true;
        }

        virtual ~TopicAttributes() {}

        bool operator==(const TopicAttributes& b) const
        {
            return (this->topicKind == b.topicKind) &&
                   (this->topicName == b.topicName) &&
                   (this->topicDataType == b.topicDataType) &&
                   (this->historyQos == b.historyQos);
        }

        const string_255& getTopicDataType() const {
            return topicDataType;
        }

        rtps::TopicKind_t getTopicKind() const {
            return topicKind;
        }

        const string_255& getTopicName() const {
            return topicName;
        }

        rtps::TopicKind_t topicKind;
        string_255 topicName;
        string_255 topicDataType;
        HistoryQosPolicy historyQos;
        ResourceLimitsQosPolicy resourceLimitsQos;
        TypeIdV1 type_id;
        TypeObjectV1 type;
        xtypes::TypeInformation type_information;
        bool auto_fill_type_object;
        bool auto_fill_type_information;

        bool checkQos() const;
};

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

bool inline operator!=(const TopicAttributes& t1, const TopicAttributes& t2)
{
    if(t1.topicKind != t2.topicKind
            || t1.topicName != t2.topicName
            || t1.topicDataType != t2.topicDataType
            || t1.historyQos.kind != t2.historyQos.kind
            || (t1.historyQos.kind == KEEP_LAST_HISTORY_QOS && t1.historyQos.depth != t2.historyQos.depth))
    {
        return true;
    }
    return false;
}
#endif

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

#endif /* TOPICPARAMETERS_H_ */