Program Listing for File TopicDataType.hpp
↰ Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/dds/topic/TopicDataType.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_TOPICDATATYPE_HPP_
#define _FASTDDS_TOPICDATATYPE_HPP_
#include <functional>
#include <memory>
#include <string>
#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/rtps/common/InstanceHandle.h>
#include <fastdds/rtps/common/SerializedPayload.h>
#include <fastrtps/fastrtps_dll.h>
#include <fastrtps/utils/md5.h>
// This version of TypeSupport has `is_bounded()`
#define TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
// This version of TypeSupport has `is_plain()`
#define TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
// This version of TypeSupport has `construct_sample()`
#define TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE
namespace eprosima {
namespace fastrtps {
namespace rtps {
struct SerializedPayload_t;
struct InstanceHandle_t;
} // namespace rtps
} // namespace fastrtps
namespace fastdds {
namespace dds {
class TypeSupport;
class TopicDataType
{
public:
RTPS_DllAPI TopicDataType()
: m_typeSize(0)
, m_isGetKeyDefined(false)
, auto_fill_type_object_(true)
, auto_fill_type_information_(true)
{
}
RTPS_DllAPI virtual ~TopicDataType()
{
}
RTPS_DllAPI virtual bool serialize(
void* data,
fastrtps::rtps::SerializedPayload_t* payload) = 0;
RTPS_DllAPI virtual bool deserialize(
fastrtps::rtps::SerializedPayload_t* payload,
void* data) = 0;
RTPS_DllAPI virtual std::function<uint32_t()> getSerializedSizeProvider(
void* data) = 0;
RTPS_DllAPI virtual void* createData() = 0;
RTPS_DllAPI virtual void deleteData(
void* data) = 0;
RTPS_DllAPI virtual bool getKey(
void* data,
fastrtps::rtps::InstanceHandle_t* ihandle,
bool force_md5 = false) = 0;
RTPS_DllAPI inline void setName(
const char* nam)
{
m_topicDataTypeName = std::string(nam);
}
RTPS_DllAPI inline const char* getName() const
{
return m_topicDataTypeName.c_str();
}
RTPS_DllAPI inline bool auto_fill_type_object() const
{
return auto_fill_type_object_;
}
RTPS_DllAPI inline void auto_fill_type_object(
bool auto_fill_type_object)
{
auto_fill_type_object_ = auto_fill_type_object;
}
RTPS_DllAPI inline bool auto_fill_type_information() const
{
return auto_fill_type_information_;
}
RTPS_DllAPI inline void auto_fill_type_information(
bool auto_fill_type_information)
{
auto_fill_type_information_ = auto_fill_type_information;
}
RTPS_DllAPI inline const std::shared_ptr<TypeIdV1> type_identifier() const
{
return type_identifier_;
}
RTPS_DllAPI inline void type_identifier(
const TypeIdV1& id)
{
type_identifier_ = std::make_shared<TypeIdV1>(id);
}
RTPS_DllAPI inline void type_identifier(
const std::shared_ptr<TypeIdV1> id)
{
type_identifier_ = std::move(id);
}
RTPS_DllAPI inline const std::shared_ptr<TypeObjectV1> type_object() const
{
return type_object_;
}
RTPS_DllAPI inline void type_object(
const TypeObjectV1& object)
{
type_object_ = std::make_shared<TypeObjectV1>(object);
}
RTPS_DllAPI inline void type_object(
std::shared_ptr<TypeObjectV1> object)
{
type_object_ = std::move(object);
}
RTPS_DllAPI inline const std::shared_ptr<xtypes::TypeInformation> type_information() const
{
return type_information_;
}
RTPS_DllAPI inline void type_information(
const xtypes::TypeInformation& info)
{
type_information_ = std::make_shared<xtypes::TypeInformation>(info);
}
RTPS_DllAPI inline void type_information(
std::shared_ptr<xtypes::TypeInformation> info)
{
type_information_ = std::move(info);
}
RTPS_DllAPI virtual inline bool is_bounded() const
{
return false;
}
RTPS_DllAPI virtual inline bool is_plain() const
{
return false;
}
RTPS_DllAPI virtual inline bool construct_sample(
void* memory) const
{
static_cast<void>(memory);
return false;
}
uint32_t m_typeSize;
bool m_isGetKeyDefined;
protected:
std::shared_ptr<TypeIdV1> type_identifier_;
std::shared_ptr<TypeObjectV1> type_object_;
std::shared_ptr<xtypes::TypeInformation> type_information_;
private:
std::string m_topicDataTypeName;
bool auto_fill_type_object_;
bool auto_fill_type_information_;
friend class fastdds::dds::TypeSupport;
};
} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
#endif /* _FASTDDS_TOPICDATATYPE_HPP_ */