fw4spl
|
This class defines a graph object. More...
#include <Graph.hpp>
Public Types | |
typedef std::map< Edge::sptr, std::pair< Node::sptr, Node::sptr > > | ConnectionContainer |
typedef std::set< Node::sptr > | NodeContainer |
typedef std::vector< ::fwData::Object::sptr > | UpdatedDataType |
Type of signal m_sigUpdated. | |
typedef ::fwCom::Signal< void(UpdatedDataType, UpdatedDataType) > | UpdatedSignalType |
Update signal type Signal updated is composed of two parameters which represent added and removed elements in the graph. | |
Public Types inherited from fwData::Object | |
typedef ::fwData::factory::Key | Key |
typedef std::string | FieldNameType |
typedef std::vector< FieldNameType > | FieldNameVectorType |
typedef ::std::unordered_map< FieldNameType,::fwData::Object::sptr > | FieldMapType |
typedef ::std::unordered_map< ::fwData::Object::csptr,::fwData::Object::sptr > | DeepCopyCacheType |
typedef ::fwCom::Signal< void() > | ModifiedSignalType |
Type of signal m_sigModified. | |
typedef std::map< std::string,::fwData::Object::sptr > | FieldsContainerType |
Type of signal m_sigModified. | |
typedef ::fwCom::Signal< void(FieldsContainerType) > | AddedFieldsSignalType |
Type of signal when objects are added. | |
typedef ::fwCom::Signal< void(FieldsContainerType, FieldsContainerType) > | ChangedFieldsSignalType |
Type of signal when objects are changed (newObjects, oldObjects) | |
typedef ::fwCom::Signal< void(FieldsContainerType) > | RemovedFieldsSignalType |
Type of signal when objects are removed. | |
Public Types inherited from fwCom::HasSignals | |
typedef std::shared_ptr< HasSignals > | sptr |
typedef std::shared_ptr< const HasSignals > | csptr |
Public Member Functions | |
virtual bool | isA (const std::string &type) const override |
FWDATA_API | Graph (::fwData::Object::Key key) |
Constructor. More... | |
virtual FWDATA_API | ~Graph () |
Destructor. | |
FWDATA_API bool | addNode (Node::sptr _node) |
add a node More... | |
FWDATA_API bool | removeNode (Node::csptr _node) |
remove a node More... | |
FWDATA_API const ConnectionContainer & | getConnections () const |
Get the connection container. More... | |
FWDATA_API ConnectionContainer & | getConnections () |
FWDATA_API bool | addEdge (Edge::sptr _edge, Node::csptr _nodeSource, Node::csptr _nodeDestination) |
Add and edge. More... | |
FWDATA_API Edge::sptr | makeConnection (Node::csptr _nodeSource, std::string _nodeSourceOutputPortID, Node::csptr _nodeDestination, std::string _nodeDestinationInputPortID, std::string _EdgeNature) |
create an edge from given info and add edge in the graph More... | |
FWDATA_API bool | removeEdge (Edge::sptr _edge) |
remove an edge More... | |
FWDATA_API Node::sptr | getSourceNode (Edge::sptr _edge) |
Get source node. More... | |
FWDATA_API Node::sptr | getDestinationNode (Edge::sptr _edge) |
Get destination node. More... | |
FWDATA_API Node::sptr | getNode (Edge::sptr _edge, bool _upStream) |
Get node. More... | |
FWDATA_API std::vector< Edge::sptr > | getInputEdges (Node::csptr _node) |
Get input edges. More... | |
FWDATA_API std::vector< Edge::sptr > | getOutputEdges (Node::csptr _node) |
Get output edges. More... | |
FWDATA_API std::vector< Edge::sptr > | getEdges (const Node::csptr &_node, bool _upStream, const std::string &_nature="", const std::string &_portID="") |
Get a vector of edges. More... | |
FWDATA_API std::vector< ::fwData::Node::sptr > | getNodes (const ::fwData::Node::csptr &node, bool upStream, const std::string &nature="", const std::string &portID="") |
Get a vector of nodes. More... | |
FWDATA_API size_t | getNbNodes () const |
FWDATA_API size_t | getNbEdges () const |
FWDATA_API void | shallowCopy (const Object::csptr &_source) override |
FWDATA_API void | cachedDeepCopy (const Object::csptr &_source, DeepCopyCacheType &cache) override |
FWDATA_API bool | haveConnectedEdges (Node::csptr _node) const |
Check if an edge is connected to the node. More... | |
FWDATA_API NodeContainer & | getNodes () |
Get the node container. | |
FWDATA_API const NodeContainer & | getNodes () const |
Get the node container. | |
Public Member Functions inherited from fwData::Object | |
FWDATA_API::fwData::Object::sptr | getField (const FieldNameType &name,::fwData::Object::sptr defaultValue=::fwData::Object::sptr()) const |
Returns a pointer of corresponding field (null if non exist). More... | |
template<typename DATA_TYPE > | |
std::shared_ptr< DATA_TYPE > | getField (const FieldNameType &name) const |
Returns a pointer of corresponding field. More... | |
template<typename DATA_TYPE > | |
std::shared_ptr< DATA_TYPE > | getField (const FieldNameType &name, std::shared_ptr< DATA_TYPE > defaultValue) const |
Returns a pointer of corresponding field. More... | |
template<typename DATA_TYPE > | |
std::shared_ptr< DATA_TYPE > | setDefaultField (const FieldNameType &name, std::shared_ptr< DATA_TYPE > defaultValue) |
Returns a pointer of corresponding field. If field did not exist, it is set to defaultValue if defaultValue is not null. More... | |
FWDATA_API::fwData::Object::csptr | getConstField (const FieldNameType &name) const |
Returns a pointer of corresponding field (null if non exist). More... | |
FWDATA_API const FieldMapType & | getFields () const |
Returns fields map. | |
FWDATA_API FieldNameVectorType | getFieldNames () const |
Returns vector of field names. | |
FWDATA_API void | setField (const FieldNameType &name,::fwData::Object::sptr obj) |
Register field with specified name. If the name does already exist, the matching field will be replaced. More... | |
FWDATA_API void | setFields (const FieldMapType &fieldMap) |
Replace the field map content. | |
FWDATA_API void | removeField (const FieldNameType &name) |
Removes field with specified name. More... | |
virtual FWDATA_API void | shallowCopy (const ::fwData::Object::csptr &source) |
A shallow copy of fields (objects in m_children) More... | |
FWDATA_API void | deepCopy (const ::fwData::Object::csptr &source) |
Make a deep copy from the source Calling this method may invalidate any DumpLock, RescursiveLock or helper on the object. Prefer using fwData::Object::copy instead. | |
FWDATA_API void | fieldShallowCopy (const ::fwData::Object::csptr &source) |
A shallow copy of fields (objects in m_children) More... | |
FWDATA_API void | fieldDeepCopy (const ::fwData::Object::csptr &source) |
A deep copy of fields (objects in m_children) More... | |
::fwCore::mt::ReadWriteMutex & | getMutex () const |
Returns the object's mutex. | |
Public Member Functions inherited from fwTools::Object | |
Public Member Functions inherited from fwCore::BaseObject | |
Public Member Functions inherited from fwCom::HasSignals | |
std::shared_ptr< SignalBase > | signal (const Signals::SignalKeyType &key) const |
template<typename SignalType > | |
std::shared_ptr< SignalType > | signal (const Signals::SignalKeyType &key) const |
template<typename SignalType > | |
std::shared_ptr< SignalType > | newSignal (const Signals::SignalKeyType &key) |
Static Public Member Functions | |
static bool | isTypeOf (const std::string &type) |
Static Public Member Functions inherited from fwData::Object | |
static bool | isTypeOf (const std::string &type) |
static FWDATA_API::fwData::Object::sptr | copy (const ::fwData::Object::csptr &source) |
return a copy of the source. if source is a null pointer, return a null pointer. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< const DATA_TYPE > &source) |
return a copy of the source. if source is a null pointer, return a null pointer. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< DATA_TYPE > &source) |
return a copy of the source. if source is a null pointer, return a null pointer. | |
static const std::string & | classname () |
return full object's classname with its namespace, i.e. fwCore::BaseObject | |
Static Public Member Functions inherited from fwTools::Object | |
static bool | isTypeOf (const std::string &type) |
static const std::string & | classname () |
return full object's classname with its namespace, i.e. fwCore::BaseObject | |
Static Public Member Functions inherited from fwCore::BaseObject | |
static bool | isTypeOf (const std::string &type) |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
Static Public Attributes | |
static FWDATA_API const bool | UP_STREAM = true |
static FWDATA_API const bool | DOWN_STREAM = false |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_UPDATED_SIG = "updated" |
Updated signal key. | |
Static Public Attributes inherited from fwData::Object | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_MODIFIED_SIG = "modified" |
Key in m_signals map of signal m_sigModified. | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_ADDED_FIELDS_SIG = "addedFields" |
Type of signal m_sigModified. | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_CHANGED_FIELDS_SIG = "changedFields" |
Type of signal m_sigModified. | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_REMOVED_FIELDS_SIG = "removedFields" |
Type of signal m_sigModified. | |
Protected Attributes | |
NodeContainer | m_nodes |
ConnectionContainer | m_connections |
UpdatedSignalType::sptr | m_sigUpdated |
Updated signal. | |
Protected Attributes inherited from fwData::Object | |
FieldMapType | m_fields |
Fields. | |
mutable::fwCore::mt::ReadWriteMutex | m_mutex |
Mutex to protect object access. | |
Protected Attributes inherited from fwTools::Object | |
std::shared_ptr< ::fwTools::UUID > | m_uuid |
UUID used to identify the object, notably for serialization. | |
Protected Attributes inherited from fwCom::HasSignals | |
Signals | m_signals |
Friends | |
template<class , class , class > | |
class | ::fwTools::ClassFactory |
class | ::fwTools::Factory |
Demangling methods | |
virtual const std::string & | getLeafClassname () const override |
return object's classname without its namespace, i.e. BaseObject | |
virtual const std::string & | getClassname () const override |
return full object's classname with its namespace, i.e. fwCore::BaseObject | |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
Additional Inherited Members | |
Protected Types inherited from fwTools::fwID | |
enum | Policy { EMPTY = 1, GENERATE, MUST_EXIST } |
typedef std::string | IDType |
Protected Member Functions inherited from fwData::Object | |
FWDATA_API void | fieldDeepCopy (const ::fwData::Object::csptr &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
virtual FWDATA_API void | cachedDeepCopy (const ::fwData::Object::csptr &source, DeepCopyCacheType &cache)=0 |
Internal-use methods to implement Object's deepCopy. | |
Protected Member Functions inherited from fwTools::fwID | |
FWTOOLS_API bool | hasID () const |
Return true if the object has an id set. More... | |
FWTOOLS_API IDType | getID (Policy policy=GENERATE) const |
Returns the id of the object. If it is not set and the policy value is. More... | |
virtual FWTOOLS_API void | setID (IDType newID) |
Set a newID for the object, (newID must not exist in fwID), the oldest one is released. More... | |
FWTOOLS_API void | resetID () |
Release the id for the object. More... | |
fwID () | |
Constructor : does nothing. | |
Protected Member Functions inherited from fwCom::HasSignals | |
HasSignals (const HasSignals &) | |
Copy constructor forbidden. | |
HasSignals & | operator= (const HasSignals &) |
Copy operator forbidden. | |
Static Protected Member Functions inherited from fwData::Object | |
static FWDATA_API::fwData::Object::sptr | copy (const ::fwData::Object::csptr &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< const DATA_TYPE > &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< DATA_TYPE > &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
Static Protected Member Functions inherited from fwTools::fwID | |
static bool | isTypeOf (const std::string &type) |
static FWTOOLS_API bool | exist (IDType _id) |
static FWTOOLS_API std::shared_ptr< ::fwTools::Object > | getObject (IDType requestID) |
Retrieve the object attached to the given id. Return a null sptr if no correspondence exist. More... | |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
This class defines a graph object.
A graph is represented by connections between Edge and Node.
Definition at line 29 of file fwData/include/fwData/Graph.hpp.
fwData::Graph::Graph | ( | ::fwData::Object::Key | key | ) |
Constructor.
key | Private construction key |
Definition at line 33 of file fwData/src/fwData/Graph.cpp.
References m_sigUpdated, and s_UPDATED_SIG.
bool fwData::Graph::addEdge | ( | Edge::sptr | _edge, |
Node::csptr | _nodeSource, | ||
Node::csptr | _nodeDestination | ||
) |
Add and edge.
Definition at line 120 of file fwData/src/fwData/Graph.cpp.
Referenced by getConnections(), and makeConnection().
bool fwData::Graph::addNode | ( | Node::sptr | _node | ) |
add a node
Definition at line 51 of file fwData/src/fwData/Graph.cpp.
Referenced by getConnections().
const Graph::ConnectionContainer & fwData::Graph::getConnections | ( | ) | const |
Get the connection container.
A connection is defined by an edge, a source node and a destination node.
Definition at line 307 of file fwData/src/fwData/Graph.cpp.
References addEdge(), addNode(), fwData::Object::copy(), fwData::Object::fieldDeepCopy(), fwData::Object::fieldShallowCopy(), getClassname(), and OSLM_ASSERT.
Node::sptr fwData::Graph::getDestinationNode | ( | Edge::sptr | _edge | ) |
Get destination node.
[in] | _edge | edge associated with the node |
Definition at line 179 of file fwData/src/fwData/Graph.cpp.
References getNode().
std::vector< Edge::sptr > fwData::Graph::getEdges | ( | const Node::csptr & | _node, |
bool | _upStream, | ||
const std::string & | _nature = "" , |
||
const std::string & | _portID = "" |
||
) |
Get a vector of edges.
[in] | _node | node associated with the edges |
[in] | _upStream | if true _node is a source node, else _node is a destination node |
[in] | _nature | if nature is an empty string : no check on nature of edge |
[in] | _portID | if portID not specified (no check) : porID must be an BoolupStream port of given node |
Definition at line 223 of file fwData/src/fwData/Graph.cpp.
References SLM_ASSERT.
Referenced by getInputEdges(), getNodes(), and getOutputEdges().
std::vector< Edge::sptr > fwData::Graph::getInputEdges | ( | Node::csptr | _node | ) |
Get input edges.
[in] | _node | source node |
Definition at line 209 of file fwData/src/fwData/Graph.cpp.
References getEdges().
size_t fwData::Graph::getNbEdges | ( | ) | const |
Definition at line 300 of file fwData/src/fwData/Graph.cpp.
size_t fwData::Graph::getNbNodes | ( | ) | const |
Definition at line 293 of file fwData/src/fwData/Graph.cpp.
Node::sptr fwData::Graph::getNode | ( | Edge::sptr | _edge, |
bool | _upStream | ||
) |
Get node.
[in] | _edge | edge associated with the node |
[in] | _upStream | if true return source node, else return destination node |
Definition at line 186 of file fwData/src/fwData/Graph.cpp.
Referenced by getDestinationNode(), and getSourceNode().
std::vector<::fwData::Node::sptr > fwData::Graph::getNodes | ( | const ::fwData::Node::csptr & | node, |
bool | upStream, | ||
const std::string & | nature = "" , |
||
const std::string & | portID = "" |
||
) |
Get a vector of nodes.
[in] | node | node associated with the nodes |
[in] | upStream | if true _node is a source node, else _node is a destination node |
[in] | nature | if nature is an empty string : no check on nature of edge |
[in] | portID | if portID not specified (no check) : porID muts be an BoolupStream port of given node |
Definition at line 268 of file fwData/src/fwData/Graph.cpp.
References getEdges().
std::vector< Edge::sptr > fwData::Graph::getOutputEdges | ( | Node::csptr | _node | ) |
Get output edges.
[in] | _node | destination node |
Definition at line 216 of file fwData/src/fwData/Graph.cpp.
References getEdges().
Node::sptr fwData::Graph::getSourceNode | ( | Edge::sptr | _edge | ) |
Get source node.
[in] | _edge | edge associated with the node |
Definition at line 172 of file fwData/src/fwData/Graph.cpp.
References getNode().
bool fwData::Graph::haveConnectedEdges | ( | Node::csptr | _node | ) | const |
Check if an edge is connected to the node.
Definition at line 84 of file fwData/src/fwData/Graph.cpp.
Referenced by removeNode().
Edge::sptr fwData::Graph::makeConnection | ( | Node::csptr | _nodeSource, |
std::string | _nodeSourceOutputPortID, | ||
Node::csptr | _nodeDestination, | ||
std::string | _nodeDestinationInputPortID, | ||
std::string | _EdgeNature | ||
) |
create an edge from given info and add edge in the graph
Definition at line 98 of file fwData/src/fwData/Graph.cpp.
References addEdge().
bool fwData::Graph::removeEdge | ( | Edge::sptr | _edge | ) |
remove an edge
[in] | _edge | edge to be remove |
Definition at line 165 of file fwData/src/fwData/Graph.cpp.
bool fwData::Graph::removeNode | ( | Node::csptr | _node | ) |
remove a node
Definition at line 58 of file fwData/src/fwData/Graph.cpp.
References haveConnectedEdges().