VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Typedefs | Functions | Variables

provides basic Operating Independent Methods useful to a federate More...

Go to the source code of this file.

Classes

class  DtSelectParam
 

Macros

#define DtDELETE(x)
 DT_FD_ZERO_USES_MEMSET. More...
 
#define DtDELETE_VOID(x, cast)
 
#define DtISON(a, x)   (a & x)
 
#define DtISOFF(a, x)   (!DtISON(a, x))
 
#define DtTURNON(a, x)   (a |= x)
 
#define DtTURNOFF(a, x)   (a &= ~x)
 
#define DtNUMBER(foo)   (sizeof(foo)/sizeof(foo[0]))
 
#define DtOFFSET(type, field)   ((size_t)&((type *)NULL)->field)
 
#define DtSIZEOF(type, field)   sizeof(((type *)NULL)->field)
 
#define DtRGBA_TO_UINT(r, g, b, a)   ((((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
 
#define DtATOI(s)   (int)strtol(s, 0, 0)
 some versions of strtol returns INT_MAX for input larger than 0x7fffffff. More...
 
#define DT_8_BIT_MASK(value, bit)   (DtU8)((value & ((DtU8)1 << bit)) >>bit)
 Get the n-th bit of an 8-bit value. More...
 
#define DT_SET_8_BIT_MASK(value, bit)   (value | ((DtU8)1 << bit) )
 Set the n-th bit of an 8-bit value. More...
 
#define DT_8_BITS_MASK(value, yBits, startBit)   (DtU8)((value & ((((DtU8)1 << yBits) -1) <<startBit)) >> startBit )
 Get y bits of an 8-bit value starting at bit x and shift them to get the correct value. More...
 
#define DT_16_BIT_MASK(value, bit)   (DtU16)((value & ((DtU16)1 << bit)) >> bit)
 Get the n-th bit of an 16-bit value. More...
 
#define DT_SET_16_BIT_MASK(value, bit)   (value | ((DtU16)1 << bit) )
 Set the n-th bit of an 16-bit value. More...
 
#define DT_16_BITS_MASK(value, yBits, startBit)   (DtU16)((value & ((((DtU16)1 << yBits) -1) <<startBit)) >> startBit )
 Get y bits of a 16-bit value starting at bit x and shift them to get the correct value. More...
 
#define DT_32_BIT_MASK(value, bit)   (DtU32)((value & ((DtU32)1 << bit)) >> bit)
 Get the n-th bit of an 32-bit value. More...
 
#define DT_SET_32_BIT_MASK(value, bit)   (value | ((DtU32)1 << bit) )
 Set the n-th bit of an 32-bit value. More...
 
#define DT_VXWORKS_APP(name)
 

Typedefs

typedef DtU32 DtIpv4Addr
 

Functions

void bzero (char *b, int length)
 Need bzero. More...
 
void DtUINT_TO_RGBA (unsigned int val, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a)
 
int DtROUND_TO_MULT (int num, int mult)
 Rounds num up to a multiple of mult. More...
 
template<typename T >
DtMax (T x, T y)
 Returns what ever is greater, x or y of type T. More...
 
template<typename T >
DtMin (T x, T y)
 Returns the which ever is lesser, x or y of type T. More...
 
char * DtDeg2DmsString (double val, char *buff, int prec)
 
char * DtDeg2DmsString (double val)
 
DtString DtHexToBinary (const std::string &s, int sLength=0)
 Get the 32-bit binary value of a passed in hex value. More...
 
DtString DtBinaryToHex (const std::string &s)
 Get the hex value of a passed in 32-bit binary value. More...
 
void DtDecimalToBinary (const DtU32 value, std::vector< int > &binVal)
 Get the 32-bit binary value of a passed in decimal integer. More...
 
int DtBinaryToDecimal (const std::string &s)
 Get the decimal value given a binary value. More...
 
int DtIsInList (const int *lst, int num)
 Returns -1 if num is not in lst. More...
 
int DtSelect (int n, fd_set *i, fd_set *o, fd_set *e, DtTime t)
 
void DtClose (int &fd)
 
char * DtStrdup (const char *str)
 Strdup wrapper. More...
 
char * DtToLower (char *str)
 Convert str to all lowercase. More...
 
char * DtToUpper (char *str)
 Convert str to all uppercase. More...
 
const char * DtInetAddrString (DtIpv4Addr addr)
 Converts ulong to internet dot notation (returns internal static buffer). More...
 
DtIpv4Addr DtStringToInetAddr (const char *str)
 Converts to internet dot notation to ulong in host order. More...
 
DtIpv4Addr DtStringToInetAddr (const DtString &str)
 
DtIpv4Addr DtHexStringToInetAddr (const char *str)
 Converts to internet dot notation to ulong in host order. More...
 
DtMachineSize alignValue (DtMachineSize value, DtMachineSize alignment)
 Adjust the given value to the nearest multiple of the given alignment Efficient means to determine byte alignment avoiding costly % modulo operator (division and remainder) More...
 
const void * alignPtr (const void *ptr, DtMachineSize alignment)
 Adjust the given pointer to the given byte alignment (in bytes) More...
 
void * alignPtr (void *ptr, DtMachineSize alignment)
 
DtMachineSize alignedPadding (DtMachineSize value, DtMachineSize alignment)
 Return the adjustment necessary to align the given value to the given alignment Efficient means to determine padding for byte alignment avoiding costly % modulo operator (division and remainder) More...
 
DtMachineSize alignedPtrPadding (const void *ptr, DtMachineSize alignment)
 Return the # padding bytes necessary to align the given pointer to the given byte alignment (in bytes) More...
 
int DtResizeString (char *&buf, int &oldLn, int newLn)
 For VXWORKS. More...
 
int DtArgc (char *cmdLine)
 Convert a command line (single string with args separated by spaces) to argv, argc format. More...
 
char ** DtArgv (char *cmdLine, int *argc=NULL)
 
const char * DtOperatingSystem ()
 Returns the platform we're running on. More...
 
const char * DtCompiler ()
 Returns the compiler. More...
 
int DtGetPid ()
 Returns the process ID for the running process. More...
 
int DtGetPPid ()
 Returns the process ID for the parent of the running process. More...
 
void printHexToStream (std::ostream &stream, unsigned int numberOfColumns, unsigned char *ptr, unsigned int bytes)
 Prints Hex to a stream based on an address and the bytes. More...
 

Variables

const DtIpv4Addr DtInetAddrAny = 0
 
const DtIpv4Addr loopbackAddr = 0x7f000001
 

Detailed Description

provides basic Operating Independent Methods useful to a federate

Macro Definition Documentation

#define DT_16_BIT_MASK (   value,
  bit 
)    (DtU16)((value & ((DtU16)1 << bit)) >> bit)

Get the n-th bit of an 16-bit value.

Parameters
valueThe 16-bit binary value
bitThe bit index to be retrieved from the binary value
Returns
A int value of the bit at the given index
#define DT_16_BITS_MASK (   value,
  yBits,
  startBit 
)    (DtU16)((value & ((((DtU16)1 << yBits) -1) <<startBit)) >> startBit )

Get y bits of a 16-bit value starting at bit x and shift them to get the correct value.

Parameters
valueThe 16-bit binary value to be queried at the given index
yBitsThe number of bits to be retrieved
startBitThe index of the first bit to get
Returns
The int value of the bits indicated
#define DT_32_BIT_MASK (   value,
  bit 
)    (DtU32)((value & ((DtU32)1 << bit)) >> bit)

Get the n-th bit of an 32-bit value.

Parameters
valueThe 32-bit binary value
bitThe bit index to be retrieved from the binary value
Returns
A int value of the bit at the given index
#define DT_8_BIT_MASK (   value,
  bit 
)    (DtU8)((value & ((DtU8)1 << bit)) >>bit)

Get the n-th bit of an 8-bit value.

Parameters
valueThe 8-bit binary value
bitThe bit index to be retrieved from the binary value
Returns
A int value of the bit at the given index
#define DT_8_BITS_MASK (   value,
  yBits,
  startBit 
)    (DtU8)((value & ((((DtU8)1 << yBits) -1) <<startBit)) >> startBit )

Get y bits of an 8-bit value starting at bit x and shift them to get the correct value.

Parameters
valueThe 8-bit binary value to be queried at the given index
yBitsThe number of bits to be retrieved
startBitThe index of the first bit to get
Returns
The int value of the bits indicated
#define DT_SET_16_BIT_MASK (   value,
  bit 
)    (value | ((DtU16)1 << bit) )

Set the n-th bit of an 16-bit value.

Parameters
valueThe 16-bit binary value to be modified at the given index
bitThe bit index to be set to 1
Returns
A modified value with the set bit at the given index
#define DT_SET_32_BIT_MASK (   value,
  bit 
)    (value | ((DtU32)1 << bit) )

Set the n-th bit of an 32-bit value.

Parameters
valueThe 32-bit binary value to be modified at the given index
bitThe bit index to be set to 1
Returns
A modified value with the set bit at the given index
#define DT_SET_8_BIT_MASK (   value,
  bit 
)    (value | ((DtU8)1 << bit) )

Set the n-th bit of an 8-bit value.

Parameters
valueThe 8-bit binary value to be modified at the given index
bitThe bit index to be set to 1
Returns
A modified value with the set bit at the given index
#define DT_VXWORKS_APP (   name)
Value:
int main(int argc, char** argv); \
int name(char* cmdLine) \
{ \
return realMain(DtArgc(cmdLine), DtArgv(cmdLine)); \
}
int DtArgc(char *cmdLine)
Convert a command line (single string with args separated by spaces) to argv, argc format...
char ** DtArgv(char *cmdLine, int *argc=NULL)
#define DtATOI (   s)    (int)strtol(s, 0, 0)

some versions of strtol returns INT_MAX for input larger than 0x7fffffff.

As long as strtoul accepts and properly processes negative input, this macro will work for both unsigned and signed ints (as other strtol do).

#define DtDELETE_VOID (   x,
  cast 
)
Value:
if (x) \
{ \
cast* toDelete = reinterpret_cast<cast*>(x); \
delete toDelete; \
x = 0; \
}
#define DtISOFF (   a,
 
)    (!DtISON(a, x))
#define DtISON (   a,
 
)    (a & x)
#define DtNUMBER (   foo)    (sizeof(foo)/sizeof(foo[0]))
#define DtOFFSET (   type,
  field 
)    ((size_t)&((type *)NULL)->field)
#define DtRGBA_TO_UINT (   r,
  g,
  b,
 
)    ((((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
#define DtSIZEOF (   type,
  field 
)    sizeof(((type *)NULL)->field)
#define DtTURNOFF (   a,
 
)    (a &= ~x)
#define DtTURNON (   a,
 
)    (a |= x)

Function Documentation

DtMachineSize alignedPadding ( DtMachineSize  value,
DtMachineSize  alignment 
)
inline

Return the adjustment necessary to align the given value to the given alignment Efficient means to determine padding for byte alignment avoiding costly % modulo operator (division and remainder)

Referenced by alignedPtrPadding().

DtMachineSize alignedPtrPadding ( const void *  ptr,
DtMachineSize  alignment 
)
inline

Return the # padding bytes necessary to align the given pointer to the given byte alignment (in bytes)

References alignedPadding().

const void* alignPtr ( const void *  ptr,
DtMachineSize  alignment 
)
inline

Adjust the given pointer to the given byte alignment (in bytes)

References alignValue().

void* alignPtr ( void *  ptr,
DtMachineSize  alignment 
)
inline

References alignValue().

DtMachineSize alignValue ( DtMachineSize  value,
DtMachineSize  alignment 
)
inline

Adjust the given value to the nearest multiple of the given alignment Efficient means to determine byte alignment avoiding costly % modulo operator (division and remainder)

Referenced by alignPtr().

void bzero ( char *  b,
int  length 
)

Need bzero.

char** DtArgv ( char *  cmdLine,
int argc = NULL 
)
int DtBinaryToDecimal ( const std::string &  s)

Get the decimal value given a binary value.

Parameters
sThe binary value to be converted, as a string
Returns
A int decimal value of the binary string passed in
DtString DtBinaryToHex ( const std::string &  s)

Get the hex value of a passed in 32-bit binary value.

Parameters
sThe binary value to be converted, as a string
Returns
A string hex value of the binary string passed in
void DtDecimalToBinary ( const DtU32  value,
std::vector< int > &  binVal 
)

Get the 32-bit binary value of a passed in decimal integer.

Parameters
valueThe unsigned integer value to be converted
binValA vector to be filled with the binary of the passed in value
DtString DtHexToBinary ( const std::string &  s,
int  sLength = 0 
)

Get the 32-bit binary value of a passed in hex value.

Parameters
sThe hex value to be converted, as a string
sLengthThe length, as an integer, of the binary string to be returned (i.e. 8-bit, 16-bit, etc)
Returns
A string binary value of the hex string passed in
int DtResizeString ( char *&  buf,
int oldLn,
int  newLn 
)

For VXWORKS.

void DtUINT_TO_RGBA ( unsigned int  val,
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a 
)
inline
void printHexToStream ( std::ostream &  stream,
unsigned int  numberOfColumns,
unsigned char *  ptr,
unsigned int  bytes 
)

Prints Hex to a stream based on an address and the bytes.

This is primarily used for debugging rather than for anything else.


Document ID: Generated on Wed Mar 27 02:04:30 EDT 2024 from SVN revision 264570
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)