ZeroBuf  0.4.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 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)
 
virtual void notifyChanged ()
 Called if any data in this object has changed. More...
 
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
 
bool _fromBinary (const void *data, const size_t size) override
 

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
virtual size_t zerobuf::Zerobuf::getZerobufNumDynamics ( ) const
pure virtual
Returns
the number of dynamics fields of this object.
virtual size_t zerobuf::Zerobuf::getZerobufStaticSize ( ) const
pure virtual
Returns
the static size of this object in bytes.
virtual void zerobuf::Zerobuf::notifyChanged ( )
inlineprotectedvirtual

Called if any data in this object has changed.

Definition at line 75 of file Zerobuf.h.

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

Assignment operator.

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

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