Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

COD Class Reference

COD stands for Compact Object Description. More...

#include <cod.hh>

Inheritance diagram for COD:

RemoteCOD List of all members.

Public Member Functions

Static Public Member Functions

Protected Member Functions

Protected Attributes


Detailed Description

COD stands for Compact Object Description.

It is a binary file format for saving and loading Vobjects, and (in the form of the RemoteCOD subclass) is also used for efficient batch downloads of the state of many remote vobjects.

Definition at line 32 of file cod.hh.


Constructor & Destructor Documentation

COD::COD LocalSite ls  ) 
 

Constructor.

Does not initialize with an iostream, so you will have to supply a buffer when you call readCOD or writeCOD.

Parameters:
ls The local site any new vobjects will be created on.

Definition at line 37 of file cod.cc.

COD::COD iostream &  io,
LocalSite ls
 

Constructor.

Parameters:
io the io stream to read from or write to
ls The local site any new vobjects will be created on.

Definition at line 31 of file cod.cc.

COD::~COD  )  [virtual]
 

Destructor.

Definition at line 44 of file cod.cc.


Member Function Documentation

int COD::addVobject Vobject *  v,
const deque< string > &  types,
MessageBlock *  mb,
bool  saveChildren
[virtual]
 

Add a Vobject to this COD.

This uses the supplied values, overriding the information stored in the Vobject itself. It does not call Vobject::saveState()

Parameters:
v the Vobject
types the type strings to be saved
mb a message block of messages used to restore the state of this Vobject
saveChildren should the child list be saved in this COD?
Returns:
the position of this entry in the COD's vobject table

Definition at line 101 of file cod.cc.

int COD::addVobject Vobject *  v,
const set< string > &  types,
MessageBlock *  mb,
bool  saveChildren
[virtual]
 

Add a Vobject to this COD.

This uses the supplied values, overriding the information stored in the Vobject itself. It does not call Vobject::saveState()

Parameters:
v the Vobject
types the type strings to be saved
mb a message block of messages used to restore the state of this Vobject
saveChildren should the child list be saved in this COD?
Returns:
the position of this entry in the COD's vobject table

Definition at line 85 of file cod.cc.

int COD::addVobject Vobject *  v,
bool  portable,
bool  saveChildren
[virtual]
 

Add a Vobject to this COD.

Parameters:
v the Vobject
portable passed to Vobject::saveState -- should this COD save site- or configuration-specific information (possibly making for a smaller COD) or embed all necessary data?
saveChildren should the child list be saved in this COD?
Returns:
the position of this entry in the COD's vobject table
Note:
This will use Vobject::saveState to get additional details

Definition at line 70 of file cod.cc.

Referenced by LocalSearch::doActions(), RemoteCOD::readCOD(), and readCOD().

bool COD::checkCOD  )  [protected, virtual]
 

Definition at line 454 of file cod.cc.

Referenced by RemoteCOD::readCOD(), and readCOD().

void COD::clear  )  [virtual]
 

Clear the COD Vobject table.

Definition at line 57 of file cod.cc.

Referenced by ~COD().

int COD::computeSize  )  [virtual]
 

Computes the output size of the COD.

Returns:
the number of bytes needed to store this COD

Definition at line 342 of file cod.cc.

Referenced by writeCOD().

LocalSite & COD::getLocalSite  )  [virtual]
 

Get the default local site.

Returns:
the local site NOTE you should assign this to a vRef<> or call release when you're done!

Definition at line 561 of file cod.cc.

Referenced by LocalSearch::doActions().

COD::Entry * COD::getVobject int  pos  )  [virtual]
 

Get the Vobject by position in the COD Vobject table.

Parameters:
pos the position
Returns:
the entry, or NULL if invalid

Definition at line 133 of file cod.cc.

COD::Entry * COD::getVobject const string &  name  )  [virtual]
 

Get the Vobject from the COD Vobject table by site name.

Parameters:
name the site name
Returns:
the entry, or NULL if invalid

Definition at line 126 of file cod.cc.

Referenced by LocalSearch::doActions().

void COD::gzipCompress unsigned char **  dest,
unsigned int *  destlen,
const unsigned char *  source,
unsigned int  srclen
[static]
 

Definition at line 819 of file cod.cc.

Referenced by writeCOD().

void COD::gzipUncompress unsigned char **  dest,
unsigned int *  destlen,
const unsigned char *  source,
unsigned int  srclen
[static]
 

Definition at line 872 of file cod.cc.

Referenced by checkCOD().

int COD::numVobjects  )  [virtual]
 

Number of Vobjects in the COD Vobject table.

Returns:
the table size

Definition at line 121 of file cod.cc.

int COD::pack uint8_t buf,
int  maxsize,
char *  fmt,
... 
[static]
 

A utility function which writes some variables to the supplied buffer, following the format string.

The values are written in network byte order (big-endian). The format string supports the following data types:

'c': a char, or single byte

's': a short, or 16 bit integer

'l': a long, or 32 bit integer

'S': a string. This must actually be passed in as two values, first the length (a 16 bit unsigned integer) and then a char* to the actual character data. The string is packed using a leading 16 bit length followed by the string data.

'f': a 32-bit IEEE floating point number

Parameters:
buf the buffer to write to
maxsize the maximum size of the buffer, to avoid overflows
fmt the format string
... the values to be written to the buffer
Returns:
the number of bytes written to the buffer, which will always be <= maxsize
Note:
Here's an example of using pack:
char c = 'Q';
short int s = 42;
long int l = 999999;
char* S = "Foo Bar Baz";
float f = 3.21;
char buffer[256];

int length = pack(buffer, sizeof(buffer), "cslSf", c, s, l, strlen(S), S, f);

Definition at line 686 of file cod.cc.

Referenced by A3DL::PolygonMesh::packTextureSpace(), A3DL::PolygonMesh::setNormal(), A3DL::PolygonMesh::setNormals(), A3DL::PolygonMesh::setPolygon(), A3DL::PolygonMesh::setPolygons(), A3DL::PolygonMesh::setTexel(), A3DL::PolygonMesh::setTexels(), A3DL::PolygonMesh::setVertex(), A3DL::PolygonMesh::setVertices(), writeCOD(), writeObjectChildren(), and writeObjectDesc().

void COD::read unsigned char *  data,
unsigned int  size
[protected]
 

Definition at line 380 of file cod.cc.

void COD::read char *  data,
unsigned int  size
[protected]
 

Definition at line 392 of file cod.cc.

Referenced by checkCOD(), RemoteCOD::readCOD(), readCOD(), readLong(), readObjectDesc(), readShort(), and readStr().

void COD::readCOD unsigned char *  buffer,
unsigned int  size
[virtual]
 

Read the COD from the supplied data buffer.

Parameters:
buffer the source data
size the length of the data

Reimplemented in RemoteCOD.

Definition at line 444 of file cod.cc.

void COD::readCOD  )  [virtual]
 

Read a COD from the initialized iostream.

Reimplemented in RemoteCOD.

Definition at line 494 of file cod.cc.

Referenced by checkCOD(), RemoteCOD::readCOD(), and readCOD().

unsigned long COD::readLong  )  [protected, virtual]
 

Definition at line 282 of file cod.cc.

Referenced by RemoteCOD::readCOD(), readCOD(), readObjectChildren(), and readObjectDesc().

void COD::readObjectChildren string &  parent,
deque< PCR > &  children
[protected, virtual]
 

Definition at line 330 of file cod.cc.

Referenced by RemoteCOD::readCOD(), and readCOD().

void COD::readObjectDesc string &  name,
long &  pos,
deque< string > &  types,
MessageBlock &  mb
[protected, virtual]
 

Definition at line 291 of file cod.cc.

Referenced by RemoteCOD::readCOD(), and readCOD().

unsigned short int COD::readShort  )  [protected, virtual]
 

Definition at line 273 of file cod.cc.

Referenced by readObjectDesc().

string COD::readStr  )  [protected, virtual]
 

Definition at line 260 of file cod.cc.

Referenced by readObjectChildren(), and readObjectDesc().

void COD::removeVobject int  pos  )  [virtual]
 

Remove a Vobject from the COD Vobject table.

Parameters:
pos the position in the COD Vobject table

Definition at line 154 of file cod.cc.

void COD::removeVobject const string &  name  )  [virtual]
 

Remove a Vobject from the COD Vobject table.

Parameters:
name the site name

Definition at line 140 of file cod.cc.

void COD::setStream iostream &  io  )  [virtual]
 

Change the iostream to use.

Definition at line 52 of file cod.cc.

int COD::unpack const uint8_t buf,
int  maxsize,
char *  fmt,
... 
[static]
 

A utility function that reads some values from a packed data buffer.

It is symmetric to the unpack() function. The only major difference being that pointers to variables are passed in to which the unpacked values will be assigned.

Parameters:
buf the buffer to read from
the maximum size of the buffer, to avoid overruns
fmt the format string
... pointers to variables to store the unpacked contents
Returns:
the number of bytes read
Note:
Here's an example of using unpack:
char* buffer = getSomeData();
int buffersize = getSomeDataLength();

char c;
short int s, strsize;
long int l;
char* S;
float f;

int length = unpack(buffer, buffersize, "cslSf", &c, &s, &l, &strsize, &S, &f);

Definition at line 750 of file cod.cc.

Referenced by A3DL::PolygonMesh::getNormals(), A3DL::PolygonMesh::getPolygons(), A3DL::PolygonMesh::getTexels(), A3DL::PolygonMesh::getVertices(), readLong(), readShort(), readStr(), and A3DL::PolygonMesh::unpackTextureSpace().

void COD::write const unsigned char *  data,
unsigned int  size
[protected]
 

Definition at line 368 of file cod.cc.

void COD::write const char *  data,
unsigned int  size
[protected]
 

Definition at line 374 of file cod.cc.

Referenced by writeCOD(), writeObjectChildren(), and writeObjectDesc().

void COD::writeCOD unsigned char **  buffer,
unsigned int *  size,
bool  gzipped = true
[virtual]
 

Write the current COD to a buffer.

The buffer is malloc()'d by writeCOD and returned via the supplied parameters.

Parameters:
buffer the data buffer holding the COD data. You should free() this when you're done.
size the size of the buffer

Definition at line 404 of file cod.cc.

void COD::writeCOD bool  gzipped = true  )  [virtual]
 

Write the current COD to the initialized iostream.

Definition at line 359 of file cod.cc.

Referenced by LocalSearch::handleSearch().

int COD::writeObjectChildren Vobject *  v,
bool  doWrite = true
[protected, virtual]
 

Definition at line 219 of file cod.cc.

Referenced by computeSize(), and writeCOD().

int COD::writeObjectDesc Entry v,
bool  doWrite = true
[protected, virtual]
 

Definition at line 171 of file cod.cc.

Referenced by computeSize(), and writeCOD().


Member Data Documentation

unsigned char* COD::buffer [protected]
 

Definition at line 71 of file cod.hh.

Referenced by checkCOD(), read(), readCOD(), readLong(), readShort(), readStr(), write(), writeCOD(), writeObjectChildren(), writeObjectDesc(), and ~COD().

unsigned int COD::buffersize [protected]
 

Definition at line 70 of file cod.hh.

Referenced by checkCOD(), read(), readCOD(), and writeCOD().

iostream* COD::f [protected]
 

Definition at line 63 of file cod.hh.

Referenced by checkCOD(), pack(), read(), setStream(), unpack(), and writeCOD().

LocalSite& COD::ls [protected]
 

Definition at line 64 of file cod.hh.

Referenced by COD(), getLocalSite(), readCOD(), writeObjectDesc(), and ~COD().

unsigned int COD::offset [protected]
 

Definition at line 69 of file cod.hh.

Referenced by gzipUncompress(), read(), readCOD(), write(), and writeCOD().

deque<Entry*> COD::vobjectorder [protected]
 

Definition at line 67 of file cod.hh.

Referenced by addVobject(), clear(), computeSize(), getVobject(), numVobjects(), removeVobject(), and writeCOD().

map<string, Entry*> COD::vobjectTable [protected]
 

Definition at line 66 of file cod.hh.

Referenced by addVobject(), clear(), getVobject(), readCOD(), removeVobject(), and writeObjectChildren().


The documentation for this class was generated from the following files:
Generated on Tue Aug 12 03:55:52 2003 for Interreality Project - VOS by doxygen 1.3.2