ZeroBuf  0.2.0
Zero-copy, zero-serialize, zero-hassle protocol buffers
zerobuf::Zerobuf Class Referenceabstract

Base class for all Zerobuf serializable objects. More...

#include <Zerobuf.h>

+ Inheritance diagram for zerobuf::Zerobuf:
+ Collaboration diagram for zerobuf::Zerobuf:

Public Member Functions

virtual size_t getZerobufStaticSize () const =0
 
virtual size_t getZerobufNumDynamics () const =0
 
virtual void notifyChanging ()
 Called if any data in this object is about to change. More...
 
virtual void compact (float threshold=0.1f)
 Remove unused holes from the zerobuf. More...
 
Zerobufoperator= (const Zerobuf &rhs)
 Assignment operator. More...
 
 Zerobuf (Zerobuf &&rhs)
 Move ctor. More...
 
Zerobufoperator= (Zerobuf &&rhs)
 Move operator. More...
 
bool operator== (const Zerobuf &rhs) const
 
bool operator!= (const Zerobuf &rhs) const
 
void reset (AllocatorPtr allocator)
 
void check () const
 

Protected Member Functions

 Zerobuf (AllocatorPtr alloc)
 
const AllocatorgetAllocator () const
 
AllocatorgetAllocator ()
 
void _copyZerobufArray (const void *data, size_t size, size_t arrayNum)
 
virtual void _parseJSON (const Json::Value &json)
 
virtual void _createJSON (Json::Value &json) const
 

Friends

void fromJSON (const Json::Value &, Zerobuf &)
 
void toJSON (const Zerobuf &, Json::Value &)
 

Detailed Description

Base class for all Zerobuf serializable objects.

The zerobufCxx.py code generator creates subclasses of this class. Zerobuf objects can serialize/deserialize directly from their member storage and from and to JSON. All members are zero-initialized, unless they do have a default value. fromJSON() will compact the Zerobuf.

Definition at line 28 of file Zerobuf.h.

Constructor & Destructor Documentation

zerobuf::Zerobuf::Zerobuf ( Zerobuf &&  rhs)

Move ctor.

Member Function Documentation

virtual void zerobuf::Zerobuf::compact ( float  threshold = 0.1f)
virtual

Remove unused holes from the zerobuf.

Compaction only occurs if the current allocation exceeds the relative threshold to the optimal size, that is, if unusedMemory divided by optimalMemory is above the threshold.

Parameters
thresholdthe compaction threshold

Reimplemented in zerobuf::render::ImageJPEG.

Referenced by notifyChanging().

+ Here is the caller graph for this function:

virtual size_t zerobuf::Zerobuf::getZerobufNumDynamics ( ) const
pure virtual
Returns
the number of dynamics fields of this object.

Implemented in zerobuf::render::Camera, zerobuf::render::ImageJPEG, zerobuf::render::Vector3f, and zerobuf::render::LookupTable1D.

virtual size_t zerobuf::Zerobuf::getZerobufStaticSize ( ) const
pure virtual
Returns
the static size of this object in bytes.

Implemented in zerobuf::render::Camera, zerobuf::render::ImageJPEG, zerobuf::render::Vector3f, and zerobuf::render::LookupTable1D.

virtual void zerobuf::Zerobuf::notifyChanging ( )
inlinevirtual

Called if any data in this object is about to change.

Definition at line 38 of file Zerobuf.h.

References compact(), operator!=(), operator=(), and operator==().

+ Here is the call graph for this function:

bool zerobuf::Zerobuf::operator!= ( const Zerobuf rhs) const
Returns
true if both objects contain different data

Referenced by notifyChanging().

+ Here is the caller graph for this function:

Zerobuf& zerobuf::Zerobuf::operator= ( const Zerobuf rhs)

Assignment operator.

Referenced by notifyChanging().

+ Here is the caller graph for this function:

Zerobuf& zerobuf::Zerobuf::operator= ( Zerobuf &&  rhs)

Move operator.

May copy data if zerobuf is not movable

bool zerobuf::Zerobuf::operator== ( const Zerobuf rhs) const
Returns
true if both objects contain the same data

Referenced by notifyChanging().

+ Here is the caller graph for this function:


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