AGX Dynamics 2.41.2.0
Loading...
Searching...
No Matches
agxStream::OutputArchive Class Reference

Class for writing serialized data in binary format to a stream. More...

#include <OutputArchive.h>

+ Inheritance diagram for agxStream::OutputArchive:

Classes

struct  IdEntry
 
struct  ObjectToIdMapContext
 This struct is used to handle id-collisions when using incremental journal. More...
 

Public Types

typedef agx::HashTable< const Serializable *, IdEntryObjectToIdMap
 
typedef agx::HashTable< StorageAgent *, agx::UInt32StorageAgentToIdMap
 
typedef agx::Event2< const Serializable *, agx::UInt32StoreEvent
 

Public Member Functions

 OutputArchive (std::ostream &outputStream)
 Create and associate an OutputArchive for writing to an open stream.
 
 OutputArchive (std::ostream &outputStream, ObjectToIdMapContext &cache)
 
virtual void addAttribute (const char *name, agx::Int32 value)
 
virtual void addAttribute (const char *name, agx::Int8 value)
 
virtual void addAttribute (const char *name, agx::UInt16 value)
 
virtual void addAttribute (const char *name, agx::UInt32 value)
 
virtual void addAttribute (const char *name, agx::UInt64 value)
 
virtual void addAttribute (const char *name, agx::UInt8 value)
 
virtual void addAttribute (const char *name, bool value)
 
virtual void addAttribute (const char *name, char value)
 
virtual void addAttribute (const char *name, const agx::Uuid &value)
 
virtual void addAttribute (const char *name, const char *value)
 
virtual void addAttribute (const char *name, double value)
 
virtual void addAttribute (const char *name, float value)
 
bool addModification (const char *str)
 Add a modification string that will be stored in the archive.
 
virtual void beginSection (const char *) override
 
void close () override
 Call flush.
 
virtual void endSection (const char *) override
 
void flush ()
 Make sure all data in buffer is written to associated stream.
 
bool getEndianMatch () const
 
int getNumObjectsSkipped () const
 
int getNumObjectsWritten () const
 
std::ostream & getStream ()
 Return a reference to the output stream.
 
bool getUseCurrentDate ()
 Return if the current date (and time) at execution time should be used when creating archive, or if the build date should be used.
 
agx::UInt32 getWriteBufferSize () const
 
bool hasModification (const agx::String &modification) const
 
void open (const std::string &appName)
 Open a new stream and write an archive header with some version information.
 
void setWriteBufferSize (agx::UInt32 bufferSize)
 Specify a new buffer size for the write buffer.
 
virtual void write (agx::Int16 val)
 
virtual void write (agx::Int32 val)
 
virtual void write (agx::Int64 val)
 
virtual void write (agx::Int8 val)
 
virtual void write (agx::UInt16 val)
 
virtual void write (agx::UInt32 val)
 
virtual void write (agx::UInt64 val)
 
virtual void write (agx::UInt8 val)
 
virtual void write (bool val)
 
virtual void write (char val)
 
void write (const agx::AffineMatrix4x4d &val)
 
void write (const agx::AffineMatrix4x4f &val)
 
void write (const agx::Matrix3x3d &val)
 
void write (const agx::Matrix3x3f &val)
 
virtual void write (const agx::Name &val)
 
void write (const agx::Quat &val)
 
void write (const agx::RangeReal &val)
 
void write (const agx::SPDMatrix3x3 &val)
 
virtual void write (const agx::String &val)
 
virtual void write (const agx::Uuid &val)
 
void write (const agx::Vec2d &val)
 
void write (const agx::Vec2f &val)
 
void write (const agx::Vec2i32 &val)
 
void write (const agx::Vec2i64 &val)
 
void write (const agx::Vec3d &val)
 
void write (const agx::Vec3f &val)
 
void write (const agx::Vec3i32 &val)
 
void write (const agx::Vec3i64 &val)
 
void write (const agx::Vec4d &val)
 
void write (const agx::Vec4f &val)
 
void write (const Serializable &serializable, StorageMode mode)
 
void write (const Serializable *serializable, StorageMode mode)
 
virtual void write (const std::string &val)
 
virtual void write (const void *buf, size_t len)
 This method will write raw data into the archive.
 
virtual void write (double val)
 
virtual void write (float val)
 
template<typename VECTOR_TYPE >
AGXCORE_EXPORT void write_vector (const agx::String &name, const VECTOR_TYPE &val)
 Write an array of data.
 
virtual void writeObjectByRef (const Serializable *obj)
 
virtual void writeObjectByVal (const Serializable &obj)
 
- Public Member Functions inherited from agxStream::Archive
 Archive ()
 
virtual void beginSection (const char *)=0
 
virtual void close ()
 
virtual void endSection (const char *)=0
 
bool getBinaryMode () const
 
bool isOpen () const
 
virtual void newAttribute ()
 Called whenever a new item is initiated.
 
void setBinaryMode (bool m)
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Static Public Member Functions

static void setUseCurrentDate (bool flag)
 Specify if the current date (and time) at execution time should be used when creating archive, or if the build date should be used.
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Public Attributes

StoreEvent storeEvent
 

Protected Member Functions

 OutputArchive ()
 
 OutputArchive (const OutputArchive &)
 
virtual ~OutputArchive ()
 Destructor.
 
OutputArchiveoperator= (const OutputArchive &)
 
virtual void writeArchiveHeader (const std::string &appName, agx::UInt8 generationVersion, agx::UInt8 majorVersion, agx::UInt8 minorVersion, agx::UInt8 patchVersion, const std::string &revision, agx::UInt16 serializationVersion)
 
void writeBitSize ()
 
virtual void writeHeaderData (agx::UInt32 magic, const std::string &appName, agx::UInt8 generationVersion, agx::UInt8 majorVersion, agx::UInt8 minorVersion, agx::UInt8 patchVersion, const std::string &revision, agx::UInt16 serializationVersion)
 
virtual void writeObjectHeader (StorageMode mode, StorageAgent *agent)
 
virtual void writeTypeHeader (StorageAgent *agent)
 
- Protected Member Functions inherited from agxStream::Archive
virtual ~Archive ()
 Destructor.
 
void open ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

ObjectToIdMapContext m_defaultCache
 
int m_numObjectsSkipped
 
int m_numObjectsWritten
 
ObjectToIdMapContextm_objectToIdMap
 
std::ostream & m_outputStream
 
StorageAgentToIdMap m_storageAgentToIdMap
 
- Protected Attributes inherited from agxStream::Archive
bool m_isOpen
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

Class for writing serialized data in binary format to a stream.

Definition at line 56 of file OutputArchive.h.

Member Typedef Documentation

◆ ObjectToIdMap

◆ StorageAgentToIdMap

Definition at line 69 of file OutputArchive.h.

◆ StoreEvent

Constructor & Destructor Documentation

◆ OutputArchive() [1/4]

agxStream::OutputArchive::OutputArchive ( std::ostream &  outputStream)

Create and associate an OutputArchive for writing to an open stream.

◆ OutputArchive() [2/4]

agxStream::OutputArchive::OutputArchive ( std::ostream &  outputStream,
ObjectToIdMapContext cache 
)

◆ OutputArchive() [3/4]

agxStream::OutputArchive::OutputArchive ( )
protected

◆ ~OutputArchive()

virtual agxStream::OutputArchive::~OutputArchive ( )
protectedvirtual

Destructor.

◆ OutputArchive() [4/4]

agxStream::OutputArchive::OutputArchive ( const OutputArchive )
protected

Member Function Documentation

◆ addAttribute() [1/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
agx::Int32  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [2/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
agx::Int8  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [3/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
agx::UInt16  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [4/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
agx::UInt32  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [5/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
agx::UInt64  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [6/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
agx::UInt8  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [7/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
bool  value 
)
virtual

◆ addAttribute() [8/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
char  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [9/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
const agx::Uuid value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [10/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
const char *  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [11/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
double  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addAttribute() [12/12]

virtual void agxStream::OutputArchive::addAttribute ( const char *  name,
float  value 
)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ addModification()

bool agxStream::OutputArchive::addModification ( const char *  str)

Add a modification string that will be stored in the archive.

This method need to be called before the open method (because thats when the header is written).

Returns
false if modification already exists

◆ beginSection()

virtual void agxStream::OutputArchive::beginSection ( const char *  )
inlineoverridevirtual

Implements agxStream::Archive.

Reimplemented in agxStream::XMLOutputArchive.

Definition at line 200 of file OutputArchive.h.

Referenced by agxStream::StoreObjects< T >::~StoreObjects().

◆ close()

void agxStream::OutputArchive::close ( )
overridevirtual

Call flush.

Reimplemented from agxStream::Archive.

Reimplemented in agxStream::XMLOutputArchive.

◆ endSection()

virtual void agxStream::OutputArchive::endSection ( const char *  )
inlineoverridevirtual

Implements agxStream::Archive.

Reimplemented in agxStream::XMLOutputArchive.

Definition at line 201 of file OutputArchive.h.

Referenced by agxStream::StoreObjects< T >::~StoreObjects().

◆ flush()

void agxStream::OutputArchive::flush ( )

Make sure all data in buffer is written to associated stream.

◆ getEndianMatch()

bool agxStream::OutputArchive::getEndianMatch ( ) const
inline

Definition at line 196 of file OutputArchive.h.

◆ getNumObjectsSkipped()

int agxStream::OutputArchive::getNumObjectsSkipped ( ) const
inline
Returns
number of objects skipped in writing due to that they have setEnableSerialization(false)

Definition at line 109 of file OutputArchive.h.

◆ getNumObjectsWritten()

int agxStream::OutputArchive::getNumObjectsWritten ( ) const
inline
Returns
number of objects stored so far

Definition at line 102 of file OutputArchive.h.

◆ getStream()

std::ostream & agxStream::OutputArchive::getStream ( )
inline

Return a reference to the output stream.

Definition at line 92 of file OutputArchive.h.

◆ getUseCurrentDate()

bool agxStream::OutputArchive::getUseCurrentDate ( )

Return if the current date (and time) at execution time should be used when creating archive, or if the build date should be used.

◆ getWriteBufferSize()

agx::UInt32 agxStream::OutputArchive::getWriteBufferSize ( ) const
Returns
current write buffer

◆ hasModification()

bool agxStream::OutputArchive::hasModification ( const agx::String modification) const
Returns
true if this archive has the specified modification hash

◆ open()

void agxStream::OutputArchive::open ( const std::string &  appName)

Open a new stream and write an archive header with some version information.

◆ operator=()

OutputArchive & agxStream::OutputArchive::operator= ( const OutputArchive )
protected

◆ setUseCurrentDate()

static void agxStream::OutputArchive::setUseCurrentDate ( bool  flag)
static

Specify if the current date (and time) at execution time should be used when creating archive, or if the build date should be used.

Default is enabled.

◆ setWriteBufferSize()

void agxStream::OutputArchive::setWriteBufferSize ( agx::UInt32  bufferSize)

Specify a new buffer size for the write buffer.

Default = 8192 bytes A call to this method will flush the buffer to the stream if bufferSize is less than the current size

◆ write() [1/36]

virtual void agxStream::OutputArchive::write ( agx::Int16  val)
virtual

◆ write() [2/36]

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

◆ write() [3/36]

virtual void agxStream::OutputArchive::write ( agx::Int64  val)
virtual

◆ write() [4/36]

virtual void agxStream::OutputArchive::write ( agx::Int8  val)
virtual

◆ write() [5/36]

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

◆ write() [6/36]

virtual void agxStream::OutputArchive::write ( agx::UInt32  val)
virtual

◆ write() [7/36]

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

◆ write() [8/36]

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

◆ write() [9/36]

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

◆ write() [10/36]

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

◆ write() [11/36]

void agxStream::OutputArchive::write ( const agx::AffineMatrix4x4d val)

◆ write() [12/36]

void agxStream::OutputArchive::write ( const agx::AffineMatrix4x4f val)

◆ write() [13/36]

void agxStream::OutputArchive::write ( const agx::Matrix3x3d val)

◆ write() [14/36]

void agxStream::OutputArchive::write ( const agx::Matrix3x3f val)

◆ write() [15/36]

virtual void agxStream::OutputArchive::write ( const agx::Name val)
inlinevirtual

Reimplemented in agxStream::XMLOutputArchive.

Definition at line 148 of file OutputArchive.h.

References agxStream::write().

◆ write() [16/36]

void agxStream::OutputArchive::write ( const agx::Quat val)

◆ write() [17/36]

void agxStream::OutputArchive::write ( const agx::RangeReal val)

◆ write() [18/36]

void agxStream::OutputArchive::write ( const agx::SPDMatrix3x3 val)

◆ write() [19/36]

virtual void agxStream::OutputArchive::write ( const agx::String val)
virtual

Reimplemented in agxStream::XMLOutputArchive.

◆ write() [20/36]

virtual void agxStream::OutputArchive::write ( const agx::Uuid val)
virtual

◆ write() [21/36]

void agxStream::OutputArchive::write ( const agx::Vec2d val)

◆ write() [22/36]

void agxStream::OutputArchive::write ( const agx::Vec2f val)

◆ write() [23/36]

void agxStream::OutputArchive::write ( const agx::Vec2i32 val)

◆ write() [24/36]

void agxStream::OutputArchive::write ( const agx::Vec2i64 val)

◆ write() [25/36]

void agxStream::OutputArchive::write ( const agx::Vec3d val)

◆ write() [26/36]

void agxStream::OutputArchive::write ( const agx::Vec3f val)

◆ write() [27/36]

void agxStream::OutputArchive::write ( const agx::Vec3i32 val)

◆ write() [28/36]

void agxStream::OutputArchive::write ( const agx::Vec3i64 val)

◆ write() [29/36]

void agxStream::OutputArchive::write ( const agx::Vec4d val)

◆ write() [30/36]

void agxStream::OutputArchive::write ( const agx::Vec4f val)

◆ write() [31/36]

void agxStream::OutputArchive::write ( const Serializable serializable,
StorageMode  mode 
)

◆ write() [32/36]

void agxStream::OutputArchive::write ( const Serializable serializable,
StorageMode  mode 
)

◆ write() [33/36]

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

◆ write() [34/36]

virtual void agxStream::OutputArchive::write ( const void *  buf,
size_t  len 
)
virtual

This method will write raw data into the archive.

Notice that you should always have called beginSection() prior to calling this method. Otherwise it is not compatible with XML output.

Parameters
buf- Pointer to the data to be written
len- Number of bytes to write

Reimplemented in agxStream::XMLOutputArchive, and agxStream::XMLOutputArchive.

◆ write() [35/36]

virtual void agxStream::OutputArchive::write ( double  val)
virtual

◆ write() [36/36]

virtual void agxStream::OutputArchive::write ( float  val)
virtual

◆ write_vector()

template<typename VECTOR_TYPE >
AGXCORE_EXPORT void agxStream::OutputArchive::write_vector ( const agx::String name,
const VECTOR_TYPE &  val 
)

Write an array of data.

Only works for agx::VectorPOD<> types.

Parameters
name- name of the vector data
val- The array data to be written.

◆ writeArchiveHeader()

virtual void agxStream::OutputArchive::writeArchiveHeader ( const std::string &  appName,
agx::UInt8  generationVersion,
agx::UInt8  majorVersion,
agx::UInt8  minorVersion,
agx::UInt8  patchVersion,
const std::string &  revision,
agx::UInt16  serializationVersion 
)
protectedvirtual

◆ writeBitSize()

void agxStream::OutputArchive::writeBitSize ( )
protected

◆ writeHeaderData()

virtual void agxStream::OutputArchive::writeHeaderData ( agx::UInt32  magic,
const std::string &  appName,
agx::UInt8  generationVersion,
agx::UInt8  majorVersion,
agx::UInt8  minorVersion,
agx::UInt8  patchVersion,
const std::string &  revision,
agx::UInt16  serializationVersion 
)
protectedvirtual

◆ writeObjectByRef()

virtual void agxStream::OutputArchive::writeObjectByRef ( const Serializable obj)
virtual

◆ writeObjectByVal()

virtual void agxStream::OutputArchive::writeObjectByVal ( const Serializable obj)
virtual

◆ writeObjectHeader()

virtual void agxStream::OutputArchive::writeObjectHeader ( StorageMode  mode,
StorageAgent *  agent 
)
protectedvirtual

◆ writeTypeHeader()

virtual void agxStream::OutputArchive::writeTypeHeader ( StorageAgent *  agent)
protectedvirtual

Member Data Documentation

◆ m_defaultCache

ObjectToIdMapContext agxStream::OutputArchive::m_defaultCache
protected

Definition at line 286 of file OutputArchive.h.

◆ m_numObjectsSkipped

int agxStream::OutputArchive::m_numObjectsSkipped
protected

Definition at line 292 of file OutputArchive.h.

◆ m_numObjectsWritten

int agxStream::OutputArchive::m_numObjectsWritten
protected

Definition at line 291 of file OutputArchive.h.

◆ m_objectToIdMap

ObjectToIdMapContext& agxStream::OutputArchive::m_objectToIdMap
protected

Definition at line 287 of file OutputArchive.h.

◆ m_outputStream

std::ostream& agxStream::OutputArchive::m_outputStream
protected

Definition at line 285 of file OutputArchive.h.

◆ m_storageAgentToIdMap

StorageAgentToIdMap agxStream::OutputArchive::m_storageAgentToIdMap
protected

Definition at line 288 of file OutputArchive.h.

◆ storeEvent

StoreEvent agxStream::OutputArchive::storeEvent

Definition at line 60 of file OutputArchive.h.


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