204 lines
4.6 KiB
C
204 lines
4.6 KiB
C
|
/**
|
||
|
* @file TypeDefine.h
|
||
|
* @brief 类型定义头文件
|
||
|
*/
|
||
|
#pragma once
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
#include <memory>
|
||
|
#include <fastdds/dds/domain/DomainParticipant.hpp>
|
||
|
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
|
||
|
#include <fastdds/dds/topic/TypeSupport.hpp>
|
||
|
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
|
||
|
#include <fastdds/dds/subscriber/DataReader.hpp>
|
||
|
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
|
||
|
#include <fastdds/dds/subscriber/SampleInfo.hpp>
|
||
|
#include <fastdds/dds/subscriber/Subscriber.hpp>
|
||
|
#include <fastdds/dds/topic/TypeSupport.hpp>
|
||
|
#include <fastdds/dds/topic/Topic.hpp>
|
||
|
#include <fastdds/dds/topic/TopicDataType.hpp>
|
||
|
#include <fastdds/dds/publisher/Publisher.hpp>
|
||
|
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
|
||
|
#include <fastdds/dds/publisher/DataWriter.hpp>
|
||
|
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
|
||
|
|
||
|
/**
|
||
|
* @brief 域参与者
|
||
|
*/
|
||
|
using XNParticipant = eprosima::fastdds::dds::DomainParticipant;
|
||
|
/**
|
||
|
* @brief 域参与者Qos
|
||
|
*/
|
||
|
using XNParticipantQos = eprosima::fastdds::dds::DomainParticipantQos;
|
||
|
/**
|
||
|
* @brief 域参与者工厂
|
||
|
*/
|
||
|
using XNParticipantFactory = eprosima::fastdds::dds::DomainParticipantFactory;
|
||
|
/**
|
||
|
* @brief 数据读取器监听器
|
||
|
*/
|
||
|
using XNDataReaderListener = eprosima::fastdds::dds::DataReaderListener;
|
||
|
/**
|
||
|
* @brief 数据读取器
|
||
|
*/
|
||
|
using XNDataReader = eprosima::fastdds::dds::DataReader;
|
||
|
/**
|
||
|
* @brief 数据读取器Qos
|
||
|
*/
|
||
|
using XNDataReaderQos = eprosima::fastdds::dds::DataReaderQos;
|
||
|
/**
|
||
|
* @brief 样本信息
|
||
|
*/
|
||
|
using XNSampleInfo = eprosima::fastdds::dds::SampleInfo;
|
||
|
/**
|
||
|
* @brief 订阅者
|
||
|
*/
|
||
|
using XNSubscriber = eprosima::fastdds::dds::Subscriber;
|
||
|
/**
|
||
|
* @brief 类型支持
|
||
|
*/
|
||
|
using XNTypeSupport = eprosima::fastdds::dds::TypeSupport;
|
||
|
/**
|
||
|
* @brief 数据写入器
|
||
|
*/
|
||
|
using XNDataWriter = eprosima::fastdds::dds::DataWriter;
|
||
|
/**
|
||
|
* @brief 数据写入器Qos
|
||
|
*/
|
||
|
using XNDataWriterQos = eprosima::fastdds::dds::DataWriterQos;
|
||
|
/**
|
||
|
* @brief 发布者
|
||
|
*/
|
||
|
using XNPublisher = eprosima::fastdds::dds::Publisher;
|
||
|
/**
|
||
|
* @brief 发布者Qos
|
||
|
*/
|
||
|
using XNPublisherQos = eprosima::fastdds::dds::PublisherQos;
|
||
|
/**
|
||
|
* @brief 主题
|
||
|
*/
|
||
|
using XNTopic = eprosima::fastdds::dds::Topic;
|
||
|
/**
|
||
|
* @brief 主题数据类型
|
||
|
*/
|
||
|
using XNTopicDataType = eprosima::fastdds::dds::TopicDataType;
|
||
|
|
||
|
/**
|
||
|
* @brief 主题信息
|
||
|
*/
|
||
|
struct TopicInfo {
|
||
|
/**
|
||
|
* @brief 主题
|
||
|
*/
|
||
|
XNTopic *topic;
|
||
|
/**
|
||
|
* @brief 发布者
|
||
|
*/
|
||
|
XNPublisher *publisher;
|
||
|
/**
|
||
|
* @brief 数据写入器
|
||
|
*/
|
||
|
XNDataWriter *dataWriter;
|
||
|
/**
|
||
|
* @brief 订阅者
|
||
|
*/
|
||
|
XNSubscriber *subscriber;
|
||
|
/**
|
||
|
* @brief 数据读取器
|
||
|
*/
|
||
|
XNDataReader *dataReader;
|
||
|
/**
|
||
|
* @brief 数据读取器监听器
|
||
|
*/
|
||
|
XNDataReaderListener *listener;
|
||
|
};
|
||
|
|
||
|
// 错误码定义
|
||
|
enum class XNDDSErrorCode {
|
||
|
SUCCESS = 0,
|
||
|
INIT_FAILED = -1,
|
||
|
TOPIC_CREATE_FAILED = -2,
|
||
|
PUBLISHER_CREATE_FAILED = -3,
|
||
|
SUBSCRIBER_CREATE_FAILED = -4,
|
||
|
DATAWRITER_CREATE_FAILED = -5,
|
||
|
DATAREADER_CREATE_FAILED = -6,
|
||
|
INVALID_PARAM = -7,
|
||
|
NOT_INITIALIZED = -8
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @brief 成员变量定义结构体
|
||
|
* @note 成员变量包含数据类型、变量名、是否为数组、数组大小、描述
|
||
|
*/
|
||
|
struct MemberVariable {
|
||
|
/**
|
||
|
* @brief 数据类型
|
||
|
*/
|
||
|
std::string dataType;
|
||
|
/**
|
||
|
* @brief 变量名
|
||
|
*/
|
||
|
std::string variableName;
|
||
|
/**
|
||
|
* @brief 是否为数组
|
||
|
*/
|
||
|
bool isArray;
|
||
|
/**
|
||
|
* @brief 数组大小
|
||
|
*/
|
||
|
std::vector<int> arraySizes;
|
||
|
/**
|
||
|
* @brief 描述
|
||
|
*/
|
||
|
std::string description;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @brief 接口结构体定义结构体
|
||
|
* @note 接口结构体定义包含结构体名称、成员变量
|
||
|
*/
|
||
|
struct StructDefinition {
|
||
|
/**
|
||
|
* @brief 结构体名称
|
||
|
*/
|
||
|
std::string structName;
|
||
|
/**
|
||
|
* @brief 成员变量
|
||
|
*/
|
||
|
std::vector<std::shared_ptr<MemberVariable>> memberVariables;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @brief 命名空间定义结构体
|
||
|
* @note 命名空间定义包含命名空间名称、接口结构体定义、子命名空间定义
|
||
|
*/
|
||
|
struct NamespaceDefinition {
|
||
|
/**
|
||
|
* @brief 命名空间名称
|
||
|
*/
|
||
|
std::string namespaceName;
|
||
|
/**
|
||
|
* @brief 结构体定义
|
||
|
*/
|
||
|
std::vector<std::shared_ptr<StructDefinition>> structDefinitions;
|
||
|
/**
|
||
|
* @brief 子命名空间
|
||
|
*/
|
||
|
std::vector<std::shared_ptr<NamespaceDefinition>> childNamespaces;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @brief 模型接口定义
|
||
|
* @note 模型接口定义包含模型名称和接口命名空间定义
|
||
|
*/
|
||
|
struct ModelDefinition {
|
||
|
/**
|
||
|
* @brief 模型名称
|
||
|
*/
|
||
|
std::string modelName;
|
||
|
/**
|
||
|
* @brief 命名空间定义
|
||
|
*/
|
||
|
std::vector<std::shared_ptr<NamespaceDefinition>> namespaceDefinitions;
|
||
|
};
|