クラス rcsc::AudioCodec

communication message encoder/decorder [詳細]

#include <audio_codec.h>

すべてのメンバ一覧

Public 型

enum  BitMask {
  MASK_1 = 0x00000001, MASK_2 = 0x00000003, MASK_3 = 0x00000007, MASK_4 = 0x0000000F,
  MASK_5 = 0x0000001F, MASK_6 = 0x0000003F, MASK_7 = 0x0000007F, MASK_8 = 0x000000FF,
  MASK_9 = 0x000001FF, MASK_10 = 0x000003FF, MASK_11 = 0x000007FF, MASK_12 = 0x00000FFF,
  MASK_13 = 0x00001FFF, MASK_14 = 0x00003FFF, MASK_15 = 0x00007FFF, MASK_16 = 0x0000FFFF,
  MASK_17 = 0x0001FFFF, MASK_18 = 0x0003FFFF, MASK_19 = 0x0007FFFF, MASK_20 = 0x000FFFFF,
  MASK_21 = 0x001FFFFF, MASK_22 = 0x003FFFFF, MASK_23 = 0x007FFFFF, MASK_24 = 0x00FFFFFF,
  MASK_25 = 0x01FFFFFF, MASK_26 = 0x03FFFFFF, MASK_27 = 0x07FFFFFF, MASK_28 = 0x0FFFFFFF,
  MASK_29 = 0x1FFFFFFF, MASK_30 = 0x3FFFFFFF, MASK_31 = 0x7FFFFFFF, MASK_32 = 0xFFFFFFFF
}
typedef std::map< char, int > CharToIntCont
typedef std::vector< char > IntToCharCont

Public メソッド

const CharToIntCont & charToIntMap () const
 get character to interger map object
const IntToCharCont & intToCharMap () const
 get integer to character map object
bool encodeInt64ToStr (const boost::int64_t &ival, const int len, std::string &to) const
 encode decimal (64bit) integer to the encoded string.
bool decodeStrToInt64 (const std::string &from, boost::int64_t *to) const
 decode the message string to the decimal (64bit) integer
char encodePercentageToChar (const double &value) const
 encode % value to 1 character
double decodeCharToPercentage (const char ch) const
 decode 1 character to the real number [0,1]
bool encodePosVelToStr5 (const Vector2D &pos, const Vector2D &vel, std::string &to) const
 encode position and velocity to 5 characters.
bool decodeStr5ToPosVel (const std::string &from, Vector2D *pos, Vector2D *vel) const
 decode 5 characters to position and velocity
bool encodePosToStr3 (const Vector2D &pos, std::string &to) const
 encode position to 3 characters.
bool decodeStr3ToPos (const std::string &from, Vector2D *pos) const
 decode 3 characters to and position
bool encodeUnumPosToStr4 (const int unum, const Vector2D &pos, std::string &to) const
 encode uniform number and position to 4 characters.
bool decodeStr4ToUnumPos (const std::string &from, int *unum, Vector2D *pos) const
 decode 4 characters to uniform number and position
std::string encodeCoordToStr2 (const double &xy, const double &norm_factor) const
 encode coordinate value( x or y ) to 2 characters.
double decodeStr2ToCoord (const char ch1, const char ch2, const double &norm_factor) const
 decode 2 characters to coordinate value( x or y )
std::string encodePosToStr4 (const Vector2D &pos) const
 encode position value to 4 characters with 0.1 step
Vector2D decodeStr4ToPos (const std::string &from) const
 decode 4 characters to position value
char encodeSpeedToChar (const double &xy) const
 encode speed value to 1 character.
double decodeCharToSpeed (const char ch) const
 decode 1 character to speed value

Static Public メソッド

static const AudioCodeci ()
 singleton interface
static char unum2hex (const int unum)
 convert decimal uniform number to hex number
static int hex2unum (const char hex)
 convert hex number character to decimal uniform number.

Static Public 変数

static const double ERROR_VALUE
 constant error value (= std::numeric_limits< double >::max())
static const double X_NORM_FACTOR
 x normalize factor (field length) to limit inputed x
static const double Y_NORM_FACTOR
 y normalze factor (field width) to limit inputed y
static const double SPEED_NORM_FACTOR
 speed normalize factor to limit inputed speed range
static const double COORD_STEP_L2
 used by encodeCoordToStr2/decodeStr2ToCoord
static const double SPEED_STEP_L1
 used by encodeSpeedToChar/decodeCharToSpeed
static const std::string CHAR_SET
 available character set
static const int CHAR_SIZE
 size of CHAR_SET


説明

communication message encoder/decorder


関数

const AudioCodec & rcsc::AudioCodec::i (  )  [static]

singleton interface

戻り値:
const reference to the singleton instance

const CharToIntCont& rcsc::AudioCodec::charToIntMap (  )  const [inline]

get character to interger map object

戻り値:
const reference to the map object

const IntToCharCont& rcsc::AudioCodec::intToCharMap (  )  const [inline]

get integer to character map object

戻り値:
const reference to the map object

bool rcsc::AudioCodec::encodeInt64ToStr ( const boost::int64_t &  ival,
const int  len,
std::string &  to 
) const

encode decimal (64bit) integer to the encoded string.

引数:
ival input value
len desired string length
to reference to the result instance
戻り値:
encode status

bool rcsc::AudioCodec::decodeStrToInt64 ( const std::string &  from,
boost::int64_t *  to 
) const

decode the message string to the decimal (64bit) integer

引数:
from input message string
to pointer to the result instance
戻り値:
decode status

char rcsc::AudioCodec::encodePercentageToChar ( const double &  value  )  const

encode % value to 1 character

引数:
value real number [0,1]
戻り値:
encoded character. if value range is illegal, '0' is returned.

double rcsc::AudioCodec::decodeCharToPercentage ( const char  ch  )  const

decode 1 character to the real number [0,1]

引数:
ch character to be decoded
戻り値:
decoded value [0,1]. if ch is illegal, negative value is returned.

bool rcsc::AudioCodec::encodePosVelToStr5 ( const Vector2D pos,
const Vector2D vel,
std::string &  to 
) const

encode position and velocity to 5 characters.

引数:
pos position value to be encoded
vel velocity value to be encoded
to reference to the result variable
戻り値:
encode status
The length of result string must be 5.

bool rcsc::AudioCodec::decodeStr5ToPosVel ( const std::string &  from,
Vector2D pos,
Vector2D vel 
) const

decode 5 characters to position and velocity

引数:
from string to be decoded
pos variable pointer to store the decoded position value
vel variable pointer to store the decoded velocity value
戻り値:
true if successfully decoded
The length of 'from' must be 5.

bool rcsc::AudioCodec::encodePosToStr3 ( const Vector2D pos,
std::string &  to 
) const

encode position to 3 characters.

引数:
pos position value to be encoded
to reference to the result variable
戻り値:
encode status
The length of result string must be 3.

bool rcsc::AudioCodec::decodeStr3ToPos ( const std::string &  from,
Vector2D pos 
) const

decode 3 characters to and position

引数:
from string to be decoded
pos pointer to the result variable
戻り値:
true if successfully decoded
The length of 'from' must be 3.

bool rcsc::AudioCodec::encodeUnumPosToStr4 ( const int  unum,
const Vector2D pos,
std::string &  to 
) const

encode uniform number and position to 4 characters.

引数:
unum uniform number
pos position value to be encoded
to reference to the result variable
戻り値:
encode status
The length of result string must be 4.

bool rcsc::AudioCodec::decodeStr4ToUnumPos ( const std::string &  from,
int *  unum,
Vector2D pos 
) const

decode 4 characters to uniform number and position

引数:
from string to be decoded
unum pointer to the result variable
pos pointer to the result variable
戻り値:
true if successfully decoded
The length of 'from' must be 4.

std::string rcsc::AudioCodec::encodeCoordToStr2 ( const double &  xy,
const double &  norm_factor 
) const

encode coordinate value( x or y ) to 2 characters.

引数:
xy coordinate value to be encoded, X or Y. This value should be within [-norm_factor, norm_factor]
norm_factor normalize factor for xy
戻り値:
result string, or empty string if failed
Following condition must be satisfied:

norm_factor must be same as the value used by decodeCoordL2() norm_factor will be changed depending on the type of target coordinate value, i.e. field length or field width.

double rcsc::AudioCodec::decodeStr2ToCoord ( const char  ch1,
const char  ch2,
const double &  norm_factor 
) const

decode 2 characters to coordinate value( x or y )

引数:
ch1 first character to be decoded
ch2 second character to be decoded
norm_factor normalize factor for coordinate value
norm_factor must be same as the value used by encodeCoordL2() norm_factor will be changed depending on the type of target coordinate value, i.e. field length or field width.

std::string rcsc::AudioCodec::encodePosToStr4 ( const Vector2D pos  )  const

encode position value to 4 characters with 0.1 step

引数:
pos position value to be encoded
戻り値:
encoded string instance. if encoding is failed, empty string is returned

Vector2D rcsc::AudioCodec::decodeStr4ToPos ( const std::string &  from  )  const

decode 4 characters to position value

引数:
from message string to be decoded
戻り値:
decoded position value

char rcsc::AudioCodec::encodeSpeedToChar ( const double &  xy  )  const

encode speed value to 1 character.

引数:
xy velocity element to be encoded, X or Y
戻り値:
result char
speed value is normalized by SPEED_NORM_FACTOR

double rcsc::AudioCodec::decodeCharToSpeed ( const char  ch  )  const

decode 1 character to speed value

引数:
ch character to be decoded
戻り値:
decoded speed value. if failed to decode, HUGE_VAL is returned

char rcsc::AudioCodec::unum2hex ( const int  unum  )  [static]

convert decimal uniform number to hex number

引数:
unum decimal uniform number, that must be within [1, 11]
戻り値:
hex number character. if invalid number is given, '0' is returned.

int rcsc::AudioCodec::hex2unum ( const char  hex  )  [static]

convert hex number character to decimal uniform number.

引数:
hex hex number character, that must be within [0, B], case sensitive!
戻り値:
decimal uniform number, if invalid character is given, 0 is retuned.


このクラスの説明は次のファイルから生成されました:
librcscに対してThu May 1 15:41:25 2008に生成されました。  doxygen 1.5.0