aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-04-15 10:11:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-04-15 10:11:29 +0200
commitadfd11ab2970cf55f62caa42f827979b3560e21f (patch)
tree9d659091ec8a019c0a14f5ce0f62d0e3b367c7f4
parent3834909317a6e83b406b6063285a64e02df80ee6 (diff)
Keep track of the Arguments edges
Also add support for removing them.
-rw-r--r--xsd-frontend/semantic-graph/elements.cxx29
-rw-r--r--xsd-frontend/semantic-graph/elements.hxx32
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 <algorithm>
+
#include <xsd-frontend/semantic-graph/elements.hxx>
#include <xsd-frontend/semantic-graph/annotation.hxx>
-#include <iostream>
+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<Inherits*>
Begets;
+ typedef
+ Cult::Containers::Set<Arguments*>
+ ArgumentsSet;
+
public:
typedef
Bits::PointerIterator<Classifies::ConstIterator>
@@ -676,6 +680,24 @@ namespace XSDFrontend
return begets_.end ();
}
+ //
+ //
+ typedef
+ Bits::PointerIterator<ArgumentsSet::ConstIterator>
+ ArgumentsIterator;
+
+ ArgumentsIterator
+ arguments_begin () const
+ {
+ return arguments_.begin ();
+ }
+
+ ArgumentsIterator
+ arguments_end () const
+ {
+ return arguments_.end ();
+ }
+
protected:
friend class Bits::Graph<Node, Edge>;
@@ -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)