AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxNet::Compress::Data Class Reference

#include <Compress.h>

+ Inheritance diagram for agxNet::Compress::Data:

Public Types

enum  Level { DEFAULT_COMPRESSION =-1, MIN_COMPRESSION =0, MAX_COMPRESSION =9 }
 Specifies a compression level. Default is zlib default compression level. More...
 
enum  Mode { NONE, COMPRESSED, DECOMPRESSED }
 

Public Member Functions

 Data (Mode m=NONE)
 Default constructor. More...
 
 Data (const char *source, size_t numBytes)
 Constructor which will create a Data object which contains a copy of the source data in compressed form. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
char * data ()
 
const char * data () const
 
char * data (size_t idx)
 
const char * data (size_t idx) const
 
Mode getMode () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
float ratio () const
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
size_t size () const
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
bool valid () const
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~Data ()
 destructor More...
 
void allocate (size_t numBytes)
 Resize the data-buffer to fit numBytes. More...
 
void allocateObserverVector () const
 
size_t curr () const
 
char * currData ()
 
const char * currData () const
 
void deleteUsingDeleteHandler () const
 
void finalize ()
 Make data valid and call any finalization of the compression/decompression structures. More...
 
int init (int level=DEFAULT_COMPRESSION)
 Initialize the compression/decompression with a specified compression level (only for compression) More...
 
void setCurr (size_t curr)
 set the current position in the bit stream (determines the pointer address of the returned value from currData() More...
 
void trim ()
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Definition at line 73 of file Compress.h.

Member Enumeration Documentation

Specifies a compression level. Default is zlib default compression level.

Enumerator
DEFAULT_COMPRESSION 
MIN_COMPRESSION 
MAX_COMPRESSION 

Definition at line 84 of file Compress.h.

Enumerator
NONE 
COMPRESSED 
DECOMPRESSED 

Definition at line 76 of file Compress.h.

Constructor & Destructor Documentation

agxNet::Compress::Data::Data ( Mode  m = NONE)

Default constructor.

Parameters
m- the mode of the data
agxNet::Compress::Data::Data ( const char *  source,
size_t  numBytes 
)

Constructor which will create a Data object which contains a copy of the source data in compressed form.

I.e. mode will be COMPRESSED

virtual agxNet::Compress::Data::~Data ( )
protectedvirtual

destructor

Member Function Documentation

void agxNet::Compress::Data::allocate ( size_t  numBytes)
inlineprotected

Resize the data-buffer to fit numBytes.

Definition at line 137 of file Compress.h.

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
size_t agxNet::Compress::Data::curr ( ) const
inlineprotected
Returns
index of the current position in the bit-stream

Definition at line 131 of file Compress.h.

char* agxNet::Compress::Data::currData ( )
inlineprotected
Returns
a pointer to the data-buffer at the current index (set by setCurr).

Definition at line 140 of file Compress.h.

const char* agxNet::Compress::Data::currData ( ) const
inlineprotected
Returns
a const pointer to the data-buffer at the current index (set by setCurr).

Definition at line 143 of file Compress.h.

char* agxNet::Compress::Data::data ( )
inline
Returns
a pointer to the bit-stream (compressed or non-compressed).

Definition at line 111 of file Compress.h.

const char* agxNet::Compress::Data::data ( ) const
inline
Returns
a const pointer to the bit-stream (compressed or non-compressed).

Definition at line 114 of file Compress.h.

char* agxNet::Compress::Data::data ( size_t  idx)
inline
Returns
a pointer to the bit-stream (compressed or non-compressed).

Definition at line 117 of file Compress.h.

const char* agxNet::Compress::Data::data ( size_t  idx) const
inline
Returns
a const pointer to the bit-stream (compressed or non-compressed).

Definition at line 120 of file Compress.h.

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
void agxNet::Compress::Data::finalize ( )
protected

Make data valid and call any finalization of the compression/decompression structures.

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
Mode agxNet::Compress::Data::getMode ( ) const
inline
Returns
the current mode for the data, compressed/decompressed/none

Definition at line 92 of file Compress.h.

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
int agxNet::Compress::Data::init ( int  level = DEFAULT_COMPRESSION)
protected

Initialize the compression/decompression with a specified compression level (only for compression)

template<typename T >
bool agx::Referenced::is ( ) const
inherited
float agxNet::Compress::Data::ratio ( ) const
inline
Returns
the compression ratio of the data, for decompressed data it returns 1.0

Definition at line 126 of file Compress.h.

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

void agxNet::Compress::Data::setCurr ( size_t  curr)
inlineprotected

set the current position in the bit stream (determines the pointer address of the returned value from currData()

Definition at line 134 of file Compress.h.

References agx::min().

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

size_t agxNet::Compress::Data::size ( ) const
inline
Returns
the number of bytes in the data vector

Definition at line 108 of file Compress.h.

void agxNet::Compress::Data::trim ( )
protected
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

bool agxNet::Compress::Data::valid ( ) const
inline
Returns
true if the data is valid, compression/uncompression was succesfully done.

Definition at line 123 of file Compress.h.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


The documentation for this class was generated from the following file: