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

Protected Member Functions

void recalculate (GraphNode *node)
 Run the operation of succeeding GraphNodes up to the last node with ROI specified. More...
 
void interruptRecalculate ()
 
bool tryEnable (GraphNode *node)
 Try to enable the operation and all following operations. More...
 
void confirmOperation (GraphNode *node)
 Confirm that the operation should taken as final. More...
 
boost::shared_ptr< UpdateInfoaddROI (GraphNode *node, UpdateInfo ROI)
 Add ROI. More...
 
boost::shared_ptr< UpdateInfoaddROI (GraphNode *node, ROIinfo ROI)
 
boost::shared_ptr< UpdateInfoaddROI (GraphNode *node, unsigned int x, unsigned int y, unsigned int sizeX, unsigned int sizeY, const int mipmapLevel=0)
 
vector< boost::shared_ptr
< UpdateInfo > >::iterator 
deleteROI (boost::shared_ptr< UpdateInfo > ROI)
 Delete specified ROI from all nodes. More...
 
void recalculate_impl (GraphNode *node)
 The recalculate() implementation. More...
 
void checkFormat (ImageOperationDescriptor *operation, vector< GraphNode * > &parents, vector< GraphNode * > &children)
 Check whether the operation supports the input/output formats. More...
 
void createCache (vector< GraphNode * > &parents, GraphNode *node, bool allocateTiles=true)
 Add a cache to the node. More...
 
void removeNode (vector< GraphNode * > &vect, GraphNode *node)
 Remove the node from the vector. More...
 
void topologicalSort (GraphNode *node, std::list< GraphNode * > &sorted)
 Topological sort. More...
 
void topologicalSort_impl (GraphNode *node, std::list< GraphNode * > &sorted)
 
void updateParentsCache (GraphNode *node)
 Update the cache of the preceding nodes. More...
 
void updateChildrenBuffer (GraphNode *node)
 Update a buffer of all children if necessary. More...
 
void cleanupVisited (GraphNode *node)
 Cleans the visited flag of all GraphNodes.
 
void addROI_impl (GraphNode *node, boost::shared_ptr< UpdateInfo > ROI)
 
void insertROIForNodes (GraphNode *node, GraphNode *parent, GraphNode *child)
 Insert an UpdateInfo into the newly created GraphNode. More...
 
void insertROIForNodes (GraphNode *node, vector< GraphNode * > &parents, GraphNode *child)
 Insert an UpdateInfo into the newly created GraphNode. More...
 
void updateDistance (GraphNode *node)
 Updates distance for all parent nodes until active node is found.
 
double computeTimeLimit (double a, double b, double distance)
 Compute time limit for the given distance.
 
void cleanupCache ()
 Cleanup caches in graph. More...
 
void cleanupCache_impl (GraphNode *node, float time)
 
void invalidateChildrenStamp (GraphNode *node)
 Invalidate time stamp in node's children.
 
void disableChildren (GraphNode *node, bool cleanBuffer)
 Invalidate the following operations. More...
 

Protected Attributes

vector< GraphNode * > m_roots
 Vector containting all roots and unconnected operations.
 
unsigned int m_tileExtent
 tile extent for all buffers managed by the GraphManager.
 
unsigned int m_nodeIDcounter
 Counter used to initialize nodeID of a newly created GraphNode.
 
std::map< uint64_t,
ImageOperationDescriptor * > 
m_registeredOperations
 Stores pointers to all registered ImageOperationDescriptors, needed for deserialization. More...
 
boost::thread * m_recalculateThread
 A worker thread. More...
 
double m_timingSheer
 
double m_timingCurvature
 

Friends

class GraphManager
 
class GraphNode
 

Member Function Documentation

shared_ptr< UpdateInfo > FotoSHOCKcore::Graph_private::addROI ( GraphNode node,
UpdateInfo  ROI 
)
protected

Add ROI.

Adds ROI to the node and propagates it down to all preceding nodes.

Parameters
nodenode which initiates the adition of a new ROI
ROIdesired ROI
Returns
shared_ptr to the UpdateInfo containing the addedROI
void FotoSHOCKcore::Graph_private::checkFormat ( ImageOperationDescriptor operation,
std::vector< GraphNode * > &  parents,
std::vector< GraphNode * > &  children 
)
protected

Check whether the operation supports the input/output formats.

Throws CoreException in case the operation doesn't support the given format. NOTE: it might be better to use return values instead

Todo:
fix and enable format checks
Parameters
operationoperation to check
parentsthe parent nodes, which should be used as an input
childrenchildren nodes, ie the destination
void FotoSHOCKcore::Graph_private::cleanupCache ( )
protected

Cleanup caches in graph.

The time limit for given node is computed using the exponential function: y(t) = a ^ time/b where a, b are tunable parameters. The value of has to be higher than 1. The usual values are a = 1.5; b = 1.5

IMPORTANT NOTE: it would be better if the cache creation is minimized at the expense of exceeding time limit settings because the necessary recalculations may take a lot of time.

void FotoSHOCKcore::Graph_private::confirmOperation ( GraphNode node)
protected

Confirm that the operation should taken as final.

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

Parameters
nodenode whose operation shall be confirmed
void FotoSHOCKcore::Graph_private::createCache ( vector< GraphNode * > &  parents,
GraphNode node,
bool  allocateTiles = true 
)
protected

Add a cache to the node.

createCache adds buffer which is big enough to handle intersection of all parents buffers to a node.

It doesn't check whether node has a buffer. This means that the createCache should not be called on a node which already has a buffer because it would result in memory leak.

vector< shared_ptr< UpdateInfo > >::iterator FotoSHOCKcore::Graph_private::deleteROI ( boost::shared_ptr< UpdateInfo ROI)
protected

Delete specified ROI from all nodes.

Remove ROI specified by the UpdateInfo from all nodes.

Parameters
ROIUpdateInfo to be removed
Returns
iterator to the next ROI in the parentNode ROI list
void FotoSHOCKcore::Graph_private::disableChildren ( GraphNode node,
bool  cleanBuffer 
)
protected

Invalidate the following operations.

Invalidates all operation depending on the node. Optionally it is possible to set the buffer of all invalid operations to zero until an operation with cache is encountered. In other words, all children operations are invalidated, but only the ones which share buffer with the node has buffer set to zero.

void FotoSHOCKcore::Graph_private::insertROIForNodes ( GraphNode node,
GraphNode parent,
GraphNode child 
)
protected

Insert an UpdateInfo into the newly created GraphNode.

When a new GraphNode is inserted between the child and the parent it is necessary to insert new UpdateInfos into the node which properly connects child with parent.

insertROIForNodes() does this creation of UpdateInfo and relinking.

Parameters
nodeinserted node where the new UpdateInfo should be inserted
parentparent of the node
childchild of the node
void FotoSHOCKcore::Graph_private::insertROIForNodes ( GraphNode node,
vector< GraphNode * > &  parents,
GraphNode child 
)
protected

Insert an UpdateInfo into the newly created GraphNode.

When a new GraphNode is inserted between the child and the parents it is necessary to insert new UpdateInfos into the node which properly connects child with its parents.

insertROIForNodes() does this creation of UpdateInfo and relinking.

Parameters
nodeinserted node where the new UpdateInfo should be inserted
parentlist of parents of the node
childchild of the node
void FotoSHOCKcore::Graph_private::recalculate ( GraphNode node)
protected

Run the operation of succeeding GraphNodes up to the last node with ROI specified.

Parameters
nodethe node where the recalculation starts
void FotoSHOCKcore::Graph_private::recalculate_impl ( GraphNode node)
protected

The recalculate() implementation.

This function is run by the thread created in the recalculate().

void FotoSHOCKcore::Graph_private::removeNode ( vector< GraphNode * > &  vect,
GraphNode node 
)
protected

Remove the node from the vector.

Removes the node from the vector WITHOUT freeing the it's memory.

Parameters
vectvector from which the node should be removed
nodenode to remove
void FotoSHOCKcore::Graph_private::topologicalSort ( GraphNode node,
std::list< GraphNode * > &  sorted 
)
protected

Topological sort.

Parameters
nodestart node
sortedlist where the sorted operations will be stored
bool FotoSHOCKcore::Graph_private::tryEnable ( GraphNode node)
protected

Try to enable the operation and all following operations.

This function tries to enable the operation and all following operations. This involves adding the necessary ROI and a creation of buffers.

Parameters
nodenode that we are trying to enable
Returns
true if all children that needed to be enabled were enabled successfully
void FotoSHOCKcore::Graph_private::updateChildrenBuffer ( GraphNode node)
protected

Update a buffer of all children if necessary.

Recursively traverse all children and set their buffer to a buffer of the calling node in case they do not contain cache.

The traversal stops when children with cache is found.

Parameters
nodethe from which the graph traversal starts. Also its buffer is used as the buffer in children which do not contain cache
void FotoSHOCKcore::Graph_private::updateParentsCache ( GraphNode node)
protected

Update the cache of the preceding nodes.

When the updateParentsCache() is called the graph is traversed back to find a node which contains the cache and then runs the operations up to the node.

This is usefull when the cache is shared between several nodes and thus the cache content can contain the results of the latest operation in a chain of nodes.

For an example see the following graph.

dot_inline_dotgraph_1.png

"node 1" is a node with a cache which is shared with the "node 2", "node 3" and "node 4." Because the buffer is shared between these operations it contains the results of the "node 4" operation. If a cache to the "node 3" is added the "node 1" buffer should contain the results of "node 2" and not "node 4." "node 3" buffer should contain the results of "node 4" operation.

Member Data Documentation

boost::thread* FotoSHOCKcore::Graph_private::m_recalculateThread
protected

A worker thread.

Currently there is only one worker thread which traverses the graph and runs operations. The reason is that it would be difficult to handle race conditions if more threads were allowed.

std::map<uint64_t, ImageOperationDescriptor*> FotoSHOCKcore::Graph_private::m_registeredOperations
protected

Stores pointers to all registered ImageOperationDescriptors, needed for deserialization.

It's a map to allow faster searches.


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