From 07aa7bafa42e3909d74889e5ed70fff3ab05d0f0 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 28 Jan 2013 18:39:23 -0800 Subject: [PATCH] cyclegraph: template for addEdge() This function will be identical for all combinations of ModelAction / Promise. So just make it a template. --- cyclegraph.cc | 17 ++++++++++++----- cyclegraph.h | 5 ++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cyclegraph.cc b/cyclegraph.cc index 89c3f2ca..49c462f5 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 5c49992e..f812e24d 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; -- 2.34.1