Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

NetDatagram Class Reference

A specific kind of Datagram, especially for sending across or receiving from a network. More...

#include <netDatagram.h>

Inheritance diagram for NetDatagram:

Datagram TypedObject List of all members.

Public Member Functions

 NetDatagram ()
 Constructs an empty datagram.

 NetDatagram (const void *data, size_t size)
 Constructs a datagram from an existing block of data.

 NetDatagram (const Datagram &copy)
 NetDatagram (const NetDatagram &copy)
void operator= (const Datagram &copy)
void operator= (const NetDatagram &copy)
virtual void clear ()
 Resets the datagram to empty, in preparation for building up a new datagram.

void set_connection (const PointerTo< Connection > &connection)
 Specifies the socket to which the datagram should be written.

PointerTo< Connectionget_connection () const
 Retrieves the socket from which the datagram was read, or to which it is scheduled to be written.

void set_address (const NetAddress &address)
 Specifies the host to which the datagram should be sent.

const NetAddressget_address () const
 Retrieves the host from which the datagram was read, or to which it is scheduled to be sent.

bool operator== (const NetDatagram &other) const
bool operator!= (const NetDatagram &other) const
bool operator< (const NetDatagram &other) const
virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
void dump_hex (ostream &out) const
 Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.

void add_bool (bool value)
 Adds a boolean value to the datagram.

void add_int8 (PN_int8 value)
 Adds a signed 8-bit integer to the datagram.

void add_uint8 (PN_uint8 value)
 Adds an unsigned 8-bit integer to the datagram.

void add_int16 (PN_int16 value)
 Adds a signed 16-bit integer to the datagram.

void add_int32 (PN_int32 value)
 Adds a signed 32-bit integer to the datagram.

void add_int64 (PN_int64 value)
 Adds a signed 64-bit integer to the datagram.

void add_uint16 (PN_uint16 value)
 Adds an unsigned 16-bit integer to the datagram.

void add_uint32 (PN_uint32 value)
 Adds an unsigned 32-bit integer to the datagram.

void add_uint64 (PN_uint64 value)
 Adds an unsigned 64-bit integer to the datagram.

void add_float32 (float value)
 Adds a 32-bit single-precision floating-point number to the datagram.

void add_float64 (PN_float64 value)
 Adds a 64-bit floating-point number to the datagram.

void add_be_int16 (PN_int16 value)
 Adds a signed 16-bit big-endian integer to the datagram.

void add_be_int32 (PN_int32 value)
 Adds a signed 32-bit big-endian integer to the datagram.

void add_be_int64 (PN_int64 value)
 Adds a signed 64-bit big-endian integer to the datagram.

void add_be_uint16 (PN_uint16 value)
 Adds an unsigned 16-bit big-endian integer to the datagram.

void add_be_uint32 (PN_uint32 value)
 Adds an unsigned 32-bit big-endian integer to the datagram.

void add_be_uint64 (PN_uint64 value)
 Adds an unsigned 64-bit big-endian integer to the datagram.

void add_be_float32 (float value)
 Adds a 32-bit single-precision big-endian floating-point number to the datagram.

void add_be_float64 (PN_float64 value)
 Adds a 64-bit big-endian floating-point number to the datagram.

void add_string (const string &str)
 Adds a variable-length string to the datagram.

void add_z_string (string str)
 Adds a variable-length string to the datagram, as a NULL-terminated string.

void add_fixed_string (const string &str, size_t size)
 Adds a fixed-length string to the datagram.

void pad_bytes (size_t size)
 Adds the indicated number of zero bytes to the datagram.

void append_data (const void *data, size_t size)
 Appends some more raw data to the end of the datagram.

void append_data (const string &data)
 Appends some more raw data to the end of the datagram.

string get_message () const
 Returns the datagram's data as a string.

const void * get_data () const
 Returns a pointer to the beginning of the datagram's data.

size_t get_length () const
 Returns the number of bytes in the datagram.

bool operator== (const Datagram &other) const
bool operator!= (const Datagram &other) const
bool operator< (const Datagram &other) const
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.

bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.


Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.


Private Attributes

PointerTo< Connection_connection
NetAddress _address

Static Private Attributes

TypeHandle _type_handle

Detailed Description

A specific kind of Datagram, especially for sending across or receiving from a network.

It's different only in that it knows which Connection and/or NetAddress it is to be sent to or was received from.

Definition at line 56 of file netDatagram.h.


Constructor & Destructor Documentation

NetDatagram::NetDatagram  ) 
 

Constructs an empty datagram.

Definition at line 35 of file netDatagram.cxx.

NetDatagram::NetDatagram const void *  data,
size_t  size
 

Constructs a datagram from an existing block of data.

Definition at line 47 of file netDatagram.cxx.

NetDatagram::NetDatagram const Datagram copy  ) 
 

Definition at line 59 of file netDatagram.cxx.

NetDatagram::NetDatagram const NetDatagram &  copy  ) 
 

Definition at line 72 of file netDatagram.cxx.

References _address, _connection, NetAddress::clear(), PointerTo< Connection >::clear(), and Datagram::operator=().


Member Function Documentation

void Datagram::add_be_float32 float  value  )  [inline, inherited]
 

Adds a 32-bit single-precision big-endian floating-point number to the datagram.

Since this kind of float is not necessarily portable across different architectures, special care is required.

Definition at line 357 of file datagram.I.

References Datagram::append_data(), and INLINE.

void Datagram::add_be_float64 PN_float64  value  )  [inline, inherited]
 

Adds a 64-bit big-endian floating-point number to the datagram.

Definition at line 377 of file datagram.I.

References Datagram::_data, INLINE, and PointerToArray< unsigned char >::p().

void Datagram::add_be_int16 PN_int16  value  )  [inline, inherited]
 

Adds a signed 16-bit big-endian integer to the datagram.

Definition at line 257 of file datagram.I.

References Datagram::append_data(), ReversedNumericData::get_data(), and INLINE.

void Datagram::add_be_int32 PN_int32  value  )  [inline, inherited]
 

Adds a signed 32-bit big-endian integer to the datagram.

Definition at line 273 of file datagram.I.

References Datagram::append_data(), ReversedNumericData::get_data(), INLINE, and nassertv.

void Datagram::add_be_int64 PN_int64  value  )  [inline, inherited]
 

Adds a signed 64-bit big-endian integer to the datagram.

Definition at line 289 of file datagram.I.

References Datagram::append_data(), ReversedNumericData::get_data(), and INLINE.

void Datagram::add_be_uint16 PN_uint16  value  )  [inline, inherited]
 

Adds an unsigned 16-bit big-endian integer to the datagram.

Definition at line 305 of file datagram.I.

void Datagram::add_be_uint32 PN_uint32  value  )  [inline, inherited]
 

Adds an unsigned 32-bit big-endian integer to the datagram.

Definition at line 321 of file datagram.I.

References Datagram::add_uint8(), Datagram::append_data(), and size_t.

void Datagram::add_be_uint64 PN_uint64  value  )  [inline, inherited]
 

Adds an unsigned 64-bit big-endian integer to the datagram.

Definition at line 337 of file datagram.I.

References Datagram::append_data(), INLINE, and Datagram::pad_bytes().

void Datagram::add_bool bool  value  )  [inline, inherited]
 

Adds a boolean value to the datagram.

Definition at line 94 of file datagram.I.

References Datagram::append_data(), and INLINE.

Referenced by Camera::add_display_region().

void Datagram::add_fixed_string const string &  str,
size_t  size
[inline, inherited]
 

Adds a fixed-length string to the datagram.

If the string given is less than the requested size, this will pad the string out with zeroes; if it is greater than the requested size, this will silently truncate the string.

Definition at line 442 of file datagram.I.

void Datagram::add_float32 float  value  )  [inline, inherited]
 

Adds a 32-bit single-precision floating-point number to the datagram.

Since this kind of float is not necessarily portable across different architectures, special care is required.

Definition at line 223 of file datagram.I.

References Datagram::append_data(), ReversedNumericData::get_data(), and INLINE.

Referenced by GeomLine::draw_immediate(), GeomLinestrip::explode(), FFTCompressor::get_transpose_quats(), Spotlight::CData::make_copy(), LODSwitch::operator==(), Material::output(), AnimBundle::output(), and PStatCollectorDef::set_parent().

void Datagram::add_float64 PN_float64  value  )  [inline, inherited]
 

Adds a 64-bit floating-point number to the datagram.

Definition at line 241 of file datagram.I.

References Datagram::append_data(), ReversedNumericData::get_data(), and INLINE.

Referenced by ClassicNurbsCurve::convert_to_nurbs().

void Datagram::add_int16 PN_int16  value  )  [inline, inherited]
 

Adds a signed 16-bit integer to the datagram.

Definition at line 133 of file datagram.I.

References Datagram::append_data(), NativeNumericData::get_data(), and INLINE.

Referenced by ComputedVerticesMorph< ValueType, MorphValueType >::ComputedVerticesMorph(), and PStatCollectorDef::set_parent().

void Datagram::add_int32 PN_int32  value  )  [inline, inherited]
 

Adds a signed 32-bit integer to the datagram.

Definition at line 147 of file datagram.I.

References Datagram::append_data(), NativeNumericData::get_data(), and INLINE.

Referenced by Material::output(), and DownloadDb::Db::write().

void Datagram::add_int64 PN_int64  value  )  [inline, inherited]
 

Adds a signed 64-bit integer to the datagram.

Definition at line 161 of file datagram.I.

void Datagram::add_int8 PN_int8  value  )  [inline, inherited]
 

Adds a signed 8-bit integer to the datagram.

Definition at line 107 of file datagram.I.

Referenced by ColorAttrib::compare_to_impl(), and ClassicNurbsCurve::convert_to_nurbs().

void Datagram::add_string const string &  str  )  [inline, inherited]
 

Adds a variable-length string to the datagram.

This actually adds a count followed by n bytes.

Definition at line 393 of file datagram.I.

References Datagram::_data, INLINE, NULL, uchar, and PointerToArray< unsigned char >::v().

Referenced by AnimGroup::output(), PStatClientControlMessage::PStatClientControlMessage(), PStatServerControlMessage::PStatServerControlMessage(), and PStatCollectorDef::set_parent().

void Datagram::add_uint16 PN_uint16  value  )  [inline, inherited]
 

Adds an unsigned 16-bit integer to the datagram.

Definition at line 175 of file datagram.I.

Referenced by CharacterJoint::add_local_transform(), ComputedVerticesMorph< ValueType, MorphValueType >::ComputedVerticesMorph(), PandaNode::CData::fillin(), GeomNode::CData::make_copy(), AnimGroup::output(), AnimChannelBase::output(), AnimBundle::output(), PStatClientControlMessage::PStatClientControlMessage(), PStatServerControlMessage::PStatServerControlMessage(), ComputedVerticesMorphValue3::read_datagram(), ComputedVerticesMorphValue2::read_datagram(), RenderEffects::return_new(), BamWriter::write_pointer(), and BamWriter::~BamWriter().

void Datagram::add_uint32 PN_uint32  value  )  [inline, inherited]
 

Adds an unsigned 32-bit integer to the datagram.

Definition at line 189 of file datagram.I.

References Datagram::append_data(), and NativeNumericData::get_data().

Referenced by Camera::add_display_region(), ClassicNurbsCurve::convert_to_nurbs(), PandaNode::CData::make_copy(), DownloadDb::Db::write(), and DatagramOutputFile::write_header().

void Datagram::add_uint64 PN_uint64  value  )  [inline, inherited]
 

Adds an unsigned 64-bit integer to the datagram.

Definition at line 203 of file datagram.I.

void Datagram::add_uint8 PN_uint8  value  )  [inline, inherited]
 

Adds an unsigned 8-bit integer to the datagram.

Definition at line 120 of file datagram.I.

References Datagram::append_data(), NativeNumericData::get_data(), and INLINE.

Referenced by Datagram::add_be_uint32(), Datagram::Datagram(), GeomSprite::print_draw_immediate(), PStatClientControlMessage::PStatClientControlMessage(), PStatServerControlMessage::PStatServerControlMessage(), Texture::register_with_read_factory(), and CollisionSolid::report_undefined_intersection_test().

void Datagram::add_z_string string  str  )  [inline, inherited]
 

Adds a variable-length string to the datagram, as a NULL-terminated string.

Definition at line 415 of file datagram.I.

References Datagram::operator==().

void Datagram::append_data const string &  data  )  [inline, inherited]
 

Appends some more raw data to the end of the datagram.

Definition at line 463 of file datagram.I.

void Datagram::append_data const void *  data,
size_t  size
[inherited]
 

Appends some more raw data to the end of the datagram.

Definition at line 150 of file datagram.cxx.

References Datagram::_data, size_t, uchar, and PointerToArray< unsigned char >::v().

Referenced by Datagram::add_be_float32(), Datagram::add_be_int16(), Datagram::add_be_int32(), Datagram::add_be_int64(), Datagram::add_be_uint32(), Datagram::add_be_uint64(), Datagram::add_bool(), Datagram::add_float32(), Datagram::add_float64(), Datagram::add_int16(), Datagram::add_int32(), Datagram::add_uint32(), Datagram::add_uint8(), Datagram::Datagram(), DownloadDb::Db::Db(), DownloadDb::Db::get_multifile_name(), DownloadDb::insert_new_version(), Datagram::operator=(), and DownloadDb::Db::parse_header().

void NetDatagram::clear  )  [virtual]
 

Resets the datagram to empty, in preparation for building up a new datagram.

Reimplemented from Datagram.

Definition at line 118 of file netDatagram.cxx.

References _connection.

Referenced by DatagramQueue::insert().

void Datagram::dump_hex ostream &  out  )  const [inherited]
 

Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.

Definition at line 69 of file datagram.cxx.

virtual TypeHandle NetDatagram::force_init_type void   )  [inline, virtual]
 

Reimplemented from Datagram.

Definition at line 98 of file netDatagram.h.

const NetAddress & NetDatagram::get_address  )  const
 

Retrieves the host from which the datagram was read, or to which it is scheduled to be sent.

Definition at line 180 of file netDatagram.cxx.

TypeHandle NetDatagram::get_class_type void   )  [inline, static]
 

Reimplemented from Datagram.

Definition at line 87 of file netDatagram.h.

PointerTo< Connection > NetDatagram::get_connection  )  const
 

Retrieves the socket from which the datagram was read, or to which it is scheduled to be written.

Definition at line 150 of file netDatagram.cxx.

const void * Datagram::get_data  )  const [inline, inherited]
 

Returns a pointer to the beginning of the datagram's data.

Definition at line 491 of file datagram.I.

Referenced by Datagram::clear(), DatagramIterator::get_be_int16(), DatagramIterator::get_be_uint64(), DatagramIterator::get_fixed_string(), DatagramIterator::get_float64(), DatagramIterator::get_int64(), DatagramIterator::get_uint16(), DatagramIterator::get_uint32(), DatagramIterator::get_uint64(), and DatagramOutputFile::write_header().

size_t Datagram::get_length void   )  const [inline, inherited]
 

Returns the number of bytes in the datagram.

Definition at line 504 of file datagram.I.

Referenced by Datagram::clear(), DatagramIterator::get_be_uint64(), ConnectionWriter::send(), and DatagramOutputFile::write_header().

string Datagram::get_message  )  const [inline, inherited]
 

Returns the datagram's data as a string.

Definition at line 476 of file datagram.I.

Referenced by ClientState::ClientState(), DatagramUDPHeader::get_datagram_checksum(), DatagramTCPHeader::get_datagram_size(), HTTPClient::read(), Connection::set_ip_type_of_service(), Connection::set_keep_alive(), and DownloadDb::Db::write().

virtual TypeHandle NetDatagram::get_type void   )  const [inline, virtual]
 

Reimplemented from Datagram.

Definition at line 95 of file netDatagram.h.

int TypedObject::get_type_index  )  const [inline, inherited]
 

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

void NetDatagram::init_type void   )  [inline, static]
 

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from Datagram.

Definition at line 90 of file netDatagram.h.

Referenced by ConfigureFn().

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is the indicated type exactly.

Definition at line 101 of file typedObject.I.

Referenced by PT(), and CollisionNode::xform().

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is or derives from the indicated type.

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

bool Datagram::operator!= const Datagram other  )  const [inline, inherited]
 

Definition at line 534 of file datagram.I.

bool NetDatagram::operator!= const NetDatagram &  other  )  const [inline]
 

Definition at line 42 of file netDatagram.I.

References INLINE.

bool Datagram::operator< const Datagram other  )  const [inline, inherited]
 

Definition at line 546 of file datagram.I.

bool NetDatagram::operator< const NetDatagram &  other  )  const [inline]
 

Definition at line 54 of file netDatagram.I.

void NetDatagram::operator= const NetDatagram &  copy  ) 
 

Definition at line 101 of file netDatagram.cxx.

void NetDatagram::operator= const Datagram copy  ) 
 

Reimplemented from Datagram.

Definition at line 87 of file netDatagram.cxx.

References _address.

bool Datagram::operator== const Datagram other  )  const [inline, inherited]
 

Definition at line 516 of file datagram.I.

Referenced by Datagram::add_z_string().

bool NetDatagram::operator== const NetDatagram &  other  )  const [inline]
 

Definition at line 30 of file netDatagram.I.

References INLINE.

void Datagram::pad_bytes size_t  size  )  [inherited]
 

Adds the indicated number of zero bytes to the datagram.

Definition at line 112 of file datagram.cxx.

References Datagram::_data, and PointerToArray< unsigned char >::push_back().

Referenced by Datagram::add_be_uint64().

void NetDatagram::set_address const NetAddress address  ) 
 

Specifies the host to which the datagram should be sent.

Definition at line 165 of file netDatagram.cxx.

Referenced by ConnectionWriter::send().

void NetDatagram::set_connection const PointerTo< Connection > &  connection  ) 
 

Specifies the socket to which the datagram should be written.

Definition at line 135 of file netDatagram.cxx.

References _address.

Referenced by ConnectionWriter::send().


Member Data Documentation

NetAddress NetDatagram::_address [private]
 

Definition at line 83 of file netDatagram.h.

Referenced by NetDatagram(), operator=(), and set_connection().

PointerTo< Connection > NetDatagram::_connection [private]
 

Definition at line 82 of file netDatagram.h.

Referenced by clear(), and NetDatagram().

TypeHandle NetDatagram::_type_handle [static, private]
 

Reimplemented from Datagram.

Definition at line 24 of file netDatagram.cxx.


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:52:31 2003 for Panda by doxygen1.3