X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=cyclegraph.cc;h=2c3a5936a89d8ac7dbb7e5b43e32b7a1cfd5ec6a;hb=482c7447dd2f63823eb969c37dd6fb4e22991fde;hp=46b0d4ac4eb803df74d57e53148d0d463f343e26;hpb=d3dffe991352938e5c2ab738ce70e3ec0f069d5f;p=model-checker.git diff --git a/cyclegraph.cc b/cyclegraph.cc index 46b0d4a..2c3a593 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -31,14 +31,29 @@ void CycleGraph::putNode(const ModelAction *act, CycleNode *node) #endif } +/** @return The corresponding CycleNode, if exists; otherwise NULL */ +CycleNode * CycleGraph::getNode_noCreate(const ModelAction *act) const +{ + return actionToNode.get(act); +} + +/** @return The corresponding CycleNode, if exists; otherwise NULL */ +CycleNode * CycleGraph::getNode_noCreate(const Promise *promise) const +{ + return readerToPromiseNode.get(promise->get_action()); +} + /** * @brief Returns the CycleNode corresponding to a given ModelAction + * + * Gets (or creates, if none exist) a CycleNode corresponding to a ModelAction + * * @param action The ModelAction to find a node for * @return The CycleNode paired with this action */ CycleNode * CycleGraph::getNode(const ModelAction *action) { - CycleNode *node = actionToNode.get(action); + CycleNode *node = getNode_noCreate(action); if (node == NULL) { node = new CycleNode(action); putNode(action, node); @@ -58,7 +73,7 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) CycleNode * CycleGraph::getNode(const Promise *promise) { const ModelAction *reader = promise->get_action(); - CycleNode *node = readerToPromiseNode.get(reader); + CycleNode *node = getNode_noCreate(promise); if (node == NULL) { node = new CycleNode(promise); readerToPromiseNode.put(reader, node); @@ -275,12 +290,13 @@ void CycleGraph::dumpGraphToFile(const char *filename) const #endif /** - * Checks whether one ModelAction can reach another. + * Checks whether one ModelAction can reach another ModelAction/Promise * @param from The ModelAction from which to begin exploration - * @param to The ModelAction to reach + * @param to The ModelAction or Promise to reach * @return True, @a from can reach @a to; otherwise, false */ -bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) const +template +bool CycleGraph::checkReachable(const ModelAction *from, const T *to) const { CycleNode *fromnode = actionToNode.get(from); CycleNode *tonode = actionToNode.get(to);