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

Class for managing a graph of ImageOperations. More...

#include <GraphManager.hpp>

Public Types

typedef boost::bimap< unsigned
int, GraphNode * > 
IdNodeBimapType
 

Public Member Functions

 GraphManager ()
 A constructor. More...
 
 ~GraphManager ()
 A destructor.
 
vector< GraphNode * > & getRoots ()
 Get the root nodes. More...
 
GraphNodeaddRoot (PixelData format, unsigned int width, unsigned int height, const std::string color)
 Add a new root with buffer filled with a specified color. More...
 
GraphNodeaddRoot (const std::string fileName)
 Add a new root and load an image into it. More...
 
GraphNodeaddRoot (PixelData format, const std::string fileName)
 Add a new root and load an image into it. More...
 
void addEdge (GraphNode *source, GraphNode *dest)
 Add an edge between two nodes. More...
 
void addEdge (GraphNode *source, int outputID, GraphNode *dest, int inputID)
 Add an edge between two nodes. More...
 
void removeEdge (GraphNode *source, GraphNode *dest)
 Remove an edge connecting the specified nodes. More...
 
void removeEdge (GraphNode *source, int outputID, GraphNode *dest, int inputID)
 Remove a specific edge connecting the specified nodes. More...
 
GraphNodeinsertOperation (ImageOperationDescriptor *operationDescr)
 Insert a new, unconnected operation into the GraphManager. More...
 
GraphNodeinsertOperation (ImageOperationDescriptor *operationDescr, GraphNode *parent0,...)
 Convenience function for inserting a new operation into the GraphManager. More...
 
GraphNodeinsertOperation (ImageOperationDescriptor *operationDescr, vector< GraphNode * > &parents, vector< GraphNode * > &children)
 Insert a new operation into the GraphManager. More...
 
bool removeOperation (GraphNode *node)
 Remove the GraphNode with the associated ImageOperation from the GraphManager. More...
 
void interruptRecalculate ()
 Interrupt the currently running recalculation. More...
 
void join ()
 Wait for the recalculate thread to complete.
 
void timingSheer (double sheer)
 Set the steepness of a function computing the time limits for the cache management. More...
 
double timingSheer () const
 Returns the current sheer value. More...
 
void timingCurvature (double curvature)
 Set the curvature of a function computing time limits. More...
 
double timingCurvature () const
 Returns the current curvature value. More...
 
unsigned int tileExtent () const
 Returns the tile extent used in the GraphManager. More...
 
void registerOperation (ImageOperationDescriptor *operationDescr)
 Register an ImageOperation in the GraphManager. More...
 
xmlNodePtr serialize ()
 Serialize the graph. More...
 
void serialize (const char *fileName)
 Serialize the graph into a file. More...
 
IdNodeBimapType deserialize (xmlNodePtr rootElement)
 Deserialize the graph. More...
 
IdNodeBimapType deserialize (const char *fileName)
 Deserialize the graph. More...
 

Protected Attributes

ConstPtr< Graph_privatem_impl
 

Friends

class GraphNode
 

Detailed Description

Class for managing a graph of ImageOperations.

The GraphManager class is one of the most important classes in FotoSHOCK. It is used for managing the ImageOperations in an acyclic directed graph. This includes management of memory, so the operations are freed when the corresponding node is removed or upon the GraphManager destruction.

A starting point in a graph is a so-called root operation. There may be more root operations, meaning that there are multiple input images. The root can be either an existing image loaded from disk, or an image created by FotoSHOCK.

The graph manager also handles caching of intermediate results where needed. For more details on how this works, see TODO: reference the thesis.

The functions provided by the GraphManager include functions for:

Examples:
graph/example.cpp.

Constructor & Destructor Documentation

FotoSHOCKcore::GraphManager::GraphManager ( )

A constructor.

Construct a GraphManager object, representing an empty graph.

Member Function Documentation

void FotoSHOCKcore::GraphManager::addEdge ( FotoSHOCKcore::GraphNode source,
FotoSHOCKcore::GraphNode dest 
)

Add an edge between two nodes.

This version uses the first unset source and the first input. The edge is an oriented edge from source to dest.

Parameters
sourcesource node
destdestination node
Note
this may be removed in the future and replaced by the overload specifying the input and output numbers
void FotoSHOCKcore::GraphManager::addEdge ( FotoSHOCKcore::GraphNode source,
int  outputID,
FotoSHOCKcore::GraphNode dest,
int  inputID 
)

Add an edge between two nodes.

The edge is an oriented edge from source to dest.

This overload allows to specify both input and output number (id). This function doesn't check whether an edge already exists between the nodes.

Parameters
sourcesource node
outputIDnumber (id) of output that is used as the starting point of the edge
destdestination node
inputIDnumber (id) input that is used as the edge endpoint
GraphNode * FotoSHOCKcore::GraphManager::addRoot ( PixelData  format,
unsigned int  width,
unsigned int  height,
const std::string  color 
)

Add a new root with buffer filled with a specified color.

Creates a new root with a new buffer. The buffer is then filled with a specified color.

Parameters
formatformat of pixels in the root node
widthwidth of buffer in the root node
heightheight of buffer in the root node
colorcolor which is used to fill the buffer. For the list of supoprted supported colors, see the documentation of FotoSHOCKcore::FillFunctor.
Returns
the created node
Examples:
graph/example.cpp.
GraphNode * FotoSHOCKcore::GraphManager::addRoot ( const std::string  fileName)

Add a new root and load an image into it.

Creates a new root node and loads an image into this node.

The used format is guessed by the encoder. It should be the best matching format for the input image.

Parameters
fileNamepath to the image
Returns
a node containing the loaded image
GraphNode * FotoSHOCKcore::GraphManager::addRoot ( PixelData  format,
const std::string  fileName 
)

Add a new root and load an image into it.

Creates a new root node and loads an image into this node.

Parameters
formatformat of pixels in the root node
fileNamepath to the image
Returns
a node containing the loaded image
GraphManager::IdNodeBimapType FotoSHOCKcore::GraphManager::deserialize ( xmlNodePtr  rootElement)

Deserialize the graph.

Deserialize the graph from XML tree.

Parameters
rootElementthe root (ie. the <graph> element) element of the XML tree.
Returns
mapping between loaded IDs and corresponding GraphNodes. This is usefull when there was an additional information serialized outside of the GraphManager that used the GraphNode IDs.
GraphManager::IdNodeBimapType FotoSHOCKcore::GraphManager::deserialize ( const char *  fileName)

Deserialize the graph.

Deserialize the graph from XML file.

Parameters
fileNameXML document containing the serialized data. The root element of such file has to be a <graph> element.
Returns
mapping between loaded IDs and corresponding GraphNodes
vector< GraphNode * > & FotoSHOCKcore::GraphManager::getRoots ( )

Get the root nodes.

Returns the vector of nodes which is used as a root (a starting point) for the processing.

Returns
a vector of all root nodes
GraphNode * FotoSHOCKcore::GraphManager::insertOperation ( ImageOperationDescriptor operationDescr)

Insert a new, unconnected operation into the GraphManager.

Inserts a new operation without any connections into a graph. To connect it with other nodes, use one of the addEdge() functions.The created node is inactive until it is properly connected to other nodes.

The purpose of this function is to allow creating a new unconnected nodes, which can be automatically freed by the GraphManager on exit.

Parameters
operationDescrpointer to an ImageOperationDescriptor of the operation to be inserted
Returns
pointer to a node containing the operation
Examples:
graph/example.cpp.
GraphNode * FotoSHOCKcore::GraphManager::insertOperation ( ImageOperationDescriptor operationDescr,
GraphNode parent0,
  ... 
)

Convenience function for inserting a new operation into the GraphManager.

This is a convenience function for inserting a new operation into the GraphManager without the need to initialize parents and children vectors manually.

Parameters
operationpointer to an ImageOperationDescriptor to be inserted
...pointers to parents
NULLseparates parents from children (it mustn't be 0)
...pointers to children
NULLends the list of children
Returns
pointer to a GraphNode containing the operation
GraphNode * FotoSHOCKcore::GraphManager::insertOperation ( ImageOperationDescriptor operationDescr,
std::vector< GraphNode * > &  parents,
std::vector< GraphNode * > &  children 
)

Insert a new operation into the GraphManager.

Parameters
operationpointer to an ImageOperationDescriptor to be inserted
parentsvector of pointers to all parents
childrenvector of pointers to all children
Returns
pointer to a GraphNode containing the operation
void FotoSHOCKcore::GraphManager::interruptRecalculate ( )

Interrupt the currently running recalculation.

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.

void FotoSHOCKcore::GraphManager::registerOperation ( ImageOperationDescriptor operationDescr)

Register an ImageOperation in the GraphManager.

It is necessary that the ImageOperation is registered withing GraphManager for deserialization to work.

That is because deserialization needs to construct operations based on the ID's, so there must be a mapping between ImageOperationDescriptor::id() and a corresponding class.

void FotoSHOCKcore::GraphManager::removeEdge ( GraphNode source,
GraphNode dest 
)

Remove an edge connecting the specified nodes.

A convencience function, that removes edge between the source's output 0 and dest's input 0.

Parameters
sourcea first node
desta second node
Note
this may be removed in the future and replaced by the overload specifying the input and output numbers
void FotoSHOCKcore::GraphManager::removeEdge ( GraphNode source,
int  outputID,
GraphNode dest,
int  inputID 
)

Remove a specific edge connecting the specified nodes.

Removes the edge between the source's specific output and dest's input.

Parameters
sourcethe starting node of the edge
outputIDnumber of output, to which the edge is connected
destthe edge's end node
inputIDthe number of input, to which the edge is connected
bool FotoSHOCKcore::GraphManager::removeOperation ( GraphNode node)

Remove the GraphNode with the associated ImageOperation from the GraphManager.

Remove the node from the graph. Can be used for removing preview operations too.

Parameters
nodenode which should be removed
Returns
true on success, false if the node can't be removed (eg. because it has multiple parents and it still has at least one child)
xmlNodePtr FotoSHOCKcore::GraphManager::serialize ( )

Serialize the graph.

Serialize the graph into XML using the libxml2 tree API.

Returns
the root element of the XML tree.

first we store all the nodes

store the connections between nodes

store ROI

void FotoSHOCKcore::GraphManager::serialize ( const char *  fileName)

Serialize the graph into a file.

Serialize the graph into XML and store it in the file.

Parameters
fileNamename of the saved file

cleanup

unsigned int FotoSHOCKcore::GraphManager::tileExtent ( ) const

Returns the tile extent used in the GraphManager.

The tileExtent is used as a tileExtent for all buffers in the graph handled by the GraphManager. This includes both root images and caches.

Returns
tile extent used within the graph
void FotoSHOCKcore::GraphManager::timingCurvature ( double  curvature)

Set the curvature of a function computing time limits.

Bigger value means bigger curvature => the limit grows faster.

Must be >= 1, where curvature = 1 is a constant function.

Parameters
curvaturedefines how fast the time limits grow
double FotoSHOCKcore::GraphManager::timingCurvature ( ) const

Returns the current curvature value.

For more information about the curvature, see the documentation of the timingCurvature() setter.

Returns
current curvature
void FotoSHOCKcore::GraphManager::timingSheer ( double  sheer)

Set the steepness of a function computing the time limits for the cache management.

The sheer defines how "steep" the function used for computing time limits is. Generally smaller value means longer limits.

Must be positive.

Parameters
sheerthe steepness of the function computing time limits
double FotoSHOCKcore::GraphManager::timingSheer ( ) const

Returns the current sheer value.

For more information, see the documentation of the timingSheer() setter.

Returns
current sheer

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