summaryrefslogtreecommitdiff
path: root/odb/semantics/template.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-03-25 13:47:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-03-25 13:47:43 +0200
commit01f77f6d38283b4efbe2b55fc9c7c837fd6498dc (patch)
tree12059fa0c514a3f2b9da2a9419593e3596cc6f5d /odb/semantics/template.hxx
parentad637abaa62a26461b276769c35dd1b67036b54b (diff)
Add support for union, enum, class/union template
Diffstat (limited to 'odb/semantics/template.hxx')
-rw-r--r--odb/semantics/template.hxx158
1 files changed, 158 insertions, 0 deletions
diff --git a/odb/semantics/template.hxx b/odb/semantics/template.hxx
new file mode 100644
index 0000000..1357dbf
--- /dev/null
+++ b/odb/semantics/template.hxx
@@ -0,0 +1,158 @@
+// file : odb/semantics/template.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_SEMANTICS_TEMPLATE_HXX
+#define ODB_SEMANTICS_TEMPLATE_HXX
+
+#include <vector>
+#include <semantics/elements.hxx>
+
+namespace semantics
+{
+ //
+ //
+ class instantiates;
+
+ class template_: public virtual nameable
+ {
+ typedef std::vector<instantiates*> instantiated;
+
+ public:
+ typedef
+ pointer_iterator<instantiated::const_iterator>
+ instantiated_iterator;
+
+ instantiated_iterator
+ instantiated_begin () const
+ {
+ return instantiated_.begin ();
+ }
+
+ instantiated_iterator
+ instantiated_end () const
+ {
+ return instantiated_.end ();
+ }
+
+ public:
+ void
+ add_edge_right (instantiates& e)
+ {
+ instantiated_.push_back (&e);
+ }
+
+ using nameable::add_edge_right;
+
+ protected:
+ template_ ()
+ {
+ }
+
+ private:
+ instantiated instantiated_;
+ };
+
+ //
+ //
+ class instantiation;
+
+ class instantiates: public edge
+ {
+ public:
+ typedef semantics::template_ template_type;
+ typedef semantics::instantiation instantiation_type;
+
+ template_type&
+ template_ () const
+ {
+ return *template__;
+ }
+
+ instantiation_type&
+ instantiation () const
+ {
+ return *instantiation_;
+ }
+
+ public:
+ instantiates ()
+ {
+ }
+
+ void
+ set_left_node (instantiation_type& n)
+ {
+ instantiation_ = &n;
+ }
+
+ void
+ set_right_node (template_type& n)
+ {
+ template__ = &n;
+ }
+
+ private:
+ template_type* template__;
+ instantiation_type* instantiation_;
+ };
+
+ //
+ //
+ class instantiation: public virtual node
+ {
+ public:
+ typedef semantics::template_ template_type;
+ typedef semantics::instantiates instantiates_type;
+
+ template_type&
+ template_ () const
+ {
+ return instantiates_->template_ ();
+ }
+
+ instantiates_type&
+ instantiates () const
+ {
+ return *instantiates_;
+ }
+
+ public:
+ void
+ add_edge_left (instantiates_type& e)
+ {
+ instantiates_ = &e;
+ }
+
+ protected:
+ instantiation ()
+ {
+ }
+
+ private:
+ instantiates_type* instantiates_;
+ };
+
+ //
+ // Type template and instantiation.
+ //
+
+ class type_template: public template_
+ {
+ protected:
+ type_template ()
+ {
+ }
+ };
+
+ class type_instantiation: public virtual type, public instantiation
+ {
+ protected:
+ type_instantiation ()
+ {
+ }
+ };
+}
+
+#endif // ODB_SEMANTICS_TEMPLATE_HXX