Conexus::Data Struct Reference
[ConexusConexusConexus]

#include <conexus/data.h>

List of all members.


Detailed Description

This structure represents a data chunk.

Author:
Rick L Vinyard Jr


Public Types

typedef ConexusPointer< Datapointer
 Smart pointer typedef.
typedef ConexusPointer< const
Data
const_pointer
typedef ConexusPointer< Datapointer
 Smart pointer typedef.
typedef ConexusPointer< const
Data
const_pointer

Public Member Functions

 Data (size_t s=0, unsigned priority=0) throw (std::bad_alloc)
 Constructor initializes buffer to a specific size.
 Data (const void *d, size_t s, unsigned priority=0, DataMode mode=COPY) throw (std::bad_alloc)
 Constructor initializes buffer with a copy of specific data.
 Data (const Data &other)
 Copy constructor.
 ~Data ()
 Destructor.
uint8_t * data ()
 Pointer to the actual data.
const uint8_t * data () const
 Constant pointer to the actual data.
bool set_data (const void *newdata, size_t newsize, DataMode mode=COPY) throw (std::bad_alloc)
 Sets the buffer to specific data.
size_t size () const
 Current buffer size.
bool resize (size_t s) throw (std::bad_alloc)
 Resize buffer to size s.
Data clone () const
 Performs a deep copy of this data object.
 operator bool ()
 operator bool () const
 operator uint8_t * ()
 Cast to a 1-octet pointer.
 operator const uint8_t * () const
 Cast to a 1-octet const pointer.
std::string hex_string (std::string separator=std::string()) const
 Returns a hex string representation of the data.
void clear ()
 Releases any allocated memory and resets size to 0.
const Glib::TimeVal & time () const
 Returns the timeval associated with this data item.
void set_time (const Glib::TimeVal &)
 Sets the timeval associated with this data item.
void set_current_time ()
 Sets the timeval associated with this data item to the current time.
unsigned priority () const
 Get the priority, where 0 is the lowest priority.
void set_priority (unsigned p)
 Set the priority, where 0 is the lowest priority.
bool operator< (const Data &other) const
bool operator<= (const Data &other) const
bool operator== (const Data &other) const
bool operator!= (const Data &other) const
bool operator>= (const Data &other) const
bool operator> (const Data &other) const
int compare (const Data &other) const
 Similar to memcmp.
virtual ~Data ()
 Destructor.
Octet * data ()
 Pointer to the actual data.
const Octet * data () const
 Constant pointer to the actual data.
virtual void set_data (const void *newdata, size_t newsize, DataMode mode=COPY) throw (std::bad_alloc)
 Sets the buffer to specific data.
virtual size_t size () const
 Current buffer size.
virtual bool resize (size_t s) throw (std::bad_alloc)
 Resize buffer to size s.
Data::pointer clone () const
 Performs a deep copy of this data object.
 operator Octet * ()
 Cast to a 1-octet pointer.
 operator const Octet * () const
 Cast to a 1-octet const pointer.
 operator void * ()
 Cast to a void pointer.
 operator const void * () const
 Cast to a const void pointer.
std::string hex_string (std::string separator=std::string()) const
 Returns a hex string representation of the data.
virtual void clear ()
 Releases any allocated memory and resets size to 0.
sigc::signal< void, size_t > signal_size_changed ()
 Signal emitted when the buffer size is changed.
sigc::signal< void, Octet * > signal_data_buffer_changed ()
 Signal emitted when the buffer pointer is changed.
Glib::TimeVal & time ()
 Returns the timeval associated with this data item.
virtual ~Data ()
 Destructor.
Octet * data ()
 Pointer to the actual data.
const Octet * data () const
 Constant pointer to the actual data.
virtual void set_data (const void *newdata, size_t newsize, DataMode mode=COPY) throw (std::bad_alloc)
 Sets the buffer to specific data.
virtual size_t size () const
 Current buffer size.
virtual bool resize (size_t s) throw (std::bad_alloc)
 Resize buffer to size s.
Data::pointer clone () const
 Performs a deep copy of this data object.
 operator Octet * ()
 Cast to a 1-octet pointer.
 operator const Octet * () const
 Cast to a 1-octet const pointer.
 operator void * ()
 Cast to a void pointer.
 operator const void * () const
 Cast to a const void pointer.
std::string hex_string (std::string separator=std::string()) const
 Returns a hex string representation of the data.
virtual void clear ()
 Releases any allocated memory and resets size to 0.
sigc::signal< void, size_t > signal_size_changed ()
 Signal emitted when the buffer size is changed.
sigc::signal< void, Octet * > signal_data_buffer_changed ()
 Signal emitted when the buffer pointer is changed.
Glib::TimeVal & time ()
 Returns the timeval associated with this data item.

Static Public Member Functions

static pointer create (size_t s=0) throw (std::bad_alloc)
 Create a smart pointer instance initialized to a specific size.
static pointer create (const void *d, size_t s, DataMode mode=COPY) throw (std::bad_alloc)
 Create a smart pointer instance initialized to a copy of specific data.
static pointer create (size_t s=0) throw (std::bad_alloc)
 Create a smart pointer instance initialized to a specific size.
static pointer create (const void *d, size_t s, DataMode mode=COPY) throw (std::bad_alloc)
 Create a smart pointer instance initialized to a copy of specific data.

Protected Member Functions

 Data (size_t s=0) throw (std::bad_alloc)
 Constructor initializes buffer to a specific size.
 Data (const void *d, size_t s, DataMode mode=COPY) throw (std::bad_alloc)
 Constructor initializes buffer with a copy of specific data.
 Data (size_t s=0) throw (std::bad_alloc)
 Constructor initializes buffer to a specific size.
 Data (const void *d, size_t s, DataMode mode=COPY) throw (std::bad_alloc)
 Constructor initializes buffer with a copy of specific data.

Protected Attributes

Storage::pointer m_storage
sigc::signal< void, size_t > m_signal_size_changed
sigc::signal< void, Octet * > m_signal_data_buffer_changed
sigc::signal< void, size_t > m_signal_size_changed
sigc::signal< void, Octet * > m_signal_data_buffer_changed


Member Function Documentation

bool Data::set_data ( const void *  newdata,
size_t  newsize,
DataMode  mode = COPY 
) throw (std::bad_alloc)

Sets the buffer to specific data.

newdata + newsize must not be within the current storage region if a copy is performed

Returns:
false if a realloc is required and the realloc fails

bool Data::resize ( size_t  s  )  throw (std::bad_alloc)

Resize buffer to size s.

Returns:
true on success, false on failure

Data Data::clone (  )  const

Performs a deep copy of this data object.

This method allocates a new memory chunk, copies the existing data into that data chunk, and returns an object containing a smart pointer to the underlying data.

int Data::compare ( const Data other  )  const

Similar to memcmp.

Compares the memory areas of two data items. If the two data items are of different sizes (s1 and s2) only the first n bytes will be compared, where n is the lesser of s1 and s2.

Unlike memcmp, 0 will be returned only if the memory areas are identical and s1 is equal to s2.

If memcmp would return 0 for the first n bytes and s1 != s2, the an integer less than 0 is returned if s1 < s2 and an integer greater than 0 is returned if s1 > s2.

virtual bool Conexus::Data::resize ( size_t  s  )  throw (std::bad_alloc) [virtual]

Resize buffer to size s.

Returns:
true on success, false on failure

Data::pointer Conexus::Data::clone (  )  const

Performs a deep copy of this data object.

This method allocates a new memory chunk, copies the existing data into that data chunk, and returns an object containing a smart pointer to the underlying data.

virtual bool Conexus::Data::resize ( size_t  s  )  throw (std::bad_alloc) [virtual]

Resize buffer to size s.

Returns:
true on success, false on failure

Data::pointer Conexus::Data::clone (  )  const

Performs a deep copy of this data object.

This method allocates a new memory chunk, copies the existing data into that data chunk, and returns an object containing a smart pointer to the underlying data.


The documentation for this struct was generated from the following files:
Generated on Tue Mar 13 19:54:56 2007 by  doxygen 1.5.1