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..).
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. In this case, it is defining the short 'id' as a key value. The comparable RTI definition would be
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.
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.
请注意,通过编译指示的显式键列表规范允许在键中定义一个排序 - 根据用例 - 可能对维护(填充/读取/查询/过滤)'多维 - 具有显着的性能影响存储'用于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:
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):
struct SensorType {
short id; //@key
float temp;
float hum;
TempScale scale;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.