简体   繁体   English

pragma keylist关键字有什么作用?

[英]What does pragma keylist keyword do?

While reading about various IoT messaging protocols I came across a structure defined as below: 在阅读各种物联网消息传递协议时,我遇到了如下定义的结构:

enum TempScale {
   CELSIUM,
   KELVIN,
   FARENHEIT
};

struct TempSensorType {
   short id;
   float temp;
   float hum;
   TempScale scale;
};
#pragma keylist TempSensorType id

My question is: What does this #pragma keylist keyword do and where can I find some documentation about using #pragma preprocessor directives (I believe it is such directive..). 我的问题是:这个#pragma keylist关键字做了什么,哪里可以找到关于使用#pragma预处理器指令的一些文档(我相信它是这样的指令..)。

Thanks. 谢谢。

The #pragma you are looking at is the PrismTech method for defining a key value within an OMG-DDS (Data Distribution Service for Real-Time Systems) Type structure. 您正在查看的#pragma是用于在OMG-DDS(实时系统的数据分发服务)类型结构中定义键值的PrismTech方法。 In this case, it is defining the short 'id' as a key value. 在这种情况下,它将短'id'定义为键值。 The comparable RTI definition would be 可比较的RTI定义是

struct TempSensorType {
    short id; //@key
    float temp;
    float hum;
    TempScale scale;
}

For interoperability between vendors' implementations, you can safely do 对于供应商实施之间的互操作性,您可以安全地进行

struct TempSensorType {
    short id; //@key
    float temp;
    float hum;
    TempScale scale;
}
#pragma keylist TempSensorType id

because the RTI compiler ignores the pragmas, and the PT compiler ignores the //@key. 因为RTI编译器忽略了pragma,而PT编译器忽略了// @键。

This will change with future versions of the specification for Extensible Types, which will define a standard method for all vendors to support. 这将随着可扩展类型规范的未来版本而改变,这将为所有供应商提供支持的标准方法。

Note that if you were looking at a generic list of IoT messaging protocols, the concept of a "key" value may not exist in the other messaging protocols you were looking at. 请注意,如果您正在查看IoT消息传递协议的通用列表,那么您正在查看的其他消息传递协议中可能不存在“密钥”值的概念。

请注意,通过编译指示的显式键列表规范允许在键中定义一个排序 - 根据用例 - 可能对维护(填充/读取/查询/过滤)'多维 - 具有显着的性能影响存储'用于dataReader(和/或耐久性服务)

Note that for DDS implementations that comply with the recently-adopted OMG DDS-XTYPES specification ( http://www.omg.org/spec/DDS-XTypes/ ) the standard portable way to specify keys is either: 请注意,对于符合最近采用的OMG DDS-XTYPES规范( http://www.omg.org/spec/DDS-XTypes/ )的DDS实现,指定密钥的标准可移植方式是:

struct SensorType {
    @key short id;
    float temp;
    float hum;
    TempScale scale;
}

Or alternatively (to avoid breaking IDL compilers that do not understand the IDL annotations): 或者(为了避免破坏不了解IDL注释的IDL编译器):

struct SensorType {
    short id; //@key
    float temp;
    float hum;
    TempScale scale;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM