FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
FotoSHOCKcore::GraphNode Class Reference

Class representing a node of a GraphManager. More...

#include <GraphNode.hpp>

Public Member Functions

 ~GraphNode ()
 A destructor. More...
 
MipMapgetMipMap ()
 Return the mipmap associated with the node. More...
 
ImageBufferBasegetBuffer (const int mipmapLevel=0)
 Return the buffer associated with the node. More...
 
void saveBuffer (IO::SaveInfo info)
 Save the buffer associated with the node. More...
 
const float getElapsedTime () const
 Return the time consumed to run the operation in the node. More...
 
const unsigned int id () const
 Node identifier. More...
 
void recalculate ()
 Relculate the operation in the node. More...
 
void confirmOperation ()
 Confirm that the operation should be considered as fully set up. More...
 
void enabled (bool enable)
 Changes the "enabled" state. More...
 
bool tryEnable ()
 Tries to enable node and all following nodes. More...
 
const bool enabled () const
 Returns whether the operation is enabled. More...
 
ImageOperationoperation () const
 Return the ImageOperation associated with the GraphNode. More...
 
ImageOperationDescriptoroperationDescriptor () const
 Return the descriptor of the ImageOperation associated with the GraphNode. More...
 
boost::shared_ptr< UpdateInfoaddROI (UpdateInfo updInfo)
 Add a new region of interest to the node. More...
 
boost::shared_ptr< UpdateInfoaddROI (ROIinfo ROI)
 
boost::shared_ptr< UpdateInfoaddROI (unsigned int x, unsigned int y, unsigned int sizeX, unsigned int sizeY, const int mipmapLevel)
 
void deleteROI (boost::shared_ptr< UpdateInfo > ROI)
 Delete specified ROI from all nodes. More...
 
const std::vector< GraphNode * > & parents () const
 Read-only access to parent GraphNodes. More...
 
const std::vector< GraphNode * > & children () const
 Read-only access to children GraphNodes. More...
 

Protected Member Functions

 GraphNode (unsigned int id, GraphManager *manager, ImageOperationDescriptor *operationDescr)
 Construct a new GraphNode. More...
 
bool checkInputs ()
 Check whether the operation can be enabled and try to enable it. More...
 

Friends

class GraphManager
 
class Graph_private
 
class UpdateInfo
 
class RootLoadImage
 
class RootCreateImage
 

Detailed Description

Class representing a node of a GraphManager.

GraphNode is one of the most important classes in FotoSHOCK. The GraphNode class provides an interface for controlling image operations.

The functions provided by the GraphNode class include functions for accessing the processed image, such as getMipMap() and getBuffer(), the recalculate() function to forcing the operation to run and others.

If the operation is run, the GraphManager, that is managing the graph containing the node, ensures that previous operations get executed if necessary.

Most of the operations handled by the GraphNode are applied only to a selected area of an image. However, the processed area may be larger than the requested region, depending on the operation. Most of the operations recalculates whole tiles For such operations, the processed area always covers whole number of tiles.

To inform the GraphNode object which region needs to be updated, a new ROI (region of interest) has to be added using one of the addROI() functions. When a new ROI is added, the operation is automatically executed. The ROI may be changed later by changing the ROI in boost::shared_ptr<UpdateInfo> returned by the addROI() funtions and calling UpdateInfo::update().

Examples:
graph/example.cpp.

Constructor & Destructor Documentation

FotoSHOCKcore::GraphNode::~GraphNode ( )

A destructor.

The destructor frees the memory allocated to store an ImageOperation, mask and buffer if possible.

The buffer is freed only if the GraphNode owns the buffer (m_cache = true). It's still necessary to check that other GraphNodes in the GraphManager doesn't point to the destructed buffer.

FotoSHOCKcore::GraphNode::GraphNode ( unsigned int  id,
GraphManager manager,
ImageOperationDescriptor operationDescr 
)
protected

Construct a new GraphNode.

Construct a GraphNode which is contained in the given GraphManager.

Parameters
idoperation identifier
managerthe GraphManager which contains this GraphNode
operationDescrdescriptor of the operation. IMPORTANT: the descriptor is not freed automatically.

Member Function Documentation

boost::shared_ptr< UpdateInfo > FotoSHOCKcore::GraphNode::addROI ( UpdateInfo  updInfo)

Add a new region of interest to the node.

Add a new region of interest to the node. The region is propagated through the graph to all GraphNodes which calling node depends on, so the node has valid input data.

Parameters
ROIregion of interest
Returns
shared_ptr to the newly created UpdateInfo

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Examples:
graph/example.cpp.
bool FotoSHOCKcore::GraphNode::checkInputs ( )
protected

Check whether the operation can be enabled and try to enable it.

If this function is called on already enabled operation, it checks whether the operation is valid. The invalid operation is disabled.

Returns
true if operation was enabled
const std::vector< GraphNode * > & FotoSHOCKcore::GraphNode::children ( ) const

Read-only access to children GraphNodes.

Returns
const reference to vector containing children
void FotoSHOCKcore::GraphNode::confirmOperation ( )

Confirm that the operation should be considered as fully set up.

Interrupts the thread which recalculates the operations in the graph. The thread is interrupted the next time it enters one of the predefined interruption points. Called when the operation in the node is supposed to be invariant from now on.

When the operation is confirmed the caches in a graph are restructured to conform to the new state and the GraphNode is marked inactive (GraphNode.m_active = false).

Before confirming the cache is structured like if the node contains the active operation, ie. there is at least one cache in the preceding nodes.

Examples:
graph/example.cpp.
void FotoSHOCKcore::GraphNode::deleteROI ( boost::shared_ptr< UpdateInfo ROI)

Delete specified ROI from all nodes.

Recursively removes all references to the ROI and its parents.

Only the ROI which belongs to the calling node and which is not a dependency of any other ROI can be removed.

Parameters
ROIUpdateInfo to be removed
void FotoSHOCKcore::GraphNode::enabled ( bool  enable)

Changes the "enabled" state.

the enable state determines, whether the operation can be executed.

The operation is invalid and thus disabled when it has no buffer connected or when it doesn't have all it's inputs connected

Parameters
enabletrue to enable the operation
const bool FotoSHOCKcore::GraphNode::enabled ( ) const

Returns whether the operation is enabled.

For more information see GraphNode::enabled(bool enable);

Returns
true if the node is enabled, false otherwise
ImageBufferBase * FotoSHOCKcore::GraphNode::getBuffer ( const int  mipmapLevel = 0)

Return the buffer associated with the node.

The buffer returned is not guaranteed to contain the results of the operation in calling GraphNode. It is possible that the buffer contains uninitialized values (unless the node has ROI with the same dimensions as the buffer associated). It is possible that the buffer contains the output of succeeding node in case the buffer is shared.

To make sure that the buffer contains valid data for the operation, add ROI covering the requested area in a specified mipmap level and force the operation to be run using the recalculate() function.

Parameters
mipmapLevellevel of the mipmap to return, default is 0 (full resolution)
Returns
pointer to the buffer
const float FotoSHOCKcore::GraphNode::getElapsedTime ( ) const

Return the time consumed to run the operation in the node.

Returns the elapsed time of the operation's last run.

Returns
elapsed time
MipMap * FotoSHOCKcore::GraphNode::getMipMap ( )

Return the mipmap associated with the node.

The mipmap returned is not guaranteed to contain the results of the operation in calling GraphNode. It is possible that the mipmap contains uninitialized values in case the mipmap is shared.

To make sure that the mipmap contains valid data for the operation, add ROI covering the requested area in a specified mipmap level and force the operation in the node to be run using the recalculate() function.

Returns
pointer to the mipmap
const unsigned int FotoSHOCKcore::GraphNode::id ( ) const

Node identifier.

This identifier is used to identify node during the serialization process.

Returns
the identifier
ImageOperation * FotoSHOCKcore::GraphNode::operation ( ) const

Return the ImageOperation associated with the GraphNode.

Returns
the operation associated with the node
ImageOperationDescriptor * FotoSHOCKcore::GraphNode::operationDescriptor ( ) const

Return the descriptor of the ImageOperation associated with the GraphNode.

Returns
the ImageOperationDescriptor
const std::vector< GraphNode * > & FotoSHOCKcore::GraphNode::parents ( ) const

Read-only access to parent GraphNodes.

Returns
const reference to vector containing parents
void FotoSHOCKcore::GraphNode::recalculate ( )

Relculate the operation in the node.

Recalculate() function recalculates the operation in the calling node and in all GraphNodes depending on the output of this node. The previous operations are run if necessary.

Examples:
graph/example.cpp.
void FotoSHOCKcore::GraphNode::saveBuffer ( IO::SaveInfo  info)

Save the buffer associated with the node.

This is a convenience function to save a complete, full-resolution image to a file.

Parameters
infoinformation specifying the output file properties, such as the format and the file name
bool FotoSHOCKcore::GraphNode::tryEnable ( )

Tries to enable node and all following nodes.

This function also involves adding the necessary ROI and a creation of buffers.


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