cyclegraph: expand template usage
authorBrian Norris <banorris@uci.edu>
Thu, 7 Feb 2013 00:39:15 +0000 (16:39 -0800)
committerBrian Norris <banorris@uci.edu>
Thu, 7 Feb 2013 00:39:15 +0000 (16:39 -0800)
checkReachable() and addEdge() will be used in more forms. Add template
instantiations.

cyclegraph.cc
cyclegraph.h

index e0b221514f9bd88b0785839b44e2436921f9f4b8..7fadcbda00d8b6f02f9cfe81d5cd3f423e9a3a2b 100644 (file)
@@ -308,10 +308,11 @@ bool CycleGraph::addEdge(const T *from, const U *to)
 
        return addNodeEdge(fromnode, tonode);
 }
-/* Instantiate three forms of CycleGraph::addEdge */
+/* Instantiate four forms of CycleGraph::addEdge */
 template bool CycleGraph::addEdge(const ModelAction *from, const ModelAction *to);
 template bool CycleGraph::addEdge(const ModelAction *from, const Promise *to);
 template bool CycleGraph::addEdge(const Promise *from, const ModelAction *to);
+template bool CycleGraph::addEdge(const Promise *from, const Promise *to);
 
 #if SUPPORT_MOD_ORDER_DUMP
 
@@ -405,13 +406,13 @@ bool CycleGraph::checkReachable(const CycleNode *from, const CycleNode *to) cons
 }
 
 /**
- * Checks whether one ModelAction can reach another ModelAction/Promise
- * @param from The ModelAction from which to begin exploration
+ * Checks whether one ModelAction/Promise can reach another ModelAction/Promise
+ * @param from The ModelAction or Promise from which to begin exploration
  * @param to The ModelAction or Promise to reach
  * @return True, @a from can reach @a to; otherwise, false
  */
-template <typename T>
-bool CycleGraph::checkReachable(const ModelAction *from, const T *to) const
+template <typename T, typename U>
+bool CycleGraph::checkReachable(const T *from, const U *to) const
 {
        CycleNode *fromnode = getNode_noCreate(from);
        CycleNode *tonode = getNode_noCreate(to);
@@ -421,11 +422,13 @@ bool CycleGraph::checkReachable(const ModelAction *from, const T *to) const
 
        return checkReachable(fromnode, tonode);
 }
-/* Instantiate two forms of CycleGraph::checkReachable */
+/* Instantiate three forms of CycleGraph::checkReachable */
 template bool CycleGraph::checkReachable(const ModelAction *from,
                const ModelAction *to) const;
 template bool CycleGraph::checkReachable(const ModelAction *from,
                const Promise *to) const;
+template bool CycleGraph::checkReachable(const Promise *from,
+               const ModelAction *to) const;
 
 /** @return True, if the promise has failed; false otherwise */
 bool CycleGraph::checkPromise(const ModelAction *fromact, Promise *promise) const
index e96e1216c0907a0af9d7e166441f960c5b782188..bb2ab2d87b4370065ff64fa9dfcac45e86f2ce39 100644 (file)
@@ -36,8 +36,8 @@ class CycleGraph {
        bool checkForCycles() const;
        bool checkPromise(const ModelAction *from, Promise *p) const;
 
-       template <typename T>
-       bool checkReachable(const ModelAction *from, const T *to) const;
+       template <typename T, typename U>
+       bool checkReachable(const T *from, const U *to) const;
 
        void startChanges();
        void commitChanges();