From: Brian Norris Date: Tue, 29 Jan 2013 02:39:23 +0000 (-0800) Subject: cyclegraph: template for addEdge() X-Git-Tag: oopsla2013~306 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=07aa7bafa42e3909d74889e5ed70fff3ab05d0f0;p=model-checker.git cyclegraph: template for addEdge() This function will be identical for all combinations of ModelAction / Promise. So just make it a template. --- diff --git a/cyclegraph.cc b/cyclegraph.cc index 89c3f2c..49c462f 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -47,12 +47,19 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) } /** - * Adds an edge between two ModelActions. The ModelAction @a to is ordered - * after the ModelAction @a from. - * @param to The edge points to this ModelAction - * @param from The edge comes from this ModelAction + * @brief Adds an edge between objects + * + * This function will add an edge between any two objects which can be + * associated with a CycleNode. That is, if they have a CycleGraph::getNode + * implementation. + * + * The object to is ordered after the object from. + * + * @param to The edge points to this object, of type T + * @param from The edge comes from this object, of type U */ -void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) +template +void CycleGraph::addEdge(const T from, const U to) { ASSERT(from); ASSERT(to); diff --git a/cyclegraph.h b/cyclegraph.h index 5c49992..f812e24 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -24,7 +24,10 @@ class CycleGraph { public: CycleGraph(); ~CycleGraph(); - void addEdge(const ModelAction *from, const ModelAction *to); + + template + void addEdge(const T from, const U to); + bool checkForCycles() const; void addRMWEdge(const ModelAction *from, const ModelAction *rmw); bool checkPromise(const ModelAction *from, Promise *p) const;