From adfd11ab2970cf55f62caa42f827979b3560e21f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Apr 2010 10:11:29 +0200 Subject: Keep track of the Arguments edges Also add support for removing them. --- xsd-frontend/semantic-graph/elements.cxx | 29 +++++++++++++++++++++++++++-- xsd-frontend/semantic-graph/elements.hxx | 32 +++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/xsd-frontend/semantic-graph/elements.cxx b/xsd-frontend/semantic-graph/elements.cxx index 6a4fa52..6b174e2 100644 --- a/xsd-frontend/semantic-graph/elements.cxx +++ b/xsd-frontend/semantic-graph/elements.cxx @@ -3,10 +3,12 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include + #include #include -#include +using namespace std; namespace XSDFrontend { @@ -28,6 +30,30 @@ namespace XSDFrontend return annotates_->annotation (); } + // Type + // + Void Type:: + remove_edge_left (Arguments& a) + { + ArgumentsSet::Iterator i (arguments_.find (&a)); + assert (i != arguments_.end ()); + arguments_.erase (i); + } + + // Specialization + // + Void Specialization:: + remove_edge_right (Arguments& a) + { + // The number of entries should be small so linear search will do. + // + Argumented::Iterator i ( + std::find (argumented_.begin (), argumented_.end (), &a)); + + assert (i != argumented_.end ()); + argumented_.erase (i); + } + namespace RTTI = Cult::RTTI; using RTTI::Access; @@ -326,4 +352,3 @@ operator<< (std::wostream& os, XSDFrontend::SemanticGraph::Path const& path) { return os << path.native_file_string ().c_str (); } - diff --git a/xsd-frontend/semantic-graph/elements.hxx b/xsd-frontend/semantic-graph/elements.hxx index 3a95c09..dd397f2 100644 --- a/xsd-frontend/semantic-graph/elements.hxx +++ b/xsd-frontend/semantic-graph/elements.hxx @@ -626,6 +626,10 @@ namespace XSDFrontend Cult::Containers::Vector Begets; + typedef + Cult::Containers::Set + ArgumentsSet; + public: typedef Bits::PointerIterator @@ -676,6 +680,24 @@ namespace XSDFrontend return begets_.end (); } + // + // + typedef + Bits::PointerIterator + ArgumentsIterator; + + ArgumentsIterator + arguments_begin () const + { + return arguments_.begin (); + } + + ArgumentsIterator + arguments_end () const + { + return arguments_.end (); + } + protected: friend class Bits::Graph; @@ -699,11 +721,15 @@ namespace XSDFrontend using Nameable::add_edge_right; Void - add_edge_left (Arguments&) + add_edge_left (Arguments& a) { + arguments_.insert (&a); } Void + remove_edge_left (Arguments&); + + Void add_edge_left (Inherits& e) { inherits_ = &e; @@ -713,6 +739,7 @@ namespace XSDFrontend Inherits* inherits_; Begets begets_; Classifies classifies_; + ArgumentsSet arguments_; }; @@ -1119,6 +1146,9 @@ namespace XSDFrontend argumented_.push_back (&a); } + Void + remove_edge_right (Arguments&); + public: Void add_edge_right (Arguments& a, ArgumentedIterator const& pos) -- cgit v1.1