From: Brian Norris <banorris@uci.edu>
Date: Thu, 7 Feb 2013 00:39:15 +0000 (-0800)
Subject: cyclegraph: expand template usage
X-Git-Tag: oopsla2013~274
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5236e7a4403ccc6d28b3fdc746c5710d6190310a;p=model-checker.git

cyclegraph: expand template usage

checkReachable() and addEdge() will be used in more forms. Add template
instantiations.
---

diff --git a/cyclegraph.cc b/cyclegraph.cc
index e0b2215..7fadcbd 100644
--- a/cyclegraph.cc
+++ b/cyclegraph.cc
@@ -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
diff --git a/cyclegraph.h b/cyclegraph.h
index e96e121..bb2ab2d 100644
--- a/cyclegraph.h
+++ b/cyclegraph.h
@@ -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();