ImGraph
 All Classes Functions Variables Enumerations Pages
charliesoft::Block Class Referenceabstract
Inheritance diagram for charliesoft::Block:
charliesoft::SubBlock charliesoft::ForBlock

Public Types

enum  BlockType { synchrone = 0, asynchrone }
 
enum  BlockState {
  waitingChild = 0, consumingParams, consumedParams, waitingConsumers,
  stopped, paused
}
 

Public Member Functions

 Block (std::string name, bool isOneShot, BlockType typeExec=synchrone, bool addInputParam=false)
 
virtual ~Block ()
 The derived block may want a personalized destructor...
 
std::string getName ()
 
BlockType getTypeExec ()
 
void operator() ()
 
virtual bool run (bool oneShot=false)=0
 
bool hasDynamicParams () const
 
ParamValueaddNewInput (ParamDefinition *param)
 
ParamValueaddNewOutput (ParamDefinition *param)
 
virtual void init ()
 
virtual void release ()
 
void markAsUnprocessed ()
 Use this function to reset state of process (mark every input/output as old)
 
ParamDefinitiongetParamDefinition (std::string nameOfParam, bool isInput)
 
const ParamDefinitiongetParamDefinition (std::string nameOfParam, bool isInput) const
 
bool paramDefinitionExist (std::string nameOfParam, bool isInput)
 
std::string getCurrentPreview () const
 
void setCurrentPreview (std::string val)
 
const AlgoPerformancegetPerf () const
 
virtual void setGraph (GraphOfProcess *processes)
 
GraphOfProcessgetGraph () const
 
BlockState getState () const
 
void setState (BlockState val)
 
BlockType getExecType () const
 
void setExecType (BlockType val)
 
unsigned int getNbRendering () const
 
unsigned int getTimestamp ()
 
std::string getErrorInfo ()
 
bool validateParams (std::string param, const ParamValue val)
 
bool isReadyToRun (bool realCheck=false)
 if realCheck is true, we look for links being ready to consume
 
void addCondition (ConditionOfRendering &c)
 
std::vector
< ConditionOfRendering > & 
getConditions ()
 
virtual void setParamValue (std::string nameParam_, ParamValue *value)
 
virtual void setParam (std::string nameParam_, ParamValue value)
 
virtual ParamValuegetParam (std::string nameParam_, bool input)
 
virtual std::vector< cv::String > getSubParams (std::string paramName)
 
bool isStartingBlock ()
 
bool isAncestor (Block *other)
 
bool hasNewParameters ()
 
void wakeUpFromConsumers ()
 
void notifyProduction ()
 
void wakeUpFromPause ()
 
void waitConsumers (boost::unique_lock< boost::mutex > &lock)
 
void waitProducers (boost::unique_lock< boost::mutex > &lock)
 
boost::mutex & getMutex ()
 
boost::mutex & getMutexTimestamp ()
 
std::vector< BlockLinkgetInEdges ()
 
std::string getErrorMsg ()
 
const cv::Point2f & getPosition () const
 
const cv::Point2f & getSizeIncrement () const
 
void updatePosition (float x, float y)
 
void linkParam (std::string paramName, Block *dest, std::string paramNameDest)
 
virtual boost::property_tree::ptree getXML ()
 
virtual void initFromXML (boost::property_tree::ptree *tree, std::vector< std::pair< ParamValue *, unsigned int > > &toUpdate, std::map< unsigned int, ParamValue * > &addressesMap, std::vector< ConditionOfRendering * > &condToUpdate)
 
void setPosition (int x, int y, float incX, float incY)
 
void setIncrSize (float incX, float incY)
 
void removeCondition ()
 
void update ()
 Re-run this block. If links exist, this will also render every ancestors.
 
bool shouldExecuteOnlyOnce () const
 
void setExecuteOnlyOnce (bool val)
 
std::vector< ParamDefinition * > & getInParams ()
 
std::vector< ParamDefinition * > & getOutParams ()
 
std::map< std::string,
ParamValue > const & 
getInputsVals () const
 
std::map< std::string,
ParamValue > const & 
getOutputsVals () const
 
ParamDefinition getDef (std::string name, bool isInput) const
 

Protected Member Functions

void initParameters (const std::vector< ParamDefinition > &inParam, const std::vector< ParamDefinition > &outParam)
 
void newProducedData ()
 
void paramsFullyProcessed ()
 

Protected Attributes

boost::thread::id _threadID
 
boost::posix_time::ptime _time_start
 used to measure processing time...
 
AlgoPerformance _perfCounter
 Used to record algo performance.
 
BlockState _state
 Current state of the block.
 
BlockType _exec_type
 
unsigned int nbRendering
 
GraphOfProcess_processes
 list of process currently in use
 
boost::condition_variable _cond_pause
 pause condition
 
boost::mutex _mtx
 explicit mutex declaration
 
boost::condition_variable _wait_consume
 parameter consumption sync condition
 
boost::condition_variable _wait_processed
 Block has processed the input datas.
 
boost::mutex _mtx_timestamp_inc
 Timestamps update.
 
unsigned int _timestamp
 timestamp of produced values
 
std::string _error_msg
 
std::string _name
 
cv::Point2f _position
 
cv::Point2f _sizeIncrement
 
std::string _currentPreview
 
std::vector< ParamDefinition * > _algorithmInParams
 definition of each input parameters
 
std::vector< ParamDefinition * > _algorithmSubParams
 definition of each input sub-parameters
 
std::vector< ParamDefinition * > _algorithmOutParams
 definition of each output parameters
 
std::map< std::string, ParamValue_myOutputs
 output value and name of parameters
 
std::map< std::string, ParamValue_myInputs
 input value and name of parameters
 
std::map< std::string, ParamValue_mySubParams
 sub-params value and name of parameters
 
std::vector< ConditionOfRendering_conditions
 Conditions needed for block rendering.
 
bool _executeOnlyOnce
 
bool _newData
 
bool _isOneShot
 
bool _addInputParam
 

Friends

class GraphOfProcess
 
class charliesoft::ProcessManager
 

Member Enumeration Documentation

Five states of blocks:

  • waitingChild: Block wait for new input values... Only synchrone block can be in this state.
  • consumingParams: Block is active and produce new datas
  • consumedParams: Block produced new datas
  • waitingConsumers: Block wait until all its output are consumed.
  • stopped: Block is not yet started
  • paused: Block wait until user start again the graph

Two types of blocks:

  • Classic block. Called "synchrone" they just take some input and create some output. They also wait the output childs to process the data. Ex: line finder.
  • The "asynchrones" : they produce data continuously without waiting anything.

Constructor & Destructor Documentation

charliesoft::Block::Block ( std::string  name,
bool  isOneShot,
BlockType  typeExec = synchrone,
bool  addInputParam = false 
)

Used to create a block...

Parameters
nameblock name, can be a label from Internationalizator
isOneShotif the block is simple (that is, the block is state-free), set this value to true.
typeExecused to know the type of execution this bloc should have...

Member Function Documentation

ParamValue * charliesoft::Block::addNewInput ( ParamDefinition param)

Used to add a new parameter...

Parameters
paramdefinition of the new input parameter
ParamValue * charliesoft::Block::addNewOutput ( ParamDefinition param)

Used to add a new output...

Parameters
paramdefinition of the new output value
void charliesoft::Block::initParameters ( const std::vector< ParamDefinition > &  inParam,
const std::vector< ParamDefinition > &  outParam 
)
protected

This function is used by ProcessManager to init block with default values...


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