cyclegraph: edit template for addEdge
[model-checker.git] / cyclegraph.h
index c9c575ab36cdce5c8e9bc8445b0bce21837d8f99..9fc789c1913edd590f59c497f6cee1ff0b59eff2 100644 (file)
@@ -52,8 +52,10 @@ class CycleGraph {
  private:
        void addNodeEdge(CycleNode *fromnode, CycleNode *tonode);
        void putNode(const ModelAction *act, CycleNode *node);
-       CycleNode * getNode(const ModelAction *);
+       CycleNode * getNode(const ModelAction *act);
        CycleNode * getNode(const Promise *promise);
+       CycleNode * getNode_noCreate(const ModelAction *act) const;
+       CycleNode * getNode_noCreate(const Promise *promise) const;
        bool mergeNodes(CycleNode *node1, CycleNode *node2,
                        promise_list_t *mustMerge);
 
@@ -128,4 +130,28 @@ class CycleNode {
        CycleNode *hasRMW;
 };
 
+/*
+ * @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
+ */
+template <typename T, typename U>
+void CycleGraph::addEdge(const T from, const U to)
+{
+       ASSERT(from);
+       ASSERT(to);
+
+       CycleNode *fromnode = getNode(from);
+       CycleNode *tonode = getNode(to);
+
+       addNodeEdge(fromnode, tonode);
+}
+
 #endif /* __CYCLEGRAPH_H__ */