Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

dcs::fee::FeePacket Class Reference

#include <FeePacket.hpp>


Detailed Description

This class covers the work for marshalling and unmarshalling the command, send down to the DIM-Server.

Author:
Christian Kofler, Sebastian Bablok, Eric Conner


Public Member Functions

 FeePacket (short errorCode, char *payload, int payloadSize, bool checksum=false, FlagBits flags=0x0000, bool huffman=false)
 ~FeePacket ()
unsigned int getId () const
short getErrorCode () const
int getPayloadSize () const
int getFeePacketSize () const

Private Member Functions

 FeePacket (unsigned int id, short errorCode, char *payload, bool legal, int payloadSize, bool checksum=false, FlagBits flags=0x0000, bool huffman=false)
void initFeePacket (unsigned int id, short errorCode, char *payload, int payloadSize, bool checksum, FlagBits flags, bool huffman, bool legal=true)

Static Private Member Functions

unsigned int calculateChecksum (unsigned char *input, int size)

Private Attributes

short mErrorCode
unsigned int mId
FlagBits mFlags
unsigned int mChecksum
char * mPayload
int mPayloadSize
bool mValid

Static Private Attributes

const int HEADER_SIZE = FEE_PACKET_HEADER_SIZE
unsigned int mLastID = 0


Constructor & Destructor Documentation

FeePacket::FeePacket unsigned int  id,
short  errorCode,
char *  payload,
bool  legal,
int  payloadSize,
bool  checksum = false,
FlagBits  flags = 0x0000,
bool  huffman = false
[private]
 

Constructor for a command.

If the huffman-flag is set, the payload will be coded in huffman here in the constructor due to consistency of the payload size member. This means: the payload and payloadSize differs from the input in the constructor afterwards.

Parameters:
id id of the package
errorCode the errorCode in the header of the command
payload the payload of the command to be send
legal indicates, if payload data is valid.
payloadSize the size of the payload in bytes
checksum indicates, if checksum-flag is or will be set (depends on marshall or unmarshall, by default this flag is set to false)
flags contains flag bits, indicating commands to feeserver (by default this flag is set to NO_FLAGS)
huffman indicates, if huffman-flag is or will be set (depends on marshall or unmarshall, by default this flag is set to false), NOTE: If flag is set,the checksum - flag will be set automatically.

FeePacket::FeePacket short  errorCode,
char *  payload,
int  payloadSize,
bool  checksum = false,
FlagBits  flags = 0x0000,
bool  huffman = false
 

Constructor for a command.

If the huffman-flag is set, the payload will be coded in huffman here in the constructor due to consistency of the payload size member. This means: the payload and payloadSize differs from the input in the constructor afterwards. The ID for the FeePacket is set inside this constructor.

Parameters:
errorCode the errorCode in the header of the command
payload the payload of the command to be send
payloadSize the size of the payload in bytes
checksum indicates, if checksum-flag is or will be set (depends on marshall or unmarshall, by default this flag is set to false)
flags flags contains flag bits, indicating commands to feeserver (by default this flag is set to NO_FLAGS)
huffman indicates, if huffman-flag is or will be set (depends on marshall or unmarshall, by default this flag is set to false), NOTE: If flag is set,the checksum - flag will be set automatically.

FeePacket::~FeePacket  ) 
 

Destructor for a FeePacket object.


Member Function Documentation

unsigned int FeePacket::calculateChecksum unsigned char *  input,
int  size
[static, private]
 

Method to calculate the checksum of an input stream.

This function uses the Adler32 algorithm, which returns a 4 byte long checksum and can check any length of input stream. Normally used to calculate the checksum of the payload. Note: the checksum is always taken before huffman encoding and after huffman decoding, so we check also the correctness of the decoded data.

Parameters:
input stream to calculate checksum of (NOTE: use of "unsigned char*" is important to be compatible with different plattforms; is mainly important, when checking binary data.)
size the size of the input stream
Returns:
4 byte long checksum.

short dcs::fee::FeePacket::getErrorCode  )  const [inline]
 

Gives back the error Code, if it is the result data from the FeeServer.

For more details see FeeServer: fee_errors.h

Returns:
error code

int dcs::fee::FeePacket::getFeePacketSize  )  const [inline]
 

Gives back the size of the command in bytes.

Returns:
the commandsize in bytes

unsigned int dcs::fee::FeePacket::getId  )  const [inline]
 

Gives back package ID of this command.

Returns:
package ID

int dcs::fee::FeePacket::getPayloadSize  )  const [inline]
 

Gives back the payload size.

Returns:
payload size in bytes

void FeePacket::initFeePacket unsigned int  id,
short  errorCode,
char *  payload,
int  payloadSize,
bool  checksum,
FlagBits  flags,
bool  huffman,
bool  legal = true
[private]
 

Initializes a FeePacket.

This function is used by both construtors to initialize the packet and covers the part, which is identic for both construction methods.

Parameters:
id id of the package
errorCode the errorCode in the header of the command
payload the payload of the command to be send
payloadSize the size of the payload in bytes
checksum indicates, if checksum-flag is or will be set (depends on marshall or unmarshall, by default this flag is set to false)
flags flags contains flag bits, indicating commands to feeserver (by default this flag is set to NO_FLAGS)
huffman indicates, if huffman-flag is or will be set (depends on marshall or unmarshall, by default this flag is set to false), NOTE: If flag is set,the checksum - flag will be set automatically.
legal indicates, if payload data is valid. (default = true).


Field Documentation

const int FeePacket::HEADER_SIZE = FEE_PACKET_HEADER_SIZE [static, private]
 

Headersize, does NOT change.

unsigned int dcs::fee::FeePacket::mChecksum [private]
 

stores the checksum

short dcs::fee::FeePacket::mErrorCode [private]
 

stores the errorCode, no error code is represented by 0

FlagBits dcs::fee::FeePacket::mFlags [private]
 

stores the flags

unsigned int dcs::fee::FeePacket::mId [private]
 

stores the package id

unsigned int FeePacket::mLastID = 0 [static, private]
 

Last transmitted ID for FeePackets.

char* dcs::fee::FeePacket::mPayload [private]
 

stores the payload, not NULL terminated !

int dcs::fee::FeePacket::mPayloadSize [private]
 

stores the payload size in bytes

bool dcs::fee::FeePacket::mValid [private]
 

indicates, if payload is valid (checksum correct).


The documentation for this class was generated from the following files:
Generated on Thu Mar 29 19:21:15 2007 for Fee Client Library by doxygen 1.3.5