# HG changeset patch # User deba # Date 1141207487 0 # Node ID d276e88aa48afe37d3ad34ccbb1cb4787eb45e23 # Parent 875fe3f689e028e60429f3ee22dd7f1084a82f5d Traits for alteration notifiers SplitGraph is temporarly deleted diff -r 875fe3f689e0 -r d276e88aa48a lemon/bits/alteration_notifier.h --- a/lemon/bits/alteration_notifier.h Wed Mar 01 09:40:16 2006 +0000 +++ b/lemon/bits/alteration_notifier.h Wed Mar 01 10:04:47 2006 +0000 @@ -16,8 +16,8 @@ * */ -#ifndef LEMON_ALTERATION_OBSERVER_REGISTRY_H -#define LEMON_ALTERATION_OBSERVER_REGISTRY_H +#ifndef LEMON_ALTERATION_NOTIFIER_H +#define LEMON_ALTERATION_NOTIFIER_H #include #include @@ -28,7 +28,7 @@ namespace lemon { - /// \addtogroin graphmapfactory + /// \addtogroup graphmapfactory /// @{ /// \brief Registry class to register objects observes alterations in @@ -51,6 +51,9 @@ template class AlterationNotifier { public: + + typedef True Notifier; + typedef _Item Item; /// ObserverBase is the base class for the observers. diff -r 875fe3f689e0 -r d276e88aa48a lemon/graph_adaptor.h --- a/lemon/graph_adaptor.h Wed Mar 01 09:40:16 2006 +0000 +++ b/lemon/graph_adaptor.h Wed Mar 01 10:04:47 2006 +0000 @@ -1350,372 +1350,371 @@ }; - template - class SplitGraphAdaptorBase - : public GraphAdaptorBase<_Graph> { - public: - typedef GraphAdaptorBase<_Graph> Parent; +// template +// class SplitGraphAdaptorBase +// : public GraphAdaptorBase<_Graph> { +// public: +// typedef GraphAdaptorBase<_Graph> Parent; - class Node; - class Edge; - template class NodeMap; - template class EdgeMap; +// class Node; +// class Edge; +// template class NodeMap; +// template class EdgeMap; - class Node : public Parent::Node { - friend class SplitGraphAdaptorBase; - template friend class NodeMap; - typedef typename Parent::Node NodeParent; - private: +// class Node : public Parent::Node { +// friend class SplitGraphAdaptorBase; +// template friend class NodeMap; +// typedef typename Parent::Node NodeParent; +// private: - bool entry; - Node(typename Parent::Node _node, bool _entry) - : Parent::Node(_node), entry(_entry) {} +// bool entry; +// Node(typename Parent::Node _node, bool _entry) +// : Parent::Node(_node), entry(_entry) {} - public: - Node() {} - Node(Invalid) : NodeParent(INVALID), entry(true) {} +// public: +// Node() {} +// Node(Invalid) : NodeParent(INVALID), entry(true) {} - bool operator==(const Node& node) const { - return NodeParent::operator==(node) && entry == node.entry; - } +// bool operator==(const Node& node) const { +// return NodeParent::operator==(node) && entry == node.entry; +// } - bool operator!=(const Node& node) const { - return !(*this == node); - } +// bool operator!=(const Node& node) const { +// return !(*this == node); +// } - bool operator<(const Node& node) const { - return NodeParent::operator<(node) || - (NodeParent::operator==(node) && entry < node.entry); - } - }; +// bool operator<(const Node& node) const { +// return NodeParent::operator<(node) || +// (NodeParent::operator==(node) && entry < node.entry); +// } +// }; - /// \todo May we want VARIANT/union type - class Edge : public Parent::Edge { - friend class SplitGraphAdaptorBase; - template friend class EdgeMap; - private: - typedef typename Parent::Edge EdgeParent; - typedef typename Parent::Node NodeParent; - NodeParent bind; +// /// \todo May we want VARIANT/union type +// class Edge : public Parent::Edge { +// friend class SplitGraphAdaptorBase; +// template friend class EdgeMap; +// private: +// typedef typename Parent::Edge EdgeParent; +// typedef typename Parent::Node NodeParent; +// NodeParent bind; - Edge(const EdgeParent& edge, const NodeParent& node) - : EdgeParent(edge), bind(node) {} - public: - Edge() {} - Edge(Invalid) : EdgeParent(INVALID), bind(INVALID) {} +// Edge(const EdgeParent& edge, const NodeParent& node) +// : EdgeParent(edge), bind(node) {} +// public: +// Edge() {} +// Edge(Invalid) : EdgeParent(INVALID), bind(INVALID) {} - bool operator==(const Edge& edge) const { - return EdgeParent::operator==(edge) && bind == edge.bind; - } +// bool operator==(const Edge& edge) const { +// return EdgeParent::operator==(edge) && bind == edge.bind; +// } - bool operator!=(const Edge& edge) const { - return !(*this == edge); - } +// bool operator!=(const Edge& edge) const { +// return !(*this == edge); +// } - bool operator<(const Edge& edge) const { - return EdgeParent::operator<(edge) || - (EdgeParent::operator==(edge) && bind < edge.bind); - } - }; +// bool operator<(const Edge& edge) const { +// return EdgeParent::operator<(edge) || +// (EdgeParent::operator==(edge) && bind < edge.bind); +// } +// }; - void first(Node& node) const { - Parent::first(node); - node.entry = true; - } +// void first(Node& node) const { +// Parent::first(node); +// node.entry = true; +// } - void next(Node& node) const { - if (node.entry) { - node.entry = false; - } else { - node.entry = true; - Parent::next(node); - } - } +// void next(Node& node) const { +// if (node.entry) { +// node.entry = false; +// } else { +// node.entry = true; +// Parent::next(node); +// } +// } - void first(Edge& edge) const { - Parent::first(edge); - if ((typename Parent::Edge&)edge == INVALID) { - Parent::first(edge.bind); - } else { - edge.bind = INVALID; - } - } +// void first(Edge& edge) const { +// Parent::first(edge); +// if ((typename Parent::Edge&)edge == INVALID) { +// Parent::first(edge.bind); +// } else { +// edge.bind = INVALID; +// } +// } - void next(Edge& edge) const { - if ((typename Parent::Edge&)edge != INVALID) { - Parent::next(edge); - if ((typename Parent::Edge&)edge == INVALID) { - Parent::first(edge.bind); - } - } else { - Parent::next(edge.bind); - } - } +// void next(Edge& edge) const { +// if ((typename Parent::Edge&)edge != INVALID) { +// Parent::next(edge); +// if ((typename Parent::Edge&)edge == INVALID) { +// Parent::first(edge.bind); +// } +// } else { +// Parent::next(edge.bind); +// } +// } - void firstIn(Edge& edge, const Node& node) const { - if (node.entry) { - Parent::firstIn(edge, node); - edge.bind = INVALID; - } else { - (typename Parent::Edge&)edge = INVALID; - edge.bind = node; - } - } +// void firstIn(Edge& edge, const Node& node) const { +// if (node.entry) { +// Parent::firstIn(edge, node); +// edge.bind = INVALID; +// } else { +// (typename Parent::Edge&)edge = INVALID; +// edge.bind = node; +// } +// } - void nextIn(Edge& edge) const { - if ((typename Parent::Edge&)edge != INVALID) { - Parent::nextIn(edge); - } else { - edge.bind = INVALID; - } - } +// void nextIn(Edge& edge) const { +// if ((typename Parent::Edge&)edge != INVALID) { +// Parent::nextIn(edge); +// } else { +// edge.bind = INVALID; +// } +// } - void firstOut(Edge& edge, const Node& node) const { - if (!node.entry) { - Parent::firstOut(edge, node); - edge.bind = INVALID; - } else { - (typename Parent::Edge&)edge = INVALID; - edge.bind = node; - } - } +// void firstOut(Edge& edge, const Node& node) const { +// if (!node.entry) { +// Parent::firstOut(edge, node); +// edge.bind = INVALID; +// } else { +// (typename Parent::Edge&)edge = INVALID; +// edge.bind = node; +// } +// } - void nextOut(Edge& edge) const { - if ((typename Parent::Edge&)edge != INVALID) { - Parent::nextOut(edge); - } else { - edge.bind = INVALID; - } - } +// void nextOut(Edge& edge) const { +// if ((typename Parent::Edge&)edge != INVALID) { +// Parent::nextOut(edge); +// } else { +// edge.bind = INVALID; +// } +// } - Node source(const Edge& edge) const { - if ((typename Parent::Edge&)edge != INVALID) { - return Node(Parent::source(edge), false); - } else { - return Node(edge.bind, true); - } - } +// Node source(const Edge& edge) const { +// if ((typename Parent::Edge&)edge != INVALID) { +// return Node(Parent::source(edge), false); +// } else { +// return Node(edge.bind, true); +// } +// } - Node target(const Edge& edge) const { - if ((typename Parent::Edge&)edge != INVALID) { - return Node(Parent::target(edge), true); - } else { - return Node(edge.bind, false); - } - } +// Node target(const Edge& edge) const { +// if ((typename Parent::Edge&)edge != INVALID) { +// return Node(Parent::target(edge), true); +// } else { +// return Node(edge.bind, false); +// } +// } - static bool entryNode(const Node& node) { - return node.entry; - } +// static bool entryNode(const Node& node) { +// return node.entry; +// } - static bool exitNode(const Node& node) { - return !node.entry; - } +// static bool exitNode(const Node& node) { +// return !node.entry; +// } - static Node getEntry(const typename Parent::Node& node) { - return Node(node, true); - } +// static Node getEntry(const typename Parent::Node& node) { +// return Node(node, true); +// } - static Node getExit(const typename Parent::Node& node) { - return Node(node, false); - } +// static Node getExit(const typename Parent::Node& node) { +// return Node(node, false); +// } - static bool originalEdge(const Edge& edge) { - return (typename Parent::Edge&)edge != INVALID; - } +// static bool originalEdge(const Edge& edge) { +// return (typename Parent::Edge&)edge != INVALID; +// } - static bool bindingEdge(const Edge& edge) { - return edge.bind != INVALID; - } +// static bool bindingEdge(const Edge& edge) { +// return edge.bind != INVALID; +// } - static Node getBindedNode(const Edge& edge) { - return edge.bind; - } +// static Node getBindedNode(const Edge& edge) { +// return edge.bind; +// } - int nodeNum() const { - return Parent::nodeNum() * 2; - } +// int nodeNum() const { +// return Parent::nodeNum() * 2; +// } - typedef CompileTimeAnd EdgeNumTag; +// typedef True EdgeNumTag; - int edgeNum() const { - return Parent::edgeNum() + Parent::nodeNum(); - } +// int edgeNum() const { +// return countEdges() + Parent::nodeNum(); +// } - Edge findEdge(const Node& source, const Node& target, - const Edge& prev = INVALID) const { - if (exitNode(source) && entryNode(target)) { - return Parent::findEdge(source, target, prev); - } else { - if (prev == INVALID && entryNode(source) && exitNode(target) && - (typename Parent::Node&)source == (typename Parent::Node&)target) { - return Edge(INVALID, source); - } else { - return INVALID; - } - } - } +// Edge findEdge(const Node& source, const Node& target, +// const Edge& prev = INVALID) const { +// if (exitNode(source) && entryNode(target)) { +// return Parent::findEdge(source, target, prev); +// } else { +// if (prev == INVALID && entryNode(source) && exitNode(target) && +// (typename Parent::Node&)source == (typename Parent::Node&)target) { +// return Edge(INVALID, source); +// } else { +// return INVALID; +// } +// } +// } - template - class NodeMap : public MapBase { - typedef typename Parent::template NodeMap NodeImpl; - public: - NodeMap(const SplitGraphAdaptorBase& _graph) - : entry(_graph), exit(_graph) {} - NodeMap(const SplitGraphAdaptorBase& _graph, const T& t) - : entry(_graph, t), exit(_graph, t) {} +// template +// class NodeMap : public MapBase { +// typedef typename Parent::template NodeMap NodeImpl; +// public: +// NodeMap(const SplitGraphAdaptorBase& _graph) +// : entry(_graph), exit(_graph) {} +// NodeMap(const SplitGraphAdaptorBase& _graph, const T& t) +// : entry(_graph, t), exit(_graph, t) {} - void set(const Node& key, const T& val) { - if (key.entry) { entry.set(key, val); } - else {exit.set(key, val); } - } +// void set(const Node& key, const T& val) { +// if (key.entry) { entry.set(key, val); } +// else {exit.set(key, val); } +// } - typename MapTraits::ReturnValue - operator[](const Node& key) { - if (key.entry) { return entry[key]; } - else { return exit[key]; } - } +// typename MapTraits::ReturnValue +// operator[](const Node& key) { +// if (key.entry) { return entry[key]; } +// else { return exit[key]; } +// } - typename MapTraits::ConstReturnValue - operator[](const Node& key) const { - if (key.entry) { return entry[key]; } - else { return exit[key]; } - } +// typename MapTraits::ConstReturnValue +// operator[](const Node& key) const { +// if (key.entry) { return entry[key]; } +// else { return exit[key]; } +// } - private: - NodeImpl entry, exit; - }; +// private: +// NodeImpl entry, exit; +// }; - template - class EdgeMap : public MapBase { - typedef typename Parent::template NodeMap NodeImpl; - typedef typename Parent::template EdgeMap EdgeImpl; - public: - EdgeMap(const SplitGraphAdaptorBase& _graph) - : bind(_graph), orig(_graph) {} - EdgeMap(const SplitGraphAdaptorBase& _graph, const T& t) - : bind(_graph, t), orig(_graph, t) {} +// template +// class EdgeMap : public MapBase { +// typedef typename Parent::template NodeMap NodeImpl; +// typedef typename Parent::template EdgeMap EdgeImpl; +// public: +// EdgeMap(const SplitGraphAdaptorBase& _graph) +// : bind(_graph), orig(_graph) {} +// EdgeMap(const SplitGraphAdaptorBase& _graph, const T& t) +// : bind(_graph, t), orig(_graph, t) {} - void set(const Edge& key, const T& val) { - if ((typename Parent::Edge&)key != INVALID) { orig.set(key, val); } - else {bind.set(key.bind, val); } - } +// void set(const Edge& key, const T& val) { +// if ((typename Parent::Edge&)key != INVALID) { orig.set(key, val); } +// else {bind.set(key.bind, val); } +// } - typename MapTraits::ReturnValue - operator[](const Edge& key) { - if ((typename Parent::Edge&)key != INVALID) { return orig[key]; } - else {return bind[key.bind]; } - } +// typename MapTraits::ReturnValue +// operator[](const Edge& key) { +// if ((typename Parent::Edge&)key != INVALID) { return orig[key]; } +// else {return bind[key.bind]; } +// } - typename MapTraits::ConstReturnValue - operator[](const Edge& key) const { - if ((typename Parent::Edge&)key != INVALID) { return orig[key]; } - else {return bind[key.bind]; } - } +// typename MapTraits::ConstReturnValue +// operator[](const Edge& key) const { +// if ((typename Parent::Edge&)key != INVALID) { return orig[key]; } +// else {return bind[key.bind]; } +// } - private: - typename Parent::template NodeMap bind; - typename Parent::template EdgeMap orig; - }; +// private: +// typename Parent::template NodeMap bind; +// typename Parent::template EdgeMap orig; +// }; - template - class CombinedNodeMap : public MapBase { - public: - typedef MapBase Parent; +// template +// class CombinedNodeMap : public MapBase { +// public: +// typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; +// typedef typename Parent::Key Key; +// typedef typename Parent::Value Value; - CombinedNodeMap(EntryMap& _entryMap, ExitMap& _exitMap) - : entryMap(_entryMap), exitMap(_exitMap) {} +// CombinedNodeMap(EntryMap& _entryMap, ExitMap& _exitMap) +// : entryMap(_entryMap), exitMap(_exitMap) {} - Value& operator[](const Key& key) { - if (key.entry) { - return entryMap[key]; - } else { - return exitMap[key]; - } - } +// Value& operator[](const Key& key) { +// if (key.entry) { +// return entryMap[key]; +// } else { +// return exitMap[key]; +// } +// } - Value operator[](const Key& key) const { - if (key.entry) { - return entryMap[key]; - } else { - return exitMap[key]; - } - } +// Value operator[](const Key& key) const { +// if (key.entry) { +// return entryMap[key]; +// } else { +// return exitMap[key]; +// } +// } - void set(const Key& key, const Value& value) { - if (key.entry) { - entryMap.set(key, value); - } else { - exitMap.set(key, value); - } - } +// void set(const Key& key, const Value& value) { +// if (key.entry) { +// entryMap.set(key, value); +// } else { +// exitMap.set(key, value); +// } +// } - private: +// private: - EntryMap& entryMap; - ExitMap& exitMap; +// EntryMap& entryMap; +// ExitMap& exitMap; - }; +// }; - template - class CombinedEdgeMap : public MapBase { - public: - typedef MapBase Parent; +// template +// class CombinedEdgeMap : public MapBase { +// public: +// typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; +// typedef typename Parent::Key Key; +// typedef typename Parent::Value Value; - CombinedEdgeMap(EdgeMap& _edgeMap, NodeMap& _nodeMap) - : edgeMap(_edgeMap), nodeMap(_nodeMap) {} +// CombinedEdgeMap(EdgeMap& _edgeMap, NodeMap& _nodeMap) +// : edgeMap(_edgeMap), nodeMap(_nodeMap) {} - void set(const Edge& edge, const Value& val) { - if (SplitGraphAdaptorBase::originalEdge(edge)) { - edgeMap.set(edge, val); - } else { - nodeMap.set(SplitGraphAdaptorBase::bindedNode(edge), val); - } - } +// void set(const Edge& edge, const Value& val) { +// if (SplitGraphAdaptorBase::originalEdge(edge)) { +// edgeMap.set(edge, val); +// } else { +// nodeMap.set(SplitGraphAdaptorBase::bindedNode(edge), val); +// } +// } - Value operator[](const Key& edge) const { - if (SplitGraphAdaptorBase::originalEdge(edge)) { - return edgeMap[edge]; - } else { - return nodeMap[SplitGraphAdaptorBase::bindedNode(edge)]; - } - } +// Value operator[](const Key& edge) const { +// if (SplitGraphAdaptorBase::originalEdge(edge)) { +// return edgeMap[edge]; +// } else { +// return nodeMap[SplitGraphAdaptorBase::bindedNode(edge)]; +// } +// } - Value& operator[](const Key& edge) { - if (SplitGraphAdaptorBase::originalEdge(edge)) { - return edgeMap[edge]; - } else { - return nodeMap[SplitGraphAdaptorBase::bindedNode(edge)]; - } - } +// Value& operator[](const Key& edge) { +// if (SplitGraphAdaptorBase::originalEdge(edge)) { +// return edgeMap[edge]; +// } else { +// return nodeMap[SplitGraphAdaptorBase::bindedNode(edge)]; +// } +// } - private: - EdgeMap& edgeMap; - NodeMap& nodeMap; - }; +// private: +// EdgeMap& edgeMap; +// NodeMap& nodeMap; +// }; - }; +// }; - template - class SplitGraphAdaptor - : public GraphAdaptorExtender > { - public: - typedef GraphAdaptorExtender > Parent; +// template +// class SplitGraphAdaptor +// : public GraphAdaptorExtender > { +// public: +// typedef GraphAdaptorExtender > Parent; - SplitGraphAdaptor(_Graph& graph) { - Parent::setGraph(graph); - } +// SplitGraphAdaptor(_Graph& graph) { +// Parent::setGraph(graph); +// } - }; +// }; } //namespace lemon diff -r 875fe3f689e0 -r d276e88aa48a lemon/traits.h --- a/lemon/traits.h Wed Mar 01 09:40:16 2006 +0000 +++ b/lemon/traits.h Wed Mar 01 10:04:47 2006 +0000 @@ -29,6 +29,19 @@ template class ItemSetTraits {}; + + template + struct NodeNotifierIndicator { + typedef InvalidType Type; + }; + template + struct NodeNotifierIndicator< + Graph, + typename enable_if::type + > { + typedef typename Graph::NodeNotifier Type; + }; + template class ItemSetTraits<_Graph, typename _Graph::Node> { public: @@ -38,6 +51,8 @@ typedef typename Graph::Node Item; typedef typename Graph::NodeIt ItemIt; + typedef typename NodeNotifierIndicator::Type ItemNotifier; + template class Map : public Graph::template NodeMap<_Value> { public: @@ -47,8 +62,21 @@ Map(const Graph& _graph) : Parent(_graph) {} Map(const Graph& _graph, const Value& _value) : Parent(_graph, _value) {} - }; + }; + + }; + + template + struct EdgeNotifierIndicator { + typedef InvalidType Type; + }; + template + struct EdgeNotifierIndicator< + Graph, + typename enable_if::type + > { + typedef typename Graph::EdgeNotifier Type; }; template @@ -60,6 +88,8 @@ typedef typename Graph::Edge Item; typedef typename Graph::EdgeIt ItemIt; + typedef typename EdgeNotifierIndicator::Type ItemNotifier; + template class Map : public Graph::template EdgeMap<_Value> { public: @@ -73,6 +103,18 @@ }; + template + struct UEdgeNotifierIndicator { + typedef InvalidType Type; + }; + template + struct UEdgeNotifierIndicator< + Graph, + typename enable_if::type + > { + typedef typename Graph::UEdgeNotifier Type; + }; + template class ItemSetTraits<_Graph, typename _Graph::UEdge> { public: @@ -82,6 +124,8 @@ typedef typename Graph::UEdge Item; typedef typename Graph::UEdgeIt ItemIt; + typedef typename UEdgeNotifierIndicator::Type ItemNotifier; + template class Map : public Graph::template UEdgeMap<_Value> { public: @@ -95,6 +139,17 @@ }; + template + struct ANodeNotifierIndicator { + typedef InvalidType Type; + }; + template + struct ANodeNotifierIndicator< + Graph, + typename enable_if::type + > { + typedef typename Graph::ANodeNotifier Type; + }; template class ItemSetTraits<_Graph, typename _Graph::ANode> { @@ -105,6 +160,8 @@ typedef typename Graph::ANode Item; typedef typename Graph::ANodeIt ItemIt; + typedef typename ANodeNotifierIndicator::Type ItemNotifier; + template class Map : public Graph::template ANodeMap<_Value> { public: @@ -118,6 +175,18 @@ }; + template + struct BNodeNotifierIndicator { + typedef InvalidType Type; + }; + template + struct BNodeNotifierIndicator< + Graph, + typename enable_if::type + > { + typedef typename Graph::BNodeNotifier Type; + }; + template class ItemSetTraits<_Graph, typename _Graph::BNode> { public: @@ -127,6 +196,8 @@ typedef typename Graph::BNode Item; typedef typename Graph::BNodeIt ItemIt; + typedef typename BNodeNotifierIndicator::Type ItemNotifier; + template class Map : public Graph::template BNodeMap<_Value> { public: diff -r 875fe3f689e0 -r d276e88aa48a lemon/utility.h --- a/lemon/utility.h Wed Mar 01 09:40:16 2006 +0000 +++ b/lemon/utility.h Wed Mar 01 10:04:47 2006 +0000 @@ -68,21 +68,12 @@ static const bool value = false; }; - template - struct _CompileTimeAnd { - static const bool value = false; + + class InvalidType { + private: + InvalidType(); }; - template <> - struct _CompileTimeAnd { - static const bool value = true; - }; - - template - struct CompileTimeAnd { - static const bool value = - _CompileTimeAnd::value; - }; template struct Wrap {