AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agx::Journal Class Reference

#include <Journal.h>

+ Inheritance diagram for agx::Journal:

Classes

struct  SessionHeader
 

Public Types

enum  ArchiveFormat { AUTO, HDF5, CUSTOM }
 
typedef agx::Callback2
< Journal *, std::exception & > 
ExceptionHandler
 
enum  Mode { INVALID = -1, RECORD, PLAYBACK }
 
typedef agx::Event1< UInt > ProgressEvent
 
typedef Callback2
< agxSDK::Assembly *, bool > 
RenderLoaderCallback
 
typedef Callback1< const
agx::String & > 
SceneLoaderCallback
 A callback that will be called when starting playback from a recording. More...
 
typedef agx::Event1
< SessionHeader > 
SessionEvent
 

Public Member Functions

 Journal (const String &diskPath="Journal.agxJournal", ArchiveFormat archiveFormat=AUTO, bool loadPlotFromJournal=true, bool readOnlyIfExists=false)
 
void addDataBinding (const agx::Path &path, bool recursive=false)
 Add a data binding to the journal, eg Particle.position will register the buffer to be stored/restored by journal. More...
 
void addDataBinding (const agx::Object *object, bool recursive=false)
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
void attach (agxSDK::Simulation *simulation, Mode mode, agxData::Track *frameCache=nullptr, bool passive=false)
 Attach the journal to a simulation. More...
 
void clearDataBindings ()
 Remove all data bindings. More...
 
 Converter ()
 
agxData::JournalArchive::Session * createNewSession ()
 Create a new session within the current Journal archive. More...
 
agxData::JournalArchive::Session * createNewSession (const Name &name)
 
void detach ()
 Detach from the currently attached simulation. More...
 
void execute ()
 
void extractScene (const agx::String &sessionName)
 
agxData::JournalArchive::Session * findNewestSession ()
 
void flush (bool force=false)
 Flush the journal. More...
 
ArchiveFormat getArchiveFormat () const
 
agxData::JournalArchive::Session * getCurrentSession ()
 
const String & getDiskPath () const
 Set the disk path. More...
 
bool getEnableIncrementalStructure () const
 
agx::Real getEndTime () const
 
const ExceptionHandler & getExceptionHandler () const
 
agx::Bool getExpand () const
 
agxData::JournalArchive * getFileJournal () const
 
agxData::DiskFrameReader * getFileReader ()
 
const agxData::DiskFrameReader * getFileReader () const
 
agxData::DiskFrameWriter * getFileWriter ()
 
const agxData::DiskFrameWriter * getFileWriter () const
 
agx::UInt getFrameStride () const
 
Mode getMode () const
 
const Name & getName () const
 
int getReferenceCount () const
 
RenderLoaderCallback getRenderLoader ()
 
bool getSaveSceneToDisk () const
 
agx::UInt16 getSerializationVersion () const
 Find what serialization version a Journal was stored with. More...
 
agxData::JournalArchive::Session * getSession (const agx::Name &name)
 
const
agxData::JournalArchive::SessionTable & 
getSessions () const
 
agxSDK::Simulation * getSimulation ()
 
const agxSDK::Simulation * getSimulation () const
 
agxSDK::SimulationFrameReader * getSimulationReader ()
 
const
agxSDK::SimulationFrameReader * 
getSimulationReader () const
 
agxSDK::SimulationFrameWriter * getSimulationWriter ()
 
const
agxSDK::SimulationFrameWriter * 
getSimulationWriter () const
 
const agx::String & getSourcePath () const
 
agx::Real getStartTime () const
 
ArchiveFormat getTargetFormat () const
 
const agx::String & getTargetPath () const
 
agxData::Track * getTrack ()
 
const agxData::Track * getTrack () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isJumping () const
 
bool jumpToFrame (agx::UInt frameIndex)
 Jump to a specified frame during playback. More...
 
bool jumpToTime (agx::Real time)
 Jump to a specified time during playback. More...
 
bool loadConfiguration (const String &configurationFilePath)
 Load data bindings from a configuration file. More...
 
agxData::JournalArchive::Session * loadNewestSession ()
 Load the most recent session. More...
 
agxData::FrameRef readFrameAtTime (agx::Real time)
 Explicitly read a frame from the journal. More...
 
agxData::FrameRef readFrameWithIndex (agx::UInt index)
 Explicitly read a frame from the journal. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
bool removeDataBinding (const agx::Path &path)
 Remove a data binding from the journal. More...
 
bool removeDataBinding (const agx::Object *object)
 
bool removeSession (const agx::Name &sessionName)
 Remove a session from the journal. More...
 
bool renameCurrentSession (const agx::String &newName)
 Change the name of the current session. More...
 
bool sanityCheck (const agxSDK::Simulation *simulation, agxData::JournalArchive::Session *session) const
 
void saveScene ()
 Save the scene state, normally done automatically. More...
 
agxData::JournalArchive::Session * setCurrentSession (const agx::Name &sessionName, bool saveSceneOnNextPreTick=true)
 Change the active session to the session with the given name. More...
 
void setCurrentSession (agxData::JournalArchive::Session *session, bool saveSceneOnNextPreTick=true)
 Change the active session to the given session. More...
 
void setEnableIncrementalStructure (bool flag)
 Enable/disable incremental simulation structure recording. More...
 
void setEndTime (agx::Real endTime)
 
void setExceptionHandler (const ExceptionHandler &handler)
 Specify an exception handler. More...
 
void setExpand (agx::Bool expand)
 
void setFrameStride (agx::UInt stride)
 
void setMode (Mode mode)
 Set the journal mode, RECORD or PLAYBACK. More...
 
void setRenderLoader (RenderLoaderCallback loader)
 
void setSaveSceneToDisk (bool flag)
 Specifies if the simulation serialization should be temporary stored to disk or to memory when creating the journal. More...
 
void setSceneLoader (SceneLoaderCallback loader)
 
void setSourcePath (const agx::String &path)
 
void setStartTime (agx::Real startTime)
 
void setTargetFormat (ArchiveFormat format)
 
void setTargetPath (const agx::String &path)
 
void startRecordingAtTime (agx::Real time)
 Specify time stamp when journal recording should begin. More...
 
void triggerFrame ()
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

static void convert (const String &targetPath, const String &sourcePath, ArchiveFormat targetFormat, bool expand=false)
 Convert journal from one format to another. More...
 
static bool findNewestSession (const agx::String &diskPath, agx::JournalRef &journal, agxData::JournalArchive::SessionRef &session)
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Public Attributes

ProgressEvent progressEvent
 
SessionEvent sessionEndEvent
 
SessionEvent sessionStartEvent
 

Protected Member Functions

virtual ~Journal ()
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Definition at line 45 of file Journal.h.

Member Typedef Documentation

Definition at line 64 of file Journal.h.

Definition at line 403 of file Journal.h.

Definition at line 287 of file Journal.h.

A callback that will be called when starting playback from a recording.

Definition at line 284 of file Journal.h.

Definition at line 406 of file Journal.h.

Member Enumeration Documentation

Enumerator
AUTO 
HDF5 
CUSTOM 

AGX has to be built with HDF5-support to use this.

Definition at line 56 of file Journal.h.

Enumerator
INVALID 
RECORD 
PLAYBACK 

Definition at line 49 of file Journal.h.

Constructor & Destructor Documentation

agx::Journal::Journal ( const String &  diskPath = "Journal.agxJournal",
ArchiveFormat  archiveFormat = AUTO,
bool  loadPlotFromJournal = true,
bool  readOnlyIfExists = false 
)
virtual agx::Journal::~Journal ( )
protectedvirtual

Member Function Documentation

void agx::Journal::addDataBinding ( const agx::Path &  path,
bool  recursive = false 
)

Add a data binding to the journal, eg Particle.position will register the buffer to be stored/restored by journal.

void agx::Journal::addDataBinding ( const agx::Object *  object,
bool  recursive = false 
)
void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agx::Journal::attach ( agxSDK::Simulation *  simulation,
Mode  mode,
agxData::Track *  frameCache = nullptr,
bool  passive = false 
)

Attach the journal to a simulation.

Parameters
simulationThe simulation
modeRECORD or PLAYBACK
frameCacheAn existing track to load cached frames from
passiveTrue if simulation should not be made aware of this journal, must be true if more than one journal is attached
void agx::Journal::clearDataBindings ( )

Remove all data bindings.

static void agx::Journal::convert ( const String &  targetPath,
const String &  sourcePath,
ArchiveFormat  targetFormat,
bool  expand = false 
)
static

Convert journal from one format to another.

agx::Journal::Converter ( )
agxData::JournalArchive::Session* agx::Journal::createNewSession ( )

Create a new session within the current Journal archive.

Will make the newly created session the active session.

agxData::JournalArchive::Session* agx::Journal::createNewSession ( const Name &  name)
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
void agx::Journal::detach ( )

Detach from the currently attached simulation.

void agx::Journal::execute ( )
void agx::Journal::extractScene ( const agx::String &  sessionName)
agxData::JournalArchive::Session* agx::Journal::findNewestSession ( )
Returns
The most recent session
static bool agx::Journal::findNewestSession ( const agx::String &  diskPath,
agx::JournalRef &  journal,
agxData::JournalArchive::SessionRef &  session 
)
static
Returns
The name of the sessions with the highest date in its header. The empty string is returned if there are no sessions in the journal.
void agx::Journal::flush ( bool  force = false)

Flush the journal.

Parameters
forceDoes not wait for output thread to completed if true.
ArchiveFormat agx::Journal::getArchiveFormat ( ) const
Returns
The journal archive format.
agxData::JournalArchive::Session * agx::Journal::getCurrentSession ( )

Definition at line 463 of file Journal.h.

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
const String & agx::Journal::getDiskPath ( ) const

Set the disk path.

Returns
The disk path to the archive where the journal data is located.

Definition at line 458 of file Journal.h.

bool agx::Journal::getEnableIncrementalStructure ( ) const
Returns
True if incremental structure recording is enabled.
agx::Real agx::Journal::getEndTime ( ) const
const ExceptionHandler& agx::Journal::getExceptionHandler ( ) const
Returns
The current exception handler.
agx::Bool agx::Journal::getExpand ( ) const
agxData::JournalArchive* agx::Journal::getFileJournal ( ) const
Returns
The JournalArchive that frames are being read from or written to.
agxData::DiskFrameReader * agx::Journal::getFileReader ( )

Definition at line 469 of file Journal.h.

const agxData::DiskFrameReader * agx::Journal::getFileReader ( ) const

Definition at line 476 of file Journal.h.

agxData::DiskFrameWriter * agx::Journal::getFileWriter ( )

Definition at line 470 of file Journal.h.

const agxData::DiskFrameWriter * agx::Journal::getFileWriter ( ) const

Definition at line 477 of file Journal.h.

agx::UInt agx::Journal::getFrameStride ( ) const
Journal::Mode agx::Journal::getMode ( ) const
Returns
The current journal mode.

Definition at line 459 of file Journal.h.

const Name & agx::Journal::getName ( ) const
Returns
The name of the journal.

Definition at line 457 of file Journal.h.

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
RenderLoaderCallback agx::Journal::getRenderLoader ( )
bool agx::Journal::getSaveSceneToDisk ( ) const
Returns
true if simulation scene will be temporarily stored to disk when writing a journal.
agx::UInt16 agx::Journal::getSerializationVersion ( ) const

Find what serialization version a Journal was stored with.

agxData::JournalArchive::Session* agx::Journal::getSession ( const agx::Name &  name)
Returns
The session within the JournalArchive that frames are being read from or written to.
const agxData::JournalArchive::SessionTable& agx::Journal::getSessions ( ) const
Returns
All sessions in the journal archive.
agxSDK::Simulation * agx::Journal::getSimulation ( )
Returns
the attached simulation

Definition at line 460 of file Journal.h.

const agxSDK::Simulation * agx::Journal::getSimulation ( ) const
Returns
the attached simulation

Definition at line 461 of file Journal.h.

agxSDK::SimulationFrameReader * agx::Journal::getSimulationReader ( )

Definition at line 466 of file Journal.h.

const agxSDK::SimulationFrameReader * agx::Journal::getSimulationReader ( ) const

Definition at line 473 of file Journal.h.

agxSDK::SimulationFrameWriter * agx::Journal::getSimulationWriter ( )

Definition at line 467 of file Journal.h.

const agxSDK::SimulationFrameWriter * agx::Journal::getSimulationWriter ( ) const

Definition at line 474 of file Journal.h.

const agx::String& agx::Journal::getSourcePath ( ) const
agx::Real agx::Journal::getStartTime ( ) const
ArchiveFormat agx::Journal::getTargetFormat ( ) const
const agx::String& agx::Journal::getTargetPath ( ) const
agxData::Track * agx::Journal::getTrack ( )

Definition at line 465 of file Journal.h.

const agxData::Track * agx::Journal::getTrack ( ) const

Definition at line 472 of file Journal.h.

template<typename T >
bool agx::Referenced::is ( ) const
inherited
bool agx::Journal::isJumping ( ) const
Returns
True if a jump is in progress.
bool agx::Journal::jumpToFrame ( agx::UInt  frameIndex)

Jump to a specified frame during playback.

Returns
True if successful
bool agx::Journal::jumpToTime ( agx::Real  time)

Jump to a specified time during playback.

Returns
True if successful
bool agx::Journal::loadConfiguration ( const String &  configurationFilePath)

Load data bindings from a configuration file.

Returns
true for successful load, otherwise false
agxData::JournalArchive::Session* agx::Journal::loadNewestSession ( )

Load the most recent session.

Returns
nullptr if journal does not exist or does not contain any sessions.
agxData::FrameRef agx::Journal::readFrameAtTime ( agx::Real  time)

Explicitly read a frame from the journal.

Parameters
timeThe point in time
agxData::FrameRef agx::Journal::readFrameWithIndex ( agx::UInt  index)

Explicitly read a frame from the journal.

Parameters
indexThe frame index
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

bool agx::Journal::removeDataBinding ( const agx::Path &  path)

Remove a data binding from the journal.

bool agx::Journal::removeDataBinding ( const agx::Object *  object)
bool agx::Journal::removeSession ( const agx::Name &  sessionName)

Remove a session from the journal.

bool agx::Journal::renameCurrentSession ( const agx::String &  newName)

Change the name of the current session.

bool agx::Journal::sanityCheck ( const agxSDK::Simulation *  simulation,
agxData::JournalArchive::Session *  session 
) const
void agx::Journal::saveScene ( )

Save the scene state, normally done automatically.

agxData::JournalArchive::Session* agx::Journal::setCurrentSession ( const agx::Name &  sessionName,
bool  saveSceneOnNextPreTick = true 
)

Change the active session to the session with the given name.

The session must be part of the current JournalArchive. Will return nullptr if it it didn't exist

void agx::Journal::setCurrentSession ( agxData::JournalArchive::Session *  session,
bool  saveSceneOnNextPreTick = true 
)

Change the active session to the given session.

The session must be part of the current JournalArchive.

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agx::Journal::setEnableIncrementalStructure ( bool  flag)

Enable/disable incremental simulation structure recording.

Enabled by default.

void agx::Journal::setEndTime ( agx::Real  endTime)
void agx::Journal::setExceptionHandler ( const ExceptionHandler &  handler)

Specify an exception handler.

void agx::Journal::setExpand ( agx::Bool  expand)
void agx::Journal::setFrameStride ( agx::UInt  stride)
void agx::Journal::setMode ( Mode  mode)

Set the journal mode, RECORD or PLAYBACK.

void agx::Journal::setRenderLoader ( RenderLoaderCallback  loader)
void agx::Journal::setSaveSceneToDisk ( bool  flag)

Specifies if the simulation serialization should be temporary stored to disk or to memory when creating the journal.

Storing to memory is default. But this might cause problem, as a large continuous memory need to be allocated. For 32bit applications, it might be problematic to allocate 100Mb or more continuous memory, hence storing to disk might be better. And slower.

DEFAULT: store to memory (false)

Parameters
flag- if true, scene will be stored to disk, otherwise to memory before written to journal.
void agx::Journal::setSceneLoader ( SceneLoaderCallback  loader)
void agx::Journal::setSourcePath ( const agx::String &  path)
void agx::Journal::setStartTime ( agx::Real  startTime)
void agx::Journal::setTargetFormat ( ArchiveFormat  format)
void agx::Journal::setTargetPath ( const agx::String &  path)
void agx::Journal::startRecordingAtTime ( agx::Real  time)

Specify time stamp when journal recording should begin.

void agx::Journal::triggerFrame ( )
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

ProgressEvent agx::Journal::progressEvent

Definition at line 404 of file Journal.h.

SessionEvent agx::Journal::sessionEndEvent

Definition at line 408 of file Journal.h.

SessionEvent agx::Journal::sessionStartEvent

Definition at line 407 of file Journal.h.


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