![]() |
AGX Dynamics 2.40.0.0
|
Abstract base class for storing/restoring a line/drums with version control. More...
#include <StorageStream.h>
Classes | |
class | ScopedBlock |
Ties a beginBlock/endBlock pair to a scope. More... | |
Public Types | |
enum | FloatMode { AS_DOUBLE = 0 , AS_FLOAT = 1 } |
enum | Mode { RESTORE , STORE } |
enum | Status { SUCCESS , MISSING_BODY , MISSING_GEOMETRY , INVALID_MD5 , INVALID_HEADER , ERROR_WRITING_TO_OUTSTREAM , ERROR_READING_FROM_INSTREAM , ERROR_WRITING_TO_DATASTREAM , ERROR_READING_FROM_DATASTREAM , MIXING_MODES } |
Public Member Functions | |
StorageStream (Mode mode, bool useBlocks=false) | |
virtual | ~StorageStream () |
Destructor. | |
void | beginBlock (const char *blockName) |
Begin a new logical block within the stream. | |
void | clear () |
Re-initialize the stream so it has no data stored, just as it was when it was created initially. | |
bool | endBlock (const char *blockName) |
End the block started by the corresponding beginBlock . | |
bool | getEnableMD5 () const |
Mode | getMode () const |
agx::UInt16 | getSerializationVersion () const |
Status | getStatus () const |
agx::UInt16 | getStorageStreamVersion () const |
std::stringstream & | getStream () |
Return a direct reference to the current block stream, use with caution. | |
const std::stringstream & | getStream () const |
agx::UInt32 | getVersion () const |
bool | good () const |
virtual void | read (agx::AffineMatrix4x4d &val, bool readAsFloat=false) |
If readAsFloat==true , then this matrix will be read from the stream as a 16 floats. | |
virtual void | read (agx::AffineMatrix4x4f &val, bool readAsFloat=false) |
readAsFloat there to make this method compatible with write( double, bool ), it will always be read as a float | |
virtual void | read (agx::Int32 &val) |
virtual void | read (agx::Quat32 &val, bool readAsFloat=false) |
readAsFloat there to make this method compatible with write( double, bool ), it will always be read as a float | |
virtual void | read (agx::Quat64 &val, bool readAsFloat=false) |
If readAsFloat==true , then this Vec3 will be read from the stream as a 3 floats. | |
virtual bool | read (agx::RigidBody **body) |
Called when we need a valid pointer to a body. | |
virtual void | read (agx::UInt16 &val) |
virtual void | read (agx::UInt64 &val) |
virtual void | read (agx::UInt8 &val) |
virtual void | read (agx::Vec3d &val, bool readAsFloat=false) |
If readAsFloat==true , then this Vec3 will be read from the stream as a 3 floats. | |
virtual void | read (agx::Vec3f &val, bool readAsFloat=false) |
readAsFloat there to make this method compatible with write( double, bool ), it will always be read as a float | |
virtual bool | read (agxCollide::Geometry **geometry) |
Called when we need a valid pointer to a geometry. | |
virtual bool | read (agxWire::Node *node) |
Called with a valid pointer to a line node. | |
virtual void | read (bool &val) |
virtual void | read (char &val) |
bool | read (const agx::Vector< char > &buffer) |
Read data from the buffer into the stream for restore. | |
virtual void | read (double &val, bool readAsFloat=false) |
If readAsFloat==true , then this variable will be read from the stream as a float. | |
virtual void | read (float &val, bool readAsFloat=false) |
readAsFloat there to make this method compatible with write( double, bool ), it will be read as float, no matter what | |
virtual std::istream & | read (std::istream &str) |
Method that will read data from a stream into this object.Derive your own if you want to read any local data into your derived class. | |
virtual void | read (std::string &val) |
void | setEnableMD5 (bool flag) |
Enable/Disable the MD5 check of the data. | |
void | skipBlock (const char *blockName) |
virtual void | write (agx::Int32 val) |
virtual bool | write (agx::RigidBody *body) |
Called when we want to write a rigid body. | |
virtual void | write (agx::UInt16 val) |
virtual void | write (agx::UInt64 val) |
virtual void | write (agx::UInt8 val) |
bool | write (agx::Vector< char > &buffer) |
Write data from the stream into the buffer for external storage. | |
virtual bool | write (agxCollide::Geometry *geometry) |
Called when we want to write a geometry. | |
virtual bool | write (agxWire::Node *node) |
Called when we want to write a LineNode. | |
virtual void | write (bool val) |
virtual void | write (char val) |
virtual void | write (const agx::AffineMatrix4x4d &val, FloatMode writeAsFloat=AS_DOUBLE) |
If writeAsFloat==true , then this Matrix will be written to the stream as 12*float. | |
virtual void | write (const agx::AffineMatrix4x4f &val, FloatMode writeAsFloat=AS_DOUBLE) |
writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what | |
virtual void | write (const agx::Quat32 &val, FloatMode writeAsFloat=AS_DOUBLE) |
writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what | |
virtual void | write (const agx::Quat64 &val, FloatMode writeAsFloat=AS_DOUBLE) |
If writeAsFloat==true , then this vector will be written to the stream as 3*float. | |
virtual void | write (const agx::Vec3d &val, FloatMode writeAsFloat=AS_DOUBLE) |
If writeAsFloat==true , then this vector will be written to the stream as 3*float. | |
virtual void | write (const agx::Vec3f &val, FloatMode writeAsFloat=AS_DOUBLE) |
writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what | |
virtual void | write (const std::string &val) |
virtual void | write (double val, FloatMode writeAsFloat=AS_DOUBLE) |
If writeAsFloat==true , then this variable will be written to the stream as a float. | |
virtual void | write (float val, FloatMode writeAsFloat=AS_FLOAT) |
writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what | |
virtual std::ostream & | write (std::ostream &str) |
Method that will write this object to an output stream, derive your own if you want to write any local data in your derived class. | |
Protected Member Functions | |
StorageStream () | |
StorageStream (const StorageStream &) | |
void | checkMD5 () |
void | checkMode (Mode newMode) |
void | readHeader (std::istream &str) |
void | writeHeader (std::ostream &str, const char *data) |
Abstract base class for storing/restoring a line/drums with version control.
A StorageControl can either be used for WRITING data to, or READING data from, not both. The argument to the constructor will define if this is an input or an output StorageStream.
Definition at line 48 of file StorageStream.h.
Enumerator | |
---|---|
AS_DOUBLE | |
AS_FLOAT |
Definition at line 58 of file StorageStream.h.
Enumerator | |
---|---|
RESTORE | |
STORE |
Definition at line 52 of file StorageStream.h.
Definition at line 89 of file StorageStream.h.
agxStream::StorageStream::StorageStream | ( | Mode | mode, |
bool | useBlocks = false |
||
) |
mode | - specifies if the storage stream is for STORE or RESTORE |
useBlocks | - if true, block sizes will be written to enable skipBlock over blocks. This will add overhead in the STORE process. If false (default), a zero value for the block sizes will be written and skipping will not be possible. |
|
virtual |
Destructor.
|
inlineprotected |
Definition at line 324 of file StorageStream.h.
|
inlineprotected |
Definition at line 325 of file StorageStream.h.
void agxStream::StorageStream::beginBlock | ( | const char * | blockName | ) |
Begin a new logical block within the stream.
Each call to beginBlock should be matched with a corresponding call to endBlock
with the same name. Blocks may be nested.
|
protected |
|
protected |
void agxStream::StorageStream::clear | ( | ) |
Re-initialize the stream so it has no data stored, just as it was when it was created initially.
bool agxStream::StorageStream::endBlock | ( | const char * | blockName | ) |
End the block started by the corresponding beginBlock
.
|
inline |
Definition at line 307 of file StorageStream.h.
|
inline |
Definition at line 657 of file StorageStream.h.
agx::UInt16 agxStream::StorageStream::getSerializationVersion | ( | ) | const |
|
inline |
Definition at line 113 of file StorageStream.h.
agx::UInt16 agxStream::StorageStream::getStorageStreamVersion | ( | ) | const |
std::stringstream & agxStream::StorageStream::getStream | ( | ) |
Return a direct reference to the current block stream, use with caution.
const std::stringstream & agxStream::StorageStream::getStream | ( | ) | const |
agx::UInt32 agxStream::StorageStream::getVersion | ( | ) | const |
bool agxStream::StorageStream::good | ( | ) | const |
|
virtual |
If readAsFloat==true
, then this matrix will be read from the stream as a 16 floats.
|
virtual |
readAsFloat
there to make this method compatible with write( double, bool ), it will always be read as a float
|
virtual |
|
virtual |
readAsFloat
there to make this method compatible with write( double, bool ), it will always be read as a float
|
virtual |
If readAsFloat==true
, then this Vec3 will be read from the stream as a 3 floats.
|
inlinevirtual |
Called when we need a valid pointer to a body.
The derived class should set the *body pointer to a valid one.
body | - Pointer to a rigidbody pointer which should be set to a valid rigidbody |
Definition at line 407 of file StorageStream.h.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
If readAsFloat==true
, then this Vec3 will be read from the stream as a 3 floats.
|
virtual |
readAsFloat
there to make this method compatible with write( double, bool ), it will always be read as a float
|
inlinevirtual |
Called when we need a valid pointer to a geometry.
The derived class should set the *geometry pointer to a valid one.
geometry | - Pointer to a geometry pointer which should be set to a valid geometry |
Definition at line 409 of file StorageStream.h.
|
inlinevirtual |
Called with a valid pointer to a line node.
The derived class can assign user data etc during this call.
node | - valid node to assign any user specified data |
Definition at line 411 of file StorageStream.h.
|
virtual |
|
virtual |
bool agxStream::StorageStream::read | ( | const agx::Vector< char > & | buffer | ) |
Read data from the buffer into the stream for restore.
|
virtual |
If readAsFloat==true
, then this variable will be read from the stream as a float.
|
virtual |
readAsFloat
there to make this method compatible with write( double, bool ), it will be read as float, no matter what
|
virtual |
Method that will read data from a stream into this object.Derive your own if you want to read any local data into your derived class.
|
virtual |
|
protected |
|
inline |
Enable/Disable the MD5 check of the data.
Takes more time if enabled.
flag | - If true, MD5 check is enabled. A MD5 checksum will be written together with the data. |
Definition at line 302 of file StorageStream.h.
void agxStream::StorageStream::skipBlock | ( | const char * | blockName | ) |
|
virtual |
|
inlinevirtual |
Called when we want to write a rigid body.
The derived class should store this pointer/id/values somewhere so that we can later call read and get a valid pointer back.
body | - the body that is written/stored |
Definition at line 408 of file StorageStream.h.
|
virtual |
|
virtual |
|
virtual |
bool agxStream::StorageStream::write | ( | agx::Vector< char > & | buffer | ) |
Write data from the stream into the buffer for external storage.
|
inlinevirtual |
Called when we want to write a geometry.
The derived class should store this pointer/id/values somewhere so that we can later call read and get a valid pointer back.
geometry | - the geometry that is written/stored |
Definition at line 410 of file StorageStream.h.
|
inlinevirtual |
Called when we want to write a LineNode.
The derived class should store this pointer/id/values somewhere so that we can later call read and get a valid pointer back.
node | - the LineNode that is written/stored |
Definition at line 412 of file StorageStream.h.
|
virtual |
|
virtual |
|
virtual |
If writeAsFloat==true
, then this Matrix will be written to the stream as 12*float.
|
virtual |
writeAsFloat
there to make this method compatible with write( double, bool ), it WILL be written as float no matter what
|
virtual |
writeAsFloat
there to make this method compatible with write( double, bool ), it WILL be written as float no matter what
|
virtual |
If writeAsFloat==true
, then this vector will be written to the stream as 3*float.
|
virtual |
If writeAsFloat==true
, then this vector will be written to the stream as 3*float.
|
virtual |
writeAsFloat
there to make this method compatible with write( double, bool ), it WILL be written as float no matter what
|
virtual |
|
virtual |
If writeAsFloat==true
, then this variable will be written to the stream as a float.
|
virtual |
writeAsFloat
there to make this method compatible with write( double, bool ), it WILL be written as float no matter what
|
virtual |
Method that will write this object to an output stream, derive your own if you want to write any local data in your derived class.
|
protected |