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.