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... | |
GraphNode * | addRoot (PixelData format, unsigned int width, unsigned int height, const std::string color) |
Add a new root with buffer filled with a specified color. More... | |
GraphNode * | addRoot (const std::string fileName) |
Add a new root and load an image into it. More... | |
GraphNode * | addRoot (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... | |
GraphNode * | insertOperation (ImageOperationDescriptor *operationDescr) |
Insert a new, unconnected operation into the GraphManager. More... | |
GraphNode * | insertOperation (ImageOperationDescriptor *operationDescr, GraphNode *parent0,...) |
Convenience function for inserting a new operation into the GraphManager. More... | |
GraphNode * | insertOperation (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_private > | m_impl |
Friends | |
class | GraphNode |
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:
FotoSHOCKcore::GraphManager::GraphManager | ( | ) |
A constructor.
Construct a GraphManager object, representing an empty graph.
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.
source | source node |
dest | destination node |
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.
source | source node |
outputID | number (id) of output that is used as the starting point of the edge |
dest | destination node |
inputID | number (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.
format | format of pixels in the root node |
width | width of buffer in the root node |
height | height of buffer in the root node |
color | color which is used to fill the buffer. For the list of supoprted supported colors, see the documentation of FotoSHOCKcore::FillFunctor. |
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.
fileName | path to the image |
Add a new root and load an image into it.
Creates a new root node and loads an image into this node.
format | format of pixels in the root node |
fileName | path to the image |
GraphManager::IdNodeBimapType FotoSHOCKcore::GraphManager::deserialize | ( | xmlNodePtr | rootElement) |
Deserialize the graph.
Deserialize the graph from XML tree.
rootElement | the root (ie. the <graph> element) element of the XML tree. |
GraphManager::IdNodeBimapType FotoSHOCKcore::GraphManager::deserialize | ( | const char * | fileName) |
Deserialize the graph.
Deserialize the graph from XML file.
fileName | XML document containing the serialized data. The root element of such file has to be a <graph> element. |
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.
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.
operationDescr | pointer to an ImageOperationDescriptor of the operation to be inserted |
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.
operation | pointer to an ImageOperationDescriptor to be inserted |
... | pointers to parents |
NULL | separates parents from children (it mustn't be 0) |
... | pointers to children |
NULL | ends the list of children |
GraphNode * FotoSHOCKcore::GraphManager::insertOperation | ( | ImageOperationDescriptor * | operationDescr, |
std::vector< GraphNode * > & | parents, | ||
std::vector< GraphNode * > & | children | ||
) |
Insert a new operation into the GraphManager.
operation | pointer to an ImageOperationDescriptor to be inserted |
parents | vector of pointers to all parents |
children | vector of pointers to all children |
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.
Remove an edge connecting the specified nodes.
A convencience function, that removes edge between the source's output 0 and dest's input 0.
source | a first node |
dest | a second node |
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.
source | the starting node of the edge |
outputID | number of output, to which the edge is connected |
dest | the edge's end node |
inputID | the 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.
node | node which should be removed |
xmlNodePtr FotoSHOCKcore::GraphManager::serialize | ( | ) |
Serialize the graph.
Serialize the graph into XML using the libxml2 tree API.
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.
fileName | name 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.
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.
curvature | defines 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.
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.
sheer | the 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.