Overte C++ Documentation
render::Transaction Class Reference

Transaction is the mechanism to make any change to the scene. Whenever a new item need to be reset, or when an item changes its position or its size, or when an item's payload has to be updated with new states (coming from outside the scene knowledge), or when an item is destroyed, these changes must be expressed through the corresponding command from the Transaction. The Transaction is then queued on the Scene so all the pending transactions can be consolidated and processed at the time of updating the scene before it s rendered. More...

#include <Scene.h>

Public Member Functions

void resetItem (ItemID id, const PayloadPointer &payload)
 The transaction will replace item's payload with new one. More...
 
void removeItem (ItemID id)
 The transaction will remove given item. More...
 
bool hasRemovedItems () const
 
template<class T >
void updateItem (ItemID id, std::function< void(T &)> func)
 The transaction will execute a function on the render thread to update the given render item. More...
 
void updateItem (ItemID id)
 The transaction will update an item without running a function. More...
 
void resetTransitionOnItem (ItemID id, TransitionType transition, ItemID boundId=render::Item::INVALID_ITEM_ID)
 The transaction will start a new fade effect on a given item. More...
 
void removeTransitionFromItem (ItemID id)
 The transaction will remove fade effect for a given item. More...
 
void setTransitionFinishedOperator (ItemID id, TransitionFinishedFunc func)
 The transaction will add a function to be called when fade effect finishes for a given item. More...
 
void queryTransitionOnItem (ItemID id, TransitionQueryFunc func)
 The transaction will add a function to be called on the render thread that will be provided with current state of the transition. More...
 
void resetSelection (const Selection &selection)
 The transaction will replace selection with a given name with the new one. More...
 
void resetSelectionHighlight (const std::string &selectionName, const HighlightStyle &style=HighlightStyle())
 The transaction will set a highlight style for a selection with a given name. More...
 
void removeHighlightFromSelection (const std::string &selectionName)
 The transaction will remove highlight from a selection with specified name. More...
 
void querySelectionHighlight (const std::string &selectionName, const SelectionHighlightQueryFunc &func)
 The transaction will add a function to be called on the render thread that will be provided with current highlight style for a given selection. More...
 
void reserve (const std::vector< Transaction > &transactionContainer)
 Reserves space needed to fit content of provided transactions. More...
 
void mergeByCopying (const std::vector< Transaction > &transactionContainer)
 Adds content of given transactions to the current one. More...
 
void mergeByMoving (std::vector< Transaction > &&transactionContainer)
 Moves content of given transactions to the current one and then clears input vector. More...
 
void mergeByCopying (const Transaction &transaction)
 Adds content of given transactions to the current one. More...
 
void mergeByMoving (Transaction &&transaction)
 Moves content of given transactions to the current one and then clears input vector. More...
 
void clear ()
 Clears the content of this transaction.
 

Detailed Description

Transaction is the mechanism to make any change to the scene. Whenever a new item need to be reset, or when an item changes its position or its size, or when an item's payload has to be updated with new states (coming from outside the scene knowledge), or when an item is destroyed, these changes must be expressed through the corresponding command from the Transaction. The Transaction is then queued on the Scene so all the pending transactions can be consolidated and processed at the time of updating the scene before it s rendered.

/

Member Function Documentation

◆ hasRemovedItems()

bool render::Transaction::hasRemovedItems ( ) const
inline
Returns
true if a given transaction removes items.

◆ mergeByCopying() [1/2]

void Transaction::mergeByCopying ( const std::vector< Transaction > &  transactionContainer)

Adds content of given transactions to the current one.

If the current transaction is empty, then proper amount of space for the content of new transactions will be reserved. Otherwise, performance may suffer due to reallocation.

Parameters
transactionContainerTransactions from which content will be added.

◆ mergeByCopying() [2/2]

void Transaction::mergeByCopying ( const Transaction &  transaction)

Adds content of given transactions to the current one.

Parameters
transactionTransaction from which contents will be copied.

◆ mergeByMoving() [1/2]

void Transaction::mergeByMoving ( std::vector< Transaction > &&  transactionContainer)

Moves content of given transactions to the current one and then clears input vector.

If the current transaction is empty, then proper amount of space for the content of new transactions will be reserved. Otherwise, performance may suffer due to reallocation.

Parameters
transactionContainerTransactions from which content will be moved. This gets cleared after content is moved.

◆ mergeByMoving() [2/2]

void Transaction::mergeByMoving ( Transaction &&  transaction)

Moves content of given transactions to the current one and then clears input vector.

Parameters
transactionTransaction from which contents will be moved.

◆ querySelectionHighlight()

void Transaction::querySelectionHighlight ( const std::string &  selectionName,
const SelectionHighlightQueryFunc &  func 
)

The transaction will add a function to be called on the render thread that will be provided with current highlight style for a given selection.

Parameters
selectionNameUnique name of the selection.
funcFunction to be called.

◆ queryTransitionOnItem()

void Transaction::queryTransitionOnItem ( ItemID  id,
TransitionQueryFunc  func 
)

The transaction will add a function to be called on the render thread that will be provided with current state of the transition.

Parameters
idItem ID.
funcFunction to be called.

◆ removeHighlightFromSelection()

void Transaction::removeHighlightFromSelection ( const std::string &  selectionName)

The transaction will remove highlight from a selection with specified name.

Parameters
selectionNameUnique name of the selection.

◆ removeItem()

void Transaction::removeItem ( ItemID  id)

The transaction will remove given item.

Parameters
idItem ID.

◆ removeTransitionFromItem()

void Transaction::removeTransitionFromItem ( ItemID  id)

The transaction will remove fade effect for a given item.

If it was set, a transition finished operator will be called on the render thread when removal happens.

Parameters
idItem ID.

◆ reserve()

void Transaction::reserve ( const std::vector< Transaction > &  transactionContainer)

Reserves space needed to fit content of provided transactions.

WARNING: this assumes that this transaction is empty at the time of reserve() call. If the transaction is not empty, existing content will not be taken into account, so relying on this will cause performance issues due to vector reallocation.

Parameters
transactionContainerVector containing transactions for which space needs to be reserved.

◆ resetItem()

void Transaction::resetItem ( ItemID  id,
const PayloadPointer &  payload 
)

The transaction will replace item's payload with new one.

Parameters
idItem ID.
payloadShared pointer to the new payload.

◆ resetSelection()

void Transaction::resetSelection ( const Selection &  selection)

The transaction will replace selection with a given name with the new one.

Parameters
selectionObject containing selection name and list of item ids.

◆ resetSelectionHighlight()

void Transaction::resetSelectionHighlight ( const std::string &  selectionName,
const HighlightStyle &  style = HighlightStyle() 
)

The transaction will set a highlight style for a selection with a given name.

Parameters
selectionNameUnique name of the selection.
styleObject containing style properties.

◆ resetTransitionOnItem()

void Transaction::resetTransitionOnItem ( ItemID  id,
TransitionType  transition,
ItemID  boundId = render::Item::INVALID_ITEM_ID 
)

The transaction will start a new fade effect on a given item.

If given item already has a fade effect going, it will be replaced with the new one.

Parameters
idItem ID.
transitionType of the transition that should be started.
boundIdIf it's specified, dimensions for the fade effect will be taken from this item.

◆ setTransitionFinishedOperator()

void Transaction::setTransitionFinishedOperator ( ItemID  id,
TransitionFinishedFunc  func 
)

The transaction will add a function to be called when fade effect finishes for a given item.

Previous transition finished operators for the given item are not removed by this call, and all of them are called on the render thread when fade effect finishes.

Parameters
idItem ID.
funcFunction to be called.

◆ updateItem() [1/2]

void render::Transaction::updateItem ( ItemID  id)
inline

The transaction will update an item without running a function.

Spatial properties and key of an item will be updated on render thread.

Parameters
idItem ID.

◆ updateItem() [2/2]

template<class T >
void render::Transaction::updateItem ( ItemID  id,
std::function< void(T &)>  func 
)
inline

The transaction will execute a function on the render thread to update the given render item.

Spatial properties and key of an item are also updated.

Template Parameters
TType of the render item to update.
Parameters
idItem ID.
funcFunction that will perform the update.

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