file name: evalconv.hpp, evalconv.cpp
classification: evaluation
contents: functions for converting the byte order of messages
use: provides functions for converting the byte order of messages
between big and little endian
Note: the files contain many macros that make adding new conversion
functions more easy. If you have to add own functions, you do not have
to use these macros, but they will probably save you a lot of time and
effort.
global items used:
global items provided:
inline INT32
gi_Convert (INT32 data): Inverts the byte order of data and
returns this converted value.
#define
DeclareConvert(type): Declares a function with the prototype void
Convert (type *s, EBool convert). Such a Convert() function
must be declared for every message structure used in the communication.
The function checks convert and if it is True, it converts every
data entry in s. If convert is False, then it leaves
s
untouched and returns at once.
Currently, the following Convert() functions are provided:
Convert
(SModuleBase *s, EBool convert)
Convert
(SEvent *s, EBool convert)
Convert
(SNetEvent *s, EBool convert)
Convert
(SNetCrashEvent *s, EBool convert)
Convert
(SNetMessageEvent *s, EBool convert)
Convert
(SApplEvent *s, EBool convert)
Convert
(SApplNetEvent *s, EBool convert)
Convert
(SApplGpsEvent *s, EBool convert)
Convert
(SApplClockEvent *s, EBool convert)
Convert
(SApplPreloadEvent *s, EBool convert)
Convert
(SApplTimeEvent *s, EBool convert)
Convert
(SApplRateEvent *s, EBool convert)
Convert
(SApplCrashEvent *s, EBool convert)
Convert
(SApplSendMsgEvent *s, EBool convert)
Convert
(SApplRecvMsgEvent *s, EBool convert)
Convert
(SApplDelayEvent *s, EBool convert)
Convert
(SApplDelayEstimationEvent *s, EBool convert)
Convert
(SParameter *s, EBool convert)
Convert
(SNetworkParameter *s, EBool convert)
Convert
(SNetDistributionP2P *s, EBool convert)
Convert
(SNetDistribution *s, EBool convert)
Convert
(SApplDistribution *s, EBool convert)
Convert
(SApplWobbleDrift *s, EBool convert)
Convert
(SSingleNetworkParameter *s, EBool convert)
Convert
(SNetworkData *s, EBool convert)
Convert
(SSingleParameter *s, EBool convert)
Convert
(STimeParameter *s, EBool convert)
Convert
(STransmissionData *s, EBool convert)
Convert
(SRateData *s, EBool convert)
Convert
(SEventReport *s, EBool convert)
Convert
(SCommand *s, EBool convert)
Convert
(SGpsConnectCommand *s, EBool convert)
Convert
(SApplCommand *s, EBool convert)
Convert
(SNetworkCreateCommand *s, EBool convert)
Convert
(SNetworkCommand *s, EBool convert)
Convert
(SNetworkConnectCommand *s, EBool convert)
Convert
(SReply *s, EBool convert)
Convert
(SBooleanReply *s, EBool convert)
Convert
(SDoubleReply *s, EBool convert)
local items used:
void g_Convert
(INT32& src): converts the INT32, i.e., it reads src
backwards and stores this value in src.
#define DeclareConversion(type):
Macro for declaring a conversion function g_Convert(type) for
a certain enumeration. This assumes that all enums have the same data size
(4 bytes). Usually, you can enforce this with a compiler option. The g_Convert()
function calls the g_Convert(INT32) function to convert the parameter.
The macro is used to declare several conversion functions for enumerations and integer types:
Some other conversion functions are needed to convert more complex types:DeclareConversion (int)
DeclareConversion (SINT32)
DeclareConversion (EBool)
DeclareConversion (EDistribution)
DeclareConversion (EEvent)
DeclareConversion (EGpsUnit)
DeclareConversion (EModule)
DeclareConversion (ENetworkType)
DeclareConversion (EReplyType)
DeclareConversion (ESystemCommand)
DeclareConversion (ESystemParameter)
Finally, two macros are provided that make implementing the Convert() functions more easy:void g_Convert (STimestamp& src)
void g_Convert (CNtpTime& src)
void g_Convert (double& src)
#define DefineConvert(type,
basetype): This macro evaluates to the function header of the Convert()
function, to a statement that checks convert and returns if it
is False, and to a statement that calls the Convert() function
of the base class. The rest of the function depends on the type
and must be provided by the programmer.
#define DoConvert(name):
evaluates to the statement g_convert(s->name). It can be used
to convert a message structure more easily and assumes that the DefineConvert()
macro is used to create the function header.