35 |
35 |
36 /// \note Because Node and Edge are forbidden to inherit from the same |
36 /// \note Because Node and Edge are forbidden to inherit from the same |
37 /// base class, this is a template. For Node you should instantiate it |
37 /// base class, this is a template. For Node you should instantiate it |
38 /// with character 'n' and for Edge with 'e'. |
38 /// with character 'n' and for Edge with 'e'. |
39 |
39 |
40 template<char Ch> |
40 template<char _selector> |
41 class GraphItem { |
41 class GraphItem { |
42 public: |
42 public: |
|
43 /// Default constructor. |
|
44 |
|
45 /// @warning The default constructor sets the item |
|
46 /// to an undefined value. |
43 GraphItem() {} |
47 GraphItem() {} |
|
48 /// Copy constructor. |
|
49 |
|
50 /// Copy constructor. |
|
51 /// |
|
52 GraphItem(GraphItem const&) {} |
|
53 /// Invalid constructor \& conversion. |
|
54 |
|
55 /// This constructor initializes the item to be invalid. |
|
56 /// \sa Invalid for more details. |
44 GraphItem(Invalid) {} |
57 GraphItem(Invalid) {} |
45 |
58 /// Assign operator for nodes. |
46 // We explicitely list these: |
59 |
47 GraphItem(GraphItem const&) {} |
60 /// The nodes are assignable. |
|
61 /// |
48 GraphItem& operator=(GraphItem const&) { return *this; } |
62 GraphItem& operator=(GraphItem const&) { return *this; } |
49 |
63 /// Equality operator. |
|
64 |
|
65 /// Two iterators are equal if and only if they represents the |
|
66 /// same node in the graph or both are invalid. |
50 bool operator==(GraphItem) const { return false; } |
67 bool operator==(GraphItem) const { return false; } |
|
68 /// Inequality operator. |
|
69 |
|
70 /// \sa operator==(const Node& n) |
|
71 /// |
51 bool operator!=(GraphItem) const { return false; } |
72 bool operator!=(GraphItem) const { return false; } |
52 |
73 |
53 // Technical requirement. Do we really need this? |
74 // Technical requirement. Do we really need this? |
54 bool operator<(GraphItem) const { return false; } |
75 // bool operator<(GraphItem) const { return false; } |
55 }; |
76 |
56 |
77 |
57 |
78 template<typename _GraphItem> |
58 template<typename GI> |
79 struct Constraints { |
59 struct GraphItemConcept { |
80 void constraints() { |
60 void constraints() { |
81 _GraphItem i1; |
61 GI i1; |
82 _GraphItem i2 = i1; |
62 GI i2 = i1; |
83 _GraphItem i3 = INVALID; |
63 GI i3 = INVALID; |
84 |
64 |
85 i1 = i2 = i3; |
65 i1 = i2 = i3; |
86 |
66 |
87 bool b; |
67 bool b; |
88 // b = (ia == ib) && (ia != ib) && (ia < ib); |
68 b = (ia == ib) && (ia != ib) && (ia < ib); |
89 b = (ia == ib) && (ia != ib); |
69 b = (ia == INVALID) && (ib != INVALID); |
90 b = (ia == INVALID) && (ib != INVALID); |
70 } |
91 } |
71 |
92 |
72 const GI &ia; |
93 const _GraphItem &ia; |
73 const GI &ib; |
94 const _GraphItem &ib; |
74 }; |
95 }; |
75 |
96 }; |
76 |
|
77 template<typename Iter, typename Graph, typename BaseItem> |
|
78 struct GraphIteratorConcept { |
|
79 void constraints() { |
|
80 function_requires< GraphItemConcept<Iter> >(); |
|
81 Iter it1(g); |
|
82 |
|
83 /// \todo Do we need NodeIt(Node) kind of constructor? |
|
84 // Iter it2(bj); |
|
85 Iter it2; |
|
86 |
|
87 it2 = ++it1; |
|
88 ++it2 = it1; |
|
89 ++(++it1); |
|
90 /// \bug This should be: is_base_and_derived<BaseItem, Iter> |
|
91 BaseItem bi = it1; |
|
92 bi = it2; |
|
93 } |
|
94 |
|
95 BaseItem bj; |
|
96 Graph g; |
|
97 }; |
|
98 |
|
99 template<typename Iter, typename Graph> |
|
100 struct GraphIncIteratorConcept { |
|
101 typedef typename Graph::Node Node; |
|
102 typedef typename Graph::Edge Edge; |
|
103 void constraints() { |
|
104 function_requires< GraphItemConcept<Iter> >(); |
|
105 Iter it1(graph, node); |
|
106 /// \todo Do we need OutEdgeIt(Edge) kind of constructor? |
|
107 // Iter it2(edge); |
|
108 Iter it2; |
|
109 |
|
110 it2 = ++it1; |
|
111 ++it2 = it1; |
|
112 ++(++it1); |
|
113 Edge e = it1; |
|
114 e = it2; |
|
115 } |
|
116 |
|
117 Edge edge; |
|
118 Node node; |
|
119 Graph graph; |
|
120 }; |
|
121 |
|
122 |
|
123 |
97 |
124 /// An empty base graph class. |
98 /// An empty base graph class. |
125 |
99 |
126 /// This class provides the minimal set of features needed for a graph |
100 /// This class provides the minimal set of features needed for a graph |
127 /// structure. All graph concepts have to be conform to this base |
101 /// structure. All graph concepts have to be conform to this base |
137 |
111 |
138 /// Node class of the graph. |
112 /// Node class of the graph. |
139 |
113 |
140 /// This class represents the Nodes of the graph. |
114 /// This class represents the Nodes of the graph. |
141 /// |
115 /// |
142 class Node { |
116 typedef GraphItem<'n'> Node; |
143 public: |
|
144 |
|
145 /// Default constructor. |
|
146 |
|
147 /// @warning The default constructor sets the iterator |
|
148 /// to an undefined value. |
|
149 |
|
150 Node() {} |
|
151 /// Copy constructor. |
|
152 |
|
153 /// Copy constructor. |
|
154 /// |
|
155 Node(const Node&) {} |
|
156 |
|
157 /// Invalid constructor \& conversion. |
|
158 |
|
159 /// This constructor initializes the iterator to be invalid. |
|
160 /// \sa Invalid for more details. |
|
161 Node(Invalid) {} |
|
162 |
|
163 |
|
164 /// Assign operator for nodes. |
|
165 |
|
166 /// The nodes are assignable. |
|
167 /// |
|
168 Node& operator=(const Node&) { return *this;} |
|
169 |
|
170 /// Equality operator. |
|
171 |
|
172 /// Two iterators are equal if and only if they represents the |
|
173 /// same node in the graph or both are invalid. |
|
174 bool operator==(const Node&) const { return true;} |
|
175 |
|
176 |
|
177 /// Inequality operator. |
|
178 |
|
179 /// \sa operator==(const Node& n) |
|
180 /// |
|
181 bool operator!=(const Node&) const { return true;} |
|
182 |
|
183 /// Comparison operator. |
|
184 |
|
185 /// This is a strict ordering between the nodes. |
|
186 /// |
|
187 /// This ordering can be different from the iterating order of nodes. |
|
188 /// \todo Possibly we don't need it. |
|
189 bool operator<(const Node&) const { return true;} |
|
190 }; |
|
191 |
117 |
192 /// Edge class of the graph. |
118 /// Edge class of the graph. |
193 |
119 |
194 /// This class represents the Edges of the graph. |
120 /// This class represents the Edges of the graph. |
195 /// |
121 /// |
196 class Edge { |
122 typedef GraphItem<'e'> Edge; |
197 public: |
|
198 |
|
199 /// Default constructor. |
|
200 |
|
201 /// @warning The default constructor sets the iterator |
|
202 /// to an undefined value. |
|
203 |
|
204 Edge() {} |
|
205 /// Copy constructor. |
|
206 |
|
207 /// Copy constructor. |
|
208 /// |
|
209 Edge(const Edge&) {} |
|
210 |
|
211 /// Invalid constructor \& conversion. |
|
212 |
|
213 /// This constructor initializes the iterator to be invalid. |
|
214 /// \sa Invalid for more details. |
|
215 Edge(Invalid) {} |
|
216 |
|
217 /// Assign operator for edges. |
|
218 |
|
219 /// The edges are assignable. |
|
220 /// |
|
221 Edge& operator=(const Edge&) { return *this;} |
|
222 |
|
223 /// Equality operator. |
|
224 |
|
225 /// Two iterators are equal if and only if they represents the |
|
226 /// same edge in the graph or both are invalid. |
|
227 bool operator==(const Edge&) const { return true;} |
|
228 |
|
229 |
|
230 /// Inequality operator. |
|
231 |
|
232 /// \sa operator==(const Edge& n) |
|
233 /// |
|
234 bool operator!=(const Edge&) const { return true;} |
|
235 |
|
236 /// Comparison operator. |
|
237 |
|
238 /// This is a strict ordering between the edges. |
|
239 /// |
|
240 /// This ordering can be different from the iterating order of edges. |
|
241 /// \todo Possibly we don't need it. |
|
242 bool operator<(const Edge&) const { return true;} |
|
243 }; |
|
244 |
123 |
245 ///Gives back the target node of an edge. |
124 ///Gives back the target node of an edge. |
246 |
125 |
247 ///Gives back the target node of an edge. |
126 ///Gives back the target node of an edge. |
248 /// |
127 /// |
562 /// Erase all the Nodes and Edges from the graph. |
412 /// Erase all the Nodes and Edges from the graph. |
563 |
413 |
564 /// Erase all the Nodes and Edges from the graph. |
414 /// Erase all the Nodes and Edges from the graph. |
565 /// |
415 /// |
566 void clear() {} |
416 void clear() {} |
567 }; |
417 |
568 |
418 template <typename _Graph> |
569 /// Concept check function for ErasableBaseGraph. |
419 struct Constraints { |
570 |
420 void constraints() { |
571 /// Concept check function for ErasableBaseGraph. |
421 checkConcept< BaseGraphComponent, _Graph>(); |
|
422 graph.clear(); |
|
423 } |
|
424 |
|
425 _Graph& graph; |
|
426 }; |
|
427 }; |
|
428 |
|
429 |
|
430 /// Skeleton class for graph NodeIt and EdgeIt |
|
431 |
|
432 /// Skeleton class for graph NodeIt and EdgeIt. |
572 /// |
433 /// |
573 template <typename Graph> |
434 template <typename _Graph, typename _Item> |
574 struct BaseClearableGraphComponentConcept { |
435 class GraphIterator : public _Item { |
575 void constraints() { |
436 public: |
576 function_requires< BaseGraphComponentConcept<Graph> >(); |
437 /// \todo Don't we need the Item type as typedef? |
577 graph.clear(); |
438 |
578 } |
439 /// Default constructor. |
579 |
440 |
580 Graph& graph; |
441 /// @warning The default constructor sets the iterator |
581 }; |
442 /// to an undefined value. |
582 |
443 GraphIterator() {} |
583 |
444 /// Copy constructor. |
584 class IterableGraphComponent : |
445 |
585 virtual public BaseIterableGraphComponent { |
446 /// Copy constructor. |
|
447 /// |
|
448 GraphIterator(GraphIterator const&) {} |
|
449 /// Sets the iterator to the first item. |
|
450 |
|
451 /// Sets the iterator to the first item of \c the graph. |
|
452 /// |
|
453 explicit GraphIterator(const _Graph&) {} |
|
454 /// Invalid constructor \& conversion. |
|
455 |
|
456 /// This constructor initializes the item to be invalid. |
|
457 /// \sa Invalid for more details. |
|
458 GraphIterator(Invalid) {} |
|
459 /// Assign operator for items. |
|
460 |
|
461 /// The items are assignable. |
|
462 /// |
|
463 GraphIterator& operator=(GraphIterator const&) { return *this; } |
|
464 /// Next item. |
|
465 |
|
466 /// Assign the iterator to the next item. |
|
467 /// |
|
468 GraphIterator& operator++() { return *this; } |
|
469 // Node operator*() const { return INVALID; } |
|
470 /// Equality operator |
|
471 |
|
472 /// Two iterators are equal if and only if they point to the |
|
473 /// same object or both are invalid. |
|
474 bool operator==(const GraphIterator&) const { return true;} |
|
475 /// Inequality operator |
|
476 |
|
477 /// \sa operator==(Node n) |
|
478 /// |
|
479 bool operator!=(const GraphIterator&) const { return true;} |
|
480 |
|
481 template<typename _GraphIterator> |
|
482 struct Constraints { |
|
483 void constraints() { |
|
484 // checkConcept< Item, _GraphIterator >(); |
|
485 _GraphIterator it1(g); |
|
486 |
|
487 /// \todo Do we need NodeIt(Node) kind of constructor? |
|
488 // _GraphIterator it2(bj); |
|
489 _GraphIterator it2; |
|
490 |
|
491 it2 = ++it1; |
|
492 ++it2 = it1; |
|
493 ++(++it1); |
|
494 /// \bug This should be: is_base_and_derived<BaseItem, _GraphIterator> |
|
495 _Item bi = it1; |
|
496 bi = it2; |
|
497 } |
|
498 _Graph& g; |
|
499 }; |
|
500 }; |
|
501 |
|
502 /// Skeleton class for graph InEdgeIt and OutEdgeIt |
|
503 |
|
504 /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same |
|
505 /// base class, the _selector is a additional template parameter. For |
|
506 /// InEdgeIt you should instantiate it with character 'i' and for |
|
507 /// OutEdgeIt with 'o'. |
|
508 /// \todo check the name of the concept GraphIncEdgeIterator |
|
509 template <typename _Graph, char _selector> |
|
510 class GraphIncEdgeIterator : public _Graph::Edge { |
|
511 public: |
|
512 /// Default constructor. |
|
513 |
|
514 /// @warning The default constructor sets the iterator |
|
515 /// to an undefined value. |
|
516 GraphIncEdgeIterator() {} |
|
517 /// Copy constructor. |
|
518 |
|
519 /// Copy constructor. |
|
520 /// |
|
521 GraphIncEdgeIterator(GraphIncEdgeIterator const&) {} |
|
522 /// Sets the iterator to the first edge incoming into or outgoing from the node. |
|
523 |
|
524 /// Sets the iterator to the first edge incoming into or outgoing from the node. |
|
525 /// |
|
526 explicit GraphIncEdgeIterator(const _Graph&, const typename _Graph::Node&) {} |
|
527 /// Invalid constructor \& conversion. |
|
528 |
|
529 /// This constructor initializes the item to be invalid. |
|
530 /// \sa Invalid for more details. |
|
531 GraphIncEdgeIterator(Invalid) {} |
|
532 /// Assign operator for nodes. |
|
533 |
|
534 /// The nodes are assignable. |
|
535 /// |
|
536 GraphIncEdgeIterator& operator=(GraphIncEdgeIterator const&) { return *this; } |
|
537 /// Next edge. |
|
538 |
|
539 /// Assign the iterator to the next node. |
|
540 /// |
|
541 GraphIncEdgeIterator& operator++() { return *this; } |
|
542 // Node operator*() const { return INVALID; } |
|
543 /// Equality operator |
|
544 |
|
545 /// Two iterators are equal if and only if they point to the |
|
546 /// same object or both are invalid. |
|
547 bool operator==(const GraphIncEdgeIterator&) const { return true;} |
|
548 /// Inequality operator |
|
549 |
|
550 /// \sa operator==(Node n) |
|
551 /// |
|
552 bool operator!=(const GraphIncEdgeIterator&) const { return true;} |
|
553 |
|
554 template <typename _GraphIncEdgeIterator> |
|
555 struct Constraints { |
|
556 typedef typename _Graph::Node Node; |
|
557 typedef typename _Graph::Edge Edge; |
|
558 void constraints() { |
|
559 checkConcept<GraphItem<'e'>, _GraphIncEdgeIterator>(); |
|
560 _GraphIncEdgeIterator it1(graph, node); |
|
561 /// \todo Do we need OutEdgeIt(Edge) kind of constructor? |
|
562 // _GraphIncEdgeIterator it2(edge); |
|
563 _GraphIncEdgeIterator it2; |
|
564 |
|
565 it2 = ++it1; |
|
566 ++it2 = it1; |
|
567 ++(++it1); |
|
568 Edge e = it1; |
|
569 e = it2; |
|
570 } |
|
571 |
|
572 Edge& edge; |
|
573 Node& node; |
|
574 _Graph& graph; |
|
575 }; |
|
576 }; |
|
577 /// An empty iterable base graph class. |
|
578 |
|
579 /// This class provides beside the core graph features |
|
580 /// iterator based iterable interface for the graph structure. |
|
581 /// This concept is part of the StaticGraphConcept. |
|
582 class IterableGraphComponent : virtual public BaseGraphComponent { |
586 |
583 |
587 public: |
584 public: |
588 |
585 |
589 typedef IterableGraphComponent Graph; |
586 typedef IterableGraphComponent Graph; |
590 |
587 |
591 typedef BaseGraphComponent::Node Node; |
588 typedef BaseGraphComponent::Node Node; |
592 typedef BaseGraphComponent::Edge Edge; |
589 typedef BaseGraphComponent::Edge Edge; |
593 |
590 |
594 class NodeIt : public Node { |
591 /// This iterator goes through each node. |
595 public: |
592 |
596 NodeIt() {} |
593 /// This iterator goes through each node. |
597 NodeIt(Invalid) {} |
594 /// |
598 // explicit NodeIt(Node) {} |
595 typedef GraphIterator<Graph, Node> NodeIt; |
599 explicit NodeIt(const Graph&) {} |
596 /// This iterator goes through each node. |
600 |
597 |
601 NodeIt& operator++() { return *this; } |
598 /// This iterator goes through each node. |
602 // Node operator*() const { return INVALID; } |
599 /// |
603 |
600 typedef GraphIterator<Graph, Edge> EdgeIt; |
604 bool operator==(const NodeIt&) const { return true;} |
601 /// This iterator goes trough the incoming edges of a node. |
605 bool operator!=(const NodeIt&) const { return true;} |
602 |
606 }; |
603 /// This iterator goes trough the \e inccoming edges of a certain node |
607 |
604 /// of a graph. |
608 class EdgeIt : public Edge { |
605 typedef GraphIncEdgeIterator<Graph, 'i'> InEdgeIt; |
609 public: |
606 /// This iterator goes trough the outgoing edges of a node. |
610 EdgeIt() {} |
607 |
611 EdgeIt(Invalid) {} |
608 /// This iterator goes trough the \e outgoing edges of a certain node |
612 // explicit EdgeIt(Edge) {} |
609 /// of a graph. |
613 explicit EdgeIt(const Graph&) {} |
610 typedef GraphIncEdgeIterator<Graph, 'o'> OutEdgeIt; |
614 |
|
615 EdgeIt& operator++() { return *this; } |
|
616 // Edge operator*() const { return INVALID; } |
|
617 |
|
618 bool operator==(const EdgeIt&) const { return true;} |
|
619 bool operator!=(const EdgeIt&) const { return true;} |
|
620 }; |
|
621 |
|
622 class InEdgeIt : public Edge { |
|
623 public: |
|
624 InEdgeIt() {} |
|
625 InEdgeIt(Invalid) {} |
|
626 // explicit InEdgeIt(Edge) {} |
|
627 explicit InEdgeIt(const Graph&, const Node&) {} |
|
628 |
|
629 InEdgeIt& operator++() { return *this; } |
|
630 // Edge operator*() const { return INVALID; } |
|
631 |
|
632 bool operator==(const InEdgeIt&) const { return true;} |
|
633 bool operator!=(const InEdgeIt&) const { return true;} |
|
634 }; |
|
635 |
|
636 class OutEdgeIt : public Edge { |
|
637 public: |
|
638 OutEdgeIt() {} |
|
639 OutEdgeIt(Invalid) {} |
|
640 // explicit OutEdgeIt(Edge) {} |
|
641 explicit OutEdgeIt(const Graph&, const Node&) {} |
|
642 |
|
643 OutEdgeIt& operator++() { return *this; } |
|
644 // Edge operator*() const { return INVALID; } |
|
645 |
|
646 bool operator==(const OutEdgeIt&) const { return true;} |
|
647 bool operator!=(const OutEdgeIt&) const { return true;} |
|
648 }; |
|
649 |
|
650 }; |
611 }; |
651 |
612 |
652 template <typename Graph> |
613 template <typename _Graph> |
653 struct IterableGraphComponentConcept { |
614 struct Constraints { |
654 void constraints() { |
615 void constraints() { |
655 function_requires< BaseIterableGraphComponentConcept<Graph> >(); |
616 checkConcept< BaseGraphComponent, _Graph>(); |
656 |
617 |
657 typedef typename Graph::Node Node; |
618 checkConcept<GraphIterator<_Graph, typename _Graph::Edge>, typename _Graph::EdgeIt >(); |
658 typedef typename Graph::NodeIt NodeIt; |
619 checkConcept<GraphIterator<_Graph, typename _Graph::Node>, typename _Graph::NodeIt >(); |
659 typedef typename Graph::Edge Edge; |
620 checkConcept<GraphIncEdgeIterator<_Graph, 'i'>, typename _Graph::InEdgeIt >(); |
660 typedef typename Graph::EdgeIt EdgeIt; |
621 checkConcept<GraphIncEdgeIterator<_Graph, 'o'>, typename _Graph::OutEdgeIt >(); |
661 typedef typename Graph::InEdgeIt InEdgeIt; |
622 } |
662 typedef typename Graph::OutEdgeIt OutEdgeIt; |
623 }; |
|
624 |
|
625 |
|
626 template <typename Graph, typename Item, typename _Value> |
|
627 class GraphMap : public ReadWriteMap<Item, _Value> { |
|
628 protected: |
|
629 GraphMap() {} |
|
630 public: |
|
631 explicit GraphMap(const Graph&) {} |
|
632 GraphMap(const Graph&, const _Value&) {} |
|
633 GraphMap(const GraphMap&) {} |
|
634 |
|
635 GraphMap& operator=(const GraphMap&) { return *this;} |
|
636 |
|
637 template<typename _Map> |
|
638 struct Constraints { |
|
639 void constraints() { |
|
640 checkConcept<ReadWriteMap<Item, _Value>, _Map >(); |
|
641 // Construction with a graph parameter |
|
642 _Map a(g); |
|
643 // Constructor with a graph and a default value parameter |
|
644 _Map a2(g,t); |
|
645 // Copy constructor. Do we need it? |
|
646 _Map b=c; |
|
647 // Copy operator. Do we need it? |
|
648 a=b; |
|
649 |
|
650 ignore_unused_variable_warning(a2); |
|
651 } |
|
652 |
|
653 const _Map &c; |
|
654 const Graph &g; |
|
655 const typename GraphMap::Value &t; |
|
656 }; |
|
657 |
|
658 }; |
|
659 |
|
660 /// An empty mappable base graph class. |
663 |
661 |
664 function_requires< GraphIteratorConcept<NodeIt, Graph, Node> >(); |
662 /// This class provides beside the core graph features |
665 function_requires< GraphIteratorConcept<EdgeIt, Graph, Edge> >(); |
663 /// map interface for the graph structure. |
666 function_requires< GraphIncIteratorConcept<OutEdgeIt, Graph> >(); |
664 /// This concept is part of the StaticGraphConcept. |
667 function_requires< GraphIncIteratorConcept<InEdgeIt, Graph> >(); |
|
668 } |
|
669 }; |
|
670 |
|
671 |
|
672 class MappableGraphComponent : virtual public BaseGraphComponent { |
665 class MappableGraphComponent : virtual public BaseGraphComponent { |
673 public: |
666 public: |
674 |
667 |
675 typedef MappableGraphComponent Graph; |
668 typedef MappableGraphComponent Graph; |
676 |
669 |
677 typedef BaseGraphComponent::Node Node; |
670 typedef BaseGraphComponent::Node Node; |
678 typedef BaseGraphComponent::Edge Edge; |
671 typedef BaseGraphComponent::Edge Edge; |
679 |
672 |
|
673 /// ReadWrite map of the nodes. |
|
674 |
|
675 /// ReadWrite map of the nodes. |
|
676 /// |
680 template <typename _Value> |
677 template <typename _Value> |
681 class NodeMap : public ReferenceMap<Node, _Value> { |
678 class NodeMap : public GraphMap<Graph, Node, _Value> { |
|
679 private: |
|
680 NodeMap(); |
682 public: |
681 public: |
683 NodeMap(const Graph&) {} |
682 // \todo call the right parent class constructor |
|
683 explicit NodeMap(const Graph&) {} |
684 NodeMap(const Graph&, const _Value&) {} |
684 NodeMap(const Graph&, const _Value&) {} |
685 NodeMap(const NodeMap&) {} |
685 NodeMap(const NodeMap&) {} |
686 |
686 |
687 NodeMap& operator=(const NodeMap&) { return *this;} |
687 NodeMap& operator=(const NodeMap&) { return *this;} |
688 |
688 |
689 }; |
689 }; |
690 |
690 |
|
691 /// ReadWrite map of the edges. |
|
692 |
|
693 /// ReadWrite map of the edges. |
|
694 /// |
691 template <typename _Value> |
695 template <typename _Value> |
692 class EdgeMap : public ReferenceMap<Edge, _Value> { |
696 class EdgeMap : public GraphMap<Graph, Edge, _Value> { |
|
697 private: |
|
698 EdgeMap(); |
693 public: |
699 public: |
694 EdgeMap(const Graph&) {} |
700 // \todo call the right parent class constructor |
|
701 explicit EdgeMap(const Graph&) {} |
695 EdgeMap(const Graph&, const _Value&) {} |
702 EdgeMap(const Graph&, const _Value&) {} |
696 EdgeMap(const EdgeMap&) {} |
703 EdgeMap(const EdgeMap&) {} |
697 |
704 |
698 EdgeMap& operator=(const EdgeMap&) { return *this;} |
705 EdgeMap& operator=(const EdgeMap&) { return *this;} |
699 |
706 |
700 }; |
707 }; |
701 |
708 |
702 }; |
709 template <typename _Graph> |
703 |
710 struct Constraints { |
704 template <typename Graph> |
711 |
705 struct MappableGraphComponentConcept { |
712 struct Type { |
706 |
713 int value; |
707 struct Type { |
714 Type() : value(0) {} |
708 int value; |
715 Type(int _v) : value(_v) {} |
709 Type() : value(0) {} |
716 }; |
710 Type(int _v) : value(_v) {} |
717 |
711 }; |
718 void constraints() { |
712 |
719 checkConcept<BaseGraphComponent, _Graph>(); |
713 void constraints() { |
720 { // int map test |
714 function_requires< BaseGraphComponentConcept<Graph> >(); |
721 typedef typename _Graph::template NodeMap<int> IntNodeMap; |
715 { // int map test |
722 checkConcept<GraphMap<_Graph, typename _Graph::Node, int>, IntNodeMap >(); |
716 typedef typename Graph::template NodeMap<int> IntNodeMap; |
723 } { // bool map test |
717 function_requires<GraphMapConcept<IntNodeMap,Graph> >(); |
724 typedef typename _Graph::template NodeMap<bool> BoolNodeMap; |
718 } { // bool map test |
725 checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>, BoolNodeMap >(); |
719 typedef typename Graph::template NodeMap<bool> BoolNodeMap; |
726 } { // Type map test |
720 function_requires<GraphMapConcept<BoolNodeMap,Graph> >(); |
727 typedef typename _Graph::template NodeMap<Type> TypeNodeMap; |
721 } { // Type map test |
728 checkConcept<GraphMap<_Graph, typename _Graph::Node, Type>, TypeNodeMap >(); |
722 typedef typename Graph::template NodeMap<Type> TypeNodeMap; |
729 } |
723 function_requires<GraphMapConcept<TypeNodeMap,Graph> >(); |
730 |
724 } |
731 { // int map test |
725 |
732 typedef typename _Graph::template EdgeMap<int> IntEdgeMap; |
726 { // int map test |
733 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>, IntEdgeMap >(); |
727 typedef typename Graph::template EdgeMap<int> IntEdgeMap; |
734 } { // bool map test |
728 function_requires<GraphMapConcept<IntEdgeMap,Graph> >(); |
735 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap; |
729 } { // bool map test |
736 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>, BoolEdgeMap >(); |
730 typedef typename Graph::template EdgeMap<bool> BoolEdgeMap; |
737 } { // Type map test |
731 function_requires<GraphMapConcept<BoolEdgeMap,Graph> >(); |
738 typedef typename _Graph::template EdgeMap<Type> TypeEdgeMap; |
732 } { // Type map test |
739 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Type>, TypeEdgeMap >(); |
733 typedef typename Graph::template EdgeMap<Type> TypeEdgeMap; |
740 } |
734 function_requires<GraphMapConcept<TypeEdgeMap,Graph> >(); |
741 } |
735 } |
742 |
736 } |
743 _Graph& graph; |
737 |
744 }; |
738 Graph& graph; |
|
739 }; |
745 }; |
740 |
746 |
741 |
747 |
742 class ExtendableGraphComponent : virtual public BaseGraphComponent { |
748 class ExtendableGraphComponent : virtual public BaseGraphComponent { |
743 public: |
749 public: |