AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
agxStream::StorageStream Class Reference

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)
 

Detailed Description

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.

Member Enumeration Documentation

◆ FloatMode

Enumerator
AS_DOUBLE 
AS_FLOAT 

Definition at line 58 of file StorageStream.h.

◆ Mode

Enumerator
RESTORE 
STORE 

Definition at line 52 of file StorageStream.h.

◆ Status

Enumerator
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 

Definition at line 89 of file StorageStream.h.

Constructor & Destructor Documentation

◆ StorageStream() [1/3]

agxStream::StorageStream::StorageStream ( Mode  mode,
bool  useBlocks = false 
)
Parameters
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.

◆ ~StorageStream()

virtual agxStream::StorageStream::~StorageStream ( )
virtual

Destructor.

◆ StorageStream() [2/3]

agxStream::StorageStream::StorageStream ( const StorageStream )
inlineprotected

Definition at line 324 of file StorageStream.h.

◆ StorageStream() [3/3]

agxStream::StorageStream::StorageStream ( )
inlineprotected

Definition at line 325 of file StorageStream.h.

Member Function Documentation

◆ beginBlock()

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.

Note
Read/write errors may leave the block structure in an inconsistent state.

◆ checkMD5()

void agxStream::StorageStream::checkMD5 ( )
protected

◆ checkMode()

void agxStream::StorageStream::checkMode ( Mode  newMode)
protected

◆ clear()

void agxStream::StorageStream::clear ( )

Re-initialize the stream so it has no data stored, just as it was when it was created initially.

◆ endBlock()

bool agxStream::StorageStream::endBlock ( const char *  blockName)

End the block started by the corresponding beginBlock.

Returns
True if the stream for the ended block is good. False otherwise.

◆ getEnableMD5()

bool agxStream::StorageStream::getEnableMD5 ( ) const
inline
Returns
true if MD5 check is enabled

Definition at line 307 of file StorageStream.h.

◆ getMode()

StorageStream::Mode agxStream::StorageStream::getMode ( ) const
inline

Definition at line 657 of file StorageStream.h.

◆ getSerializationVersion()

agx::UInt16 agxStream::StorageStream::getSerializationVersion ( ) const
Returns
serialization version stored in the storage stream

◆ getStatus()

Status agxStream::StorageStream::getStatus ( ) const
inline
Returns
the current status of this Storage

Definition at line 113 of file StorageStream.h.

◆ getStorageStreamVersion()

agx::UInt16 agxStream::StorageStream::getStorageStreamVersion ( ) const
Returns
Storage stream version stored in the storage stream. Introduced in 2.19.0.0.

◆ getStream() [1/2]

std::stringstream & agxStream::StorageStream::getStream ( )

Return a direct reference to the current block stream, use with caution.

◆ getStream() [2/2]

const std::stringstream & agxStream::StorageStream::getStream ( ) const

◆ getVersion()

agx::UInt32 agxStream::StorageStream::getVersion ( ) const
Returns
version conglomerated into one agx::UInt32 for easier comparison using AGX_CALC_VERSION()

◆ good()

bool agxStream::StorageStream::good ( ) const
Returns
True if the current block stream is good.

◆ read() [1/20]

virtual void agxStream::StorageStream::read ( agx::AffineMatrix4x4d val,
bool  readAsFloat = false 
)
virtual

If readAsFloat==true, then this matrix will be read from the stream as a 16 floats.

◆ read() [2/20]

virtual void agxStream::StorageStream::read ( agx::AffineMatrix4x4f val,
bool  readAsFloat = false 
)
virtual

readAsFloat there to make this method compatible with write( double, bool ), it will always be read as a float

◆ read() [3/20]

virtual void agxStream::StorageStream::read ( agx::Int32 val)
virtual

◆ read() [4/20]

virtual void agxStream::StorageStream::read ( agx::Quat32 val,
bool  readAsFloat = false 
)
virtual

readAsFloat there to make this method compatible with write( double, bool ), it will always be read as a float

◆ read() [5/20]

virtual void agxStream::StorageStream::read ( agx::Quat64 val,
bool  readAsFloat = false 
)
virtual

If readAsFloat==true, then this Vec3 will be read from the stream as a 3 floats.

◆ read() [6/20]

bool agxStream::StorageStream::read ( agx::RigidBody **  body)
inlinevirtual

Called when we need a valid pointer to a body.

The derived class should set the *body pointer to a valid one.

Parameters
body- Pointer to a rigidbody pointer which should be set to a valid rigidbody
Returns
false if something went wrong in the read method, indicates that restoring body failed.

Definition at line 407 of file StorageStream.h.

◆ read() [7/20]

virtual void agxStream::StorageStream::read ( agx::UInt16 val)
virtual

◆ read() [8/20]

virtual void agxStream::StorageStream::read ( agx::UInt64 val)
virtual

◆ read() [9/20]

virtual void agxStream::StorageStream::read ( agx::UInt8 val)
virtual

◆ read() [10/20]

virtual void agxStream::StorageStream::read ( agx::Vec3d val,
bool  readAsFloat = false 
)
virtual

If readAsFloat==true, then this Vec3 will be read from the stream as a 3 floats.

◆ read() [11/20]

virtual void agxStream::StorageStream::read ( agx::Vec3f val,
bool  readAsFloat = false 
)
virtual

readAsFloat there to make this method compatible with write( double, bool ), it will always be read as a float

◆ read() [12/20]

bool agxStream::StorageStream::read ( agxCollide::Geometry **  geometry)
inlinevirtual

Called when we need a valid pointer to a geometry.

The derived class should set the *geometry pointer to a valid one.

Parameters
geometry- Pointer to a geometry pointer which should be set to a valid geometry
Returns
false if something went wrong in the read method, indicates that restoring geometry failed.

Definition at line 409 of file StorageStream.h.

◆ read() [13/20]

bool agxStream::StorageStream::read ( agxWire::Node node)
inlinevirtual

Called with a valid pointer to a line node.

The derived class can assign user data etc during this call.

Parameters
node- valid node to assign any user specified data
Returns
true if successful - otherwise false

Definition at line 411 of file StorageStream.h.

◆ read() [14/20]

virtual void agxStream::StorageStream::read ( bool &  val)
virtual

◆ read() [15/20]

virtual void agxStream::StorageStream::read ( char &  val)
virtual

◆ read() [16/20]

bool agxStream::StorageStream::read ( const agx::Vector< char > &  buffer)

Read data from the buffer into the stream for restore.

◆ read() [17/20]

virtual void agxStream::StorageStream::read ( double &  val,
bool  readAsFloat = false 
)
virtual

If readAsFloat==true, then this variable will be read from the stream as a float.

◆ read() [18/20]

virtual void agxStream::StorageStream::read ( float &  val,
bool  readAsFloat = false 
)
virtual

readAsFloat there to make this method compatible with write( double, bool ), it will be read as float, no matter what

◆ read() [19/20]

virtual std::istream & agxStream::StorageStream::read ( std::istream &  str)
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.

◆ read() [20/20]

virtual void agxStream::StorageStream::read ( std::string &  val)
virtual

◆ readHeader()

void agxStream::StorageStream::readHeader ( std::istream &  str)
protected

◆ setEnableMD5()

void agxStream::StorageStream::setEnableMD5 ( bool  flag)
inline

Enable/Disable the MD5 check of the data.

Takes more time if enabled.

Parameters
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.

◆ skipBlock()

void agxStream::StorageStream::skipBlock ( const char *  blockName)

◆ write() [1/20]

virtual void agxStream::StorageStream::write ( agx::Int32  val)
virtual

◆ write() [2/20]

bool agxStream::StorageStream::write ( agx::RigidBody body)
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.

Parameters
body- the body that is written/stored
Returns
false indicates that something went wrong when storing the body.

Definition at line 408 of file StorageStream.h.

◆ write() [3/20]

virtual void agxStream::StorageStream::write ( agx::UInt16  val)
virtual

◆ write() [4/20]

virtual void agxStream::StorageStream::write ( agx::UInt64  val)
virtual

◆ write() [5/20]

virtual void agxStream::StorageStream::write ( agx::UInt8  val)
virtual

◆ write() [6/20]

bool agxStream::StorageStream::write ( agx::Vector< char > &  buffer)

Write data from the stream into the buffer for external storage.

◆ write() [7/20]

bool agxStream::StorageStream::write ( agxCollide::Geometry geometry)
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.

Parameters
geometry- the geometry that is written/stored
Returns
false indicates that something went wrong when storing the geometry.

Definition at line 410 of file StorageStream.h.

◆ write() [8/20]

bool agxStream::StorageStream::write ( agxWire::Node node)
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.

Parameters
node- the LineNode that is written/stored
Returns
false indicates that something went wrong when storing the node.

Definition at line 412 of file StorageStream.h.

◆ write() [9/20]

virtual void agxStream::StorageStream::write ( bool  val)
virtual

◆ write() [10/20]

virtual void agxStream::StorageStream::write ( char  val)
virtual

◆ write() [11/20]

virtual void agxStream::StorageStream::write ( const agx::AffineMatrix4x4d val,
FloatMode  writeAsFloat = AS_DOUBLE 
)
virtual

If writeAsFloat==true, then this Matrix will be written to the stream as 12*float.

◆ write() [12/20]

virtual void agxStream::StorageStream::write ( const agx::AffineMatrix4x4f val,
FloatMode  writeAsFloat = AS_DOUBLE 
)
virtual

writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what

◆ write() [13/20]

virtual void agxStream::StorageStream::write ( const agx::Quat32 val,
FloatMode  writeAsFloat = AS_DOUBLE 
)
virtual

writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what

◆ write() [14/20]

virtual void agxStream::StorageStream::write ( const agx::Quat64 val,
FloatMode  writeAsFloat = AS_DOUBLE 
)
virtual

If writeAsFloat==true, then this vector will be written to the stream as 3*float.

◆ write() [15/20]

virtual void agxStream::StorageStream::write ( const agx::Vec3d val,
FloatMode  writeAsFloat = AS_DOUBLE 
)
virtual

If writeAsFloat==true, then this vector will be written to the stream as 3*float.

◆ write() [16/20]

virtual void agxStream::StorageStream::write ( const agx::Vec3f val,
FloatMode  writeAsFloat = AS_DOUBLE 
)
virtual

writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what

◆ write() [17/20]

virtual void agxStream::StorageStream::write ( const std::string &  val)
virtual

◆ write() [18/20]

virtual void agxStream::StorageStream::write ( double  val,
FloatMode  writeAsFloat = AS_DOUBLE 
)
virtual

If writeAsFloat==true, then this variable will be written to the stream as a float.

◆ write() [19/20]

virtual void agxStream::StorageStream::write ( float  val,
FloatMode  writeAsFloat = AS_FLOAT 
)
virtual

writeAsFloat there to make this method compatible with write( double, bool ), it WILL be written as float no matter what

◆ write() [20/20]

virtual std::ostream & agxStream::StorageStream::write ( std::ostream &  str)
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.

◆ writeHeader()

void agxStream::StorageStream::writeHeader ( std::ostream &  str,
const char *  data 
)
protected

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