5 #ifndef BPP_GRAPH_ASSOCIATIONGRAPHOBSERVER_H 6 #define BPP_GRAPH_ASSOCIATIONGRAPHOBSERVER_H 12 #include <type_traits> 15 #include "../Clonable.h" 16 #include "../Exceptions.h" 28 template<
class N,
class E>
44 template<
class A,
class B>
45 static B*
copy(
const A& a,
typename std::enable_if< !std::is_base_of<B, A>::value && !std::is_abstract<B>::value, B*>::type* = 0)
50 template<
class A,
class B>
51 static B*
copy(
const A& a,
typename std::enable_if< !std::is_base_of<B, A>::value && std::is_abstract<B>::value, B*>::type* = 0)
53 throw Exception(
"Unknow AssociationGraphObserver::copy(const A& a, typename std::enable_if< !std::is_base_of<B, A>::value&& std::is_abstract<B>::value, B*>::type* = 0)");
57 template<
class A,
class B>
58 static B*
copy(
const A& a,
typename std::enable_if< std::is_base_of<B, A>::value && !std::is_abstract<A>::value, B*>::type* = 0)
60 return dynamic_cast<B*
>(
new A(a));
63 template<
class A,
class B>
64 static B*
copy(
const A& a,
typename std::enable_if< std::is_base_of<B, A>::value && std::is_abstract<A>::value && std::is_base_of<Clonable, A>::value, B*>::type* = 0)
66 return dynamic_cast<B*
>(a.clone());
69 template<
class A,
class B>
70 static B*
copy(
const A& a,
typename std::enable_if< std::is_base_of<B, A>::value && std::is_abstract<A>::value && !std::is_base_of<Clonable, A>::value, B*>::type* = 0)
72 throw Exception(
"Unknow AssociationGraphObserver::copy(const A& a, typename std::enable_if< std::is_base_of<B, A>::value&& std::is_abstract<A>::value && !std::is_base_of<Clonable, A>::value, B*>::type*= 0)");
87 virtual void createNode(std::shared_ptr<N> newNodeObject) = 0;
99 virtual void createNode(std::shared_ptr<N> objectOriginNode, std::shared_ptr<N> newNodeObject, std::shared_ptr<E> newEdgeObject = 00) = 0;
110 virtual void link(std::shared_ptr<N> nodeObjectA, std::shared_ptr<N> nodeObjectB, std::shared_ptr<E> edgeObject = 00) = 0;
119 virtual void unlink(std::shared_ptr<N> nodeObjectA, std::shared_ptr<N> nodeObjectB) = 0;
125 virtual void deleteNode(std::shared_ptr<N> nodeObject) = 0;
140 virtual void associateNode(std::shared_ptr<N> nodeObject, NodeGraphid node) = 0;
148 virtual void associateEdge(std::shared_ptr<E> edgeObject, EdgeGraphid edge) = 0;
166 virtual NodeGraphid
getNodeGraphid(
const std::shared_ptr<N> nodeObject)
const = 0;
173 virtual EdgeGraphid
getEdgeGraphid(
const std::shared_ptr<E> edgeObject)
const = 0;
181 virtual std::vector<std::shared_ptr<N>>
getNodesFromGraphid(std::vector<NodeGraphid> )
const = 0;
184 virtual std::vector<std::shared_ptr<E>>
getEdgesFromGraphid(std::vector<EdgeGraphid> )
const = 0;
191 virtual std::shared_ptr<N>
getRoot()
const = 0;
207 virtual bool hasNodeIndex(
const std::shared_ptr<N> nodeObject)
const = 0;
208 virtual bool hasEdgeIndex(
const std::shared_ptr<E> edgeObject)
const = 0;
216 virtual NodeIndex
getNodeIndex(
const std::shared_ptr<N> nodeObject)
const = 0;
217 virtual std::vector<NodeIndex>
getNodeIndexes(std::vector<std::shared_ptr<N>> nodeObjects)
const = 0;
225 virtual EdgeIndex
getEdgeIndex(
const std::shared_ptr<E> edgeObject)
const = 0;
226 virtual std::vector<EdgeIndex>
getEdgeIndexes(std::vector<std::shared_ptr<E>> edgeObjects)
const = 0;
234 virtual NodeIndex
setNodeIndex(
const std::shared_ptr<N> nodeObject, NodeIndex index) = 0;
242 virtual EdgeIndex
setEdgeIndex(
const std::shared_ptr<E> edgeObject, EdgeIndex index) = 0;
249 virtual bool hasNode(NodeIndex nodeIndex)
const = 0;
256 virtual bool hasEdge(EdgeIndex edgeIndex)
const = 0;
264 virtual std::shared_ptr<N>
getNode(NodeIndex nodeIndex)
const = 0;
271 virtual std::shared_ptr<E>
getEdge(EdgeIndex edgeIndex)
const = 0;
290 virtual void next() = 0;
291 virtual bool end()
const = 0;
292 virtual void start() = 0;
294 virtual std::shared_ptr<N>
operator*() = 0;
331 virtual std::vector<std::shared_ptr<N>>
getNeighbors(
const std::shared_ptr<N> node)
const = 0;
332 virtual std::vector<NodeIndex>
getNeighbors(NodeIndex node)
const = 0;
339 virtual std::vector<std::shared_ptr<E>>
getEdges(
const std::shared_ptr<N> node)
const = 0;
340 virtual std::vector<EdgeIndex>
getEdges(NodeIndex node)
const = 0;
348 virtual std::vector<std::shared_ptr<N>>
getOutgoingNeighbors(
const std::shared_ptr<N> node)
const = 0;
357 virtual std::vector<std::shared_ptr<E>>
getOutgoingEdges(
const std::shared_ptr<N> node)
const = 0;
367 virtual std::vector<std::shared_ptr<N>>
getIncomingNeighbors(
const std::shared_ptr<N> node)
const = 0;
376 virtual std::vector<std::shared_ptr<E>>
getIncomingEdges(
const std::shared_ptr<N> node)
const = 0;
387 virtual std::vector<std::shared_ptr<N>>
getLeavesFromNode(std::shared_ptr<N> node,
unsigned int maxDepth)
const = 0;
393 virtual std::vector<std::shared_ptr<N>>
getAllLeaves()
const = 0;
407 virtual std::vector<std::shared_ptr<N>>
getAllNodes()
const = 0;
420 virtual void next() = 0;
421 virtual bool end()
const = 0;
422 virtual void start() = 0;
424 virtual std::shared_ptr<E>
operator*() = 0;
454 virtual std::vector<std::shared_ptr<E>>
getAllEdges()
const = 0;
464 virtual std::shared_ptr<E>
getEdgeLinking(std::shared_ptr<N> nodeA, std::shared_ptr<N> nodeB)
const = 0;
472 virtual void setEdgeLinking(std::shared_ptr<N> nodeA, std::shared_ptr<N> nodeB, std::shared_ptr<E> edge) = 0;
477 #endif // BPP_GRAPH_ASSOCIATIONGRAPHOBSERVER_H
virtual std::unique_ptr< NodeIterator > incomingNeighborNodesIterator(std::shared_ptr< N > node)=0
virtual std::vector< std::shared_ptr< E > > getIncomingEdges(const std::shared_ptr< N > node) const =0
virtual std::vector< std::shared_ptr< N > > getNodesFromGraphid(std::vector< NodeGraphid >) const =0
Defines a Graph Associator. It is a template which follows (subscribed to) a Graph.
virtual std::vector< std::shared_ptr< N > > getLeavesFromNode(std::shared_ptr< N > node, unsigned int maxDepth) const =0
virtual std::vector< EdgeIndex > getAllEdgesIndexes() const =0
virtual std::unique_ptr< EdgeIterator > outgoingEdgesIterator(std::shared_ptr< N > node)=0
virtual std::vector< NodeIndex > getAllNodesIndexes() const =0
static B * copy(const A &a, typename std::enable_if< !std::is_base_of< B, A >::value &&std::is_abstract< B >::value, B *>::type *=0)
virtual std::shared_ptr< E > getEdgeFromGraphid(EdgeGraphid)=0
virtual std::vector< std::shared_ptr< N > > getAllInnerNodes() const =0
virtual EdgeIndex getEdgeIndex(const std::shared_ptr< E > edgeObject) const =0
virtual void unlink(std::shared_ptr< N > nodeObjectA, std::shared_ptr< N > nodeObjectB)=0
virtual std::vector< std::shared_ptr< E > > getAllEdges() const =0
static B * copy(const A &a, typename std::enable_if< std::is_base_of< B, A >::value &&std::is_abstract< A >::value &&std::is_base_of< Clonable, A >::value, B *>::type *=0)
virtual std::vector< std::shared_ptr< N > > getAllLeaves() const =0
virtual bool hasNode(NodeIndex nodeIndex) const =0
virtual EdgeGraphid getEdgeGraphid(const std::shared_ptr< E > edgeObject) const =0
virtual std::unique_ptr< EdgeIterator > allEdgesIterator()=0
virtual NodeGraphid getNodeGraphid(const std::shared_ptr< N > nodeObject) const =0
virtual void associateNode(std::shared_ptr< N > nodeObject, NodeGraphid node)=0
static B * copy(const A &a, typename std::enable_if< !std::is_base_of< B, A >::value &&!std::is_abstract< B >::value, B *>::type *=0)
virtual std::vector< std::shared_ptr< E > > getEdgesFromGraphid(std::vector< EdgeGraphid >) const =0
virtual void deleteNode(std::shared_ptr< N > nodeObject)=0
virtual bool hasNodeIndex(const std::shared_ptr< N > nodeObject) const =0
return if the object has an index.
virtual NodeIndex getNodeIndex(const std::shared_ptr< N > nodeObject) const =0
virtual std::vector< std::shared_ptr< N > > getAllNodes() const =0
Graph::NodeId NodeGraphid
virtual std::vector< EdgeIndex > getEdgeIndexes(std::vector< std::shared_ptr< E >> edgeObjects) const =0
virtual std::vector< std::shared_ptr< E > > getOutgoingEdges(const std::shared_ptr< N > node) const =0
virtual std::unique_ptr< NodeIterator > outgoingNeighborNodesIterator(std::shared_ptr< N > node)=0
virtual std::shared_ptr< N > operator*()=0
virtual void link(std::shared_ptr< N > nodeObjectA, std::shared_ptr< N > nodeObjectB, std::shared_ptr< E > edgeObject=00)=0
static B * copy(const A &a, typename std::enable_if< std::is_base_of< B, A >::value &&std::is_abstract< A >::value &&!std::is_base_of< Clonable, A >::value, B *>::type *=0)
virtual bool end() const =0
virtual std::unique_ptr< EdgeIterator > incomingEdgesIterator(std::shared_ptr< N > node)=0
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
virtual void dissociateNode(std::shared_ptr< N > nodeObject)=0
virtual std::unique_ptr< NodeIterator > allNodesIterator()=0
virtual std::shared_ptr< N > getRoot() const =0
virtual std::shared_ptr< E > getEdge(EdgeIndex edgeIndex) const =0
virtual EdgeIndex setEdgeIndex(const std::shared_ptr< E > edgeObject, EdgeIndex index)=0
virtual void setEdgeLinking(std::shared_ptr< N > nodeA, std::shared_ptr< N > nodeB, std::shared_ptr< E > edge)=0
virtual std::vector< std::shared_ptr< N > > getNeighbors(const std::shared_ptr< N > node) const =0
virtual NodeIndex setNodeIndex(const std::shared_ptr< N > nodeObject, NodeIndex index)=0
virtual const std::shared_ptr< N > getNodeFromGraphid(NodeGraphid) const =0
virtual std::shared_ptr< E > getEdgeLinking(std::shared_ptr< N > nodeA, std::shared_ptr< N > nodeB) const =0
static B * copy(const A &a, typename std::enable_if< std::is_base_of< B, A >::value &&!std::is_abstract< A >::value, B *>::type *=0)
virtual std::vector< std::shared_ptr< E > > getEdges(const std::shared_ptr< N > node) const =0
Graph::EdgeId EdgeGraphid
Defines a Graph Observer. It is a template which follows (subscribed to) a Graph. The graph and the g...
virtual std::vector< NodeIndex > getNodeIndexes(std::vector< std::shared_ptr< N >> nodeObjects) const =0
virtual std::vector< NodeIndex > getAllInnerNodesIndexes() const =0
virtual void createNode(std::shared_ptr< N > newNodeObject)=0
virtual bool hasEdgeIndex(const std::shared_ptr< E > edgeObject) const =0
virtual std::vector< std::shared_ptr< N > > getIncomingNeighbors(const std::shared_ptr< N > node) const =0
virtual void dissociateEdge(std::shared_ptr< E > edgeObject)=0
virtual NodeIndex getRootIndex() const =0
virtual void associateEdge(std::shared_ptr< E > edgeObject, EdgeGraphid edge)=0
virtual std::vector< std::shared_ptr< N > > getOutgoingNeighbors(const std::shared_ptr< N > node) const =0
virtual std::shared_ptr< N > getNode(NodeIndex nodeIndex) const =0
virtual bool hasEdge(EdgeIndex edgeIndex) const =0
virtual std::vector< NodeIndex > getAllLeavesIndexes() const =0