next up previous contents
Nächste Seite: Über dieses Dokument ... Aufwärts: Interna Vorherige Seite: Inhalt des Parameterblocks   Inhalt


Wertebereich und Speicherbedarf der einfachen Datentypen

Type Part Min Max Step Size
Int3B val 0 262143 1 3
  x -102.4 102.3 0.1  
Val5B y -102.4 102.3 0.1 5
  age 0 62 1  
  state - - -  
bool - - - - 1
char - - - - 2
Angle - -PI PI $1.5 \cdot 10^{-3}$ 2
double - -204.8 204.7 0.1 2
NodaChar - 0 63 1 1
Grade - - - - 1

Hier noch ein Auszug aus audiomsg.h als Übersicht über Umwandlungsoperatoren von oben angegebenen Datentypen. Zum Setzen von Werten immer den Konstruktor verwenden!

//////////////////////////////////////////////////////////////////////
//
// Classes for handling simple data types and automatic encoding
// into "server-bytes"
//
//////////////////////////////////////////////////////////////////////

/** holds a 3-byte integer and its 3-byte encoding */
class Int3B 
{
public:
  /** produce 0 value */
  Int3B ();
  /** create with encoded string, should contain 3 byte encoding */
  Int3B (const char* encoded);
  /** create with integer value in 0..65536 otherwise 0 */
  Int3B (const unsigned int &val);
  void encode();
  void decode();
  unsigned int getValue() const { return value; };
  const char getEncoding(unsigned short pos) const 
  { return pos<3 ? encoding[pos] : 0; }
  operator int();
private:
  unsigned int value;
  char encoding[3];
}; // class Int3B
ostream & operator << (class ostream &os, const Int3B &i);

/** holds typical information about an object, encoded into 5 bytes:
 * coordinates x,y \in [-204.8, 204,7],
 * age \in [0..63] where age=63 is interpreted as eternal or invalid 
 */

class Val5B 
{
public:
  /** produce invalid entry */
  Val5B ();
  /** create with encoded string */
  Val5B (const char* encoded);
  /** create with x in -100.0..100.0, y in -100.0..100.0, age in 0..63
    invalid values lead to valid= false */
  Val5B (const double x_, const double y_, const unsigned int age_= 0,
         const WorldObjectState state_= UNSAFE);
  
  Val5B (const Vector2d c, const unsigned int age_= 0,
         const WorldObjectState state_= UNSAFE);
  
  /** get contents */
  double getX() const { return x; }; 
  double getY() const { return y; };
  unsigned int getAge() const { return age; };
  WorldObjectState getState() const { return state; };
  bool isValid() const { return (age < INVALIDAGE); };
  void encode();
  void decode();
  const char getEncoding(unsigned short pos) const
  { return pos<5 ? encoding[pos] : 0; }
  static const unsigned int Val5B::INVALIDAGE(63);
  operator Vector2d();
private:
  double x;
  double y;
  unsigned int age;
  WorldObjectState state;
  char encoding[5];
}; // class Val5B

ostream &operator << (class ostream &os, const Val5B &v);

//////////////////////////////////////////////////////////////////////
//
// NodaChar: Holds one 6-bit char
//
//////////////////////////////////////////////////////////////////////
class NodaChar
{
public:
  NodaChar(const unsigned char val_=0);
  operator char() const;
private:
  unsigned char val;
}; // class NodaChar
ostream &operator << (class ostream &os, const NodaChar &c);

next up previous contents
Nächste Seite: Über dieses Dokument ... Aufwärts: Interna Vorherige Seite: Inhalt des Parameterblocks   Inhalt
Debian User 2001-05-17