summaryrefslogtreecommitdiff
path: root/CIAO/CCF/Example/ComponentDeploymentDescriptor
diff options
context:
space:
mode:
Diffstat (limited to 'CIAO/CCF/Example/ComponentDeploymentDescriptor')
-rw-r--r--CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp113
-rw-r--r--CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp286
-rw-r--r--CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp112
-rw-r--r--CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp386
-rw-r--r--CIAO/CCF/Example/ComponentDeploymentDescriptor/cdd.cpp144
5 files changed, 0 insertions, 1041 deletions
diff --git a/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp b/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp
deleted file mode 100644
index 0a7a3ae6bf2..00000000000
--- a/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-// file : CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp
-// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
-// cvs-id : $Id$
-
-#include "SyntaxTree.hpp"
-
-using namespace Introspection;
-
-namespace CDD
-{
- namespace SyntaxTree
- {
- // Node
- //
- //
- namespace
- {
- TypeInfo
- node_init_ ()
- {
- TypeInfo ti (typeid (Node));
- // I don't really need this information
- // ti.add_base (Access::PUBLIC, true, Object::static_type_info ());
- return ti;
- }
-
- TypeInfo node_ (node_init_ ());
- }
-
- TypeInfo const& Node::
- static_type_info () { return node_; }
-
-
- // PortInstance
- //
- //
- namespace
- {
- TypeInfo
- port_instance_init_ ()
- {
- TypeInfo ti (typeid (PortInstance));
- ti.add_base (Access::PUBLIC, true, Node::static_type_info ());
- return ti;
- }
-
- TypeInfo port_instance_ (port_instance_init_ ());
- }
-
- TypeInfo const& PortInstance::
- static_type_info () { return port_instance_; }
-
-
- // ComponentInstance
- //
- //
- namespace
- {
- TypeInfo
- component_instance_init_ ()
- {
- TypeInfo ti (typeid (ComponentInstance));
- ti.add_base (Access::PUBLIC, true, Node::static_type_info ());
- return ti;
- }
-
- TypeInfo component_instance_ (component_instance_init_ ());
- }
-
- TypeInfo const& ComponentInstance::
- static_type_info () { return component_instance_; }
-
-
- // Connection
- //
- //
- namespace
- {
- TypeInfo
- connection_init_ ()
- {
- TypeInfo ti (typeid (Connection));
- ti.add_base (Access::PUBLIC, true, Node::static_type_info ());
- return ti;
- }
-
- TypeInfo connection_ (connection_init_ ());
- }
-
- TypeInfo const& Connection::
- static_type_info () { return connection_; }
-
-
- // Descriptor
- //
- //
- namespace
- {
- TypeInfo
- descriptor_init_ ()
- {
- TypeInfo ti (typeid (Descriptor));
- ti.add_base (Access::PUBLIC, true, Node::static_type_info ());
- return ti;
- }
-
- TypeInfo descriptor_ (descriptor_init_ ());
- }
-
- TypeInfo const& Descriptor::
- static_type_info () { return descriptor_; }
- }
-}
diff --git a/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp b/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp
deleted file mode 100644
index 3739826b27d..00000000000
--- a/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp
+++ /dev/null
@@ -1,286 +0,0 @@
-// file : CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp
-// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
-// cvs-id : $Id$
-
-#ifndef CDD_SYNTAX_TREE_HPP
-#define CDD_SYNTAX_TREE_HPP
-
-#include <set>
-#include <vector>
-#include <string>
-
-
-#include "CCF/CompilerElements/ReferenceCounting.hpp"
-#include "CCF/CompilerElements/Introspection.hpp"
-
-namespace CDD
-{
- namespace SyntaxTree
- {
- using ReferenceCounting::StrictPtr;
-
- //
- //
- //
- class Node;
-
- typedef
- StrictPtr<Node>
- NodePtr;
-
- class Node : public virtual Introspection::Object,
- public virtual ReferenceCounting::DefaultImpl <>
- {
- protected:
- virtual
- ~Node () throw () {}
-
- Node ()
- {
- type_info (static_type_info ());
- }
-
- public:
- template <typename Type>
- StrictPtr<Type>
- dynamic_type ()
- {
- NodePtr self (ReferenceCounting::add_ref (this));
- return ReferenceCounting::strict_cast<Type>(self);
- }
-
- public:
- static Introspection::TypeInfo const&
- static_type_info ();
- };
-
- typedef
- std::vector<NodePtr>
- NodeList;
-
-
- //
- //
- //
- class PortInstance : public virtual Node
- {
- public:
-
- virtual
- ~PortInstance () throw () {}
-
- PortInstance (std::string name)
- : name_ (name)
- {
- type_info (static_type_info ());
- }
-
- public:
- std::string
- name () const
- {
- return name_;
- }
-
- public:
- static Introspection::TypeInfo const&
- static_type_info ();
-
- private:
- std::string name_;
- };
-
- typedef
- StrictPtr<PortInstance>
- PortInstancePtr;
-
- template <typename T>
- struct NameComparator
- {
- bool
- operator () (T const& x, T const& y) const
- {
- return x->name () < y->name ();
- }
- };
-
- typedef
- std::set<PortInstancePtr, NameComparator<PortInstancePtr> >
- PortInstanceSet;
-
-
- //
- //
- //
- class ComponentInstance : public virtual Node
- {
- public:
- typedef
- PortInstanceSet::const_iterator
- Iterator;
-
- public:
-
- virtual
- ~ComponentInstance () throw () {}
-
- ComponentInstance (std::string name,
- std::string type)
- : name_ (name),
- type_ (type)
- {
- type_info (static_type_info ());
- }
-
- public:
-
- std::string
- name () const
- {
- return name_;
- }
-
- std::string
- type () const
- {
- return type_;
- }
-
- public:
- class AlreadyExist {};
-
- void
- insert (PortInstancePtr const& d) throw (AlreadyExist)
- {
- if (!ports_.insert (d).second) throw AlreadyExist ();
- }
-
- Iterator
- begin () const
- {
- return ports_.begin ();
- }
-
-
- Iterator
- end () const
- {
- return ports_.end ();
- }
-
- public:
- static Introspection::TypeInfo const&
- static_type_info ();
-
- private:
- std::string name_;
- std::string type_;
-
- PortInstanceSet ports_;
- };
-
- typedef
- StrictPtr<ComponentInstance>
- ComponentInstancePtr;
-
-
- //
- //
- //
- class Connection : public virtual Node
- {
- public:
- virtual
- ~Connection () throw () {}
-
- Connection (PortInstancePtr const& left,
- PortInstancePtr const& right)
- : left_ (left),
- right_ (right)
- {
- type_info (static_type_info ());
- }
-
- public:
-
- PortInstancePtr
- left () const
- {
- return left_;
- }
-
- PortInstancePtr
- right () const
- {
- return right_;
- }
-
- public:
- static Introspection::TypeInfo const&
- static_type_info ();
-
- private:
- PortInstancePtr left_;
- PortInstancePtr right_;
- };
-
- typedef
- StrictPtr<Connection>
- ConnectionPtr;
-
-
- //
- //
- //
- class Descriptor : public virtual Node
- {
- public:
- typedef
- NodeList::const_iterator
- Iterator;
-
- public:
- virtual
- ~Descriptor () throw () {}
-
- Descriptor ()
- {
- type_info (static_type_info ());
- }
-
- public:
- void
- insert (NodePtr const& n)
- {
- nodes_.push_back (n);
- }
-
- Iterator
- begin () const
- {
- return nodes_.begin ();
- }
-
-
- Iterator
- end () const
- {
- return nodes_.end ();
- }
-
- public:
- static Introspection::TypeInfo const&
- static_type_info ();
-
- private:
- NodeList nodes_;
- };
-
- typedef
- StrictPtr<Descriptor>
- DescriptorPtr;
- }
-}
-
-
-#endif // CDD_SYNTAX_TREE_HPP
diff --git a/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp b/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp
deleted file mode 100644
index 8f6a20649bc..00000000000
--- a/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// file : CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp
-// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
-// cvs-id : $Id$
-
-#include "Traversal.hpp"
-
-using namespace Introspection;
-
-namespace CDD
-{
- namespace Traversal
- {
-
- // Dispatcher
- //
- //
-
- struct TypeInfoComparator
- {
- bool
- operator () (TypeInfo const& x, TypeInfo const& y) const
- {
- return x.type_id () < y.type_id ();
- }
- };
-
- typedef
- std::map<TypeInfo, unsigned long, TypeInfoComparator>
- LevelMap;
-
- typedef
- std::set<TypeInfo, TypeInfoComparator>
- TypeInfoSet;
-
- unsigned long
- compute_levels (TypeInfo const& ti, unsigned long cur, LevelMap& map)
- {
- unsigned long ret = cur;
-
- if (map.find (ti) == map.end () || map[ti] < cur) map[ti] = cur;
-
- for (TypeInfo::BaseIterator i = ti.begin_base ();
- i != ti.end_base ();
- i++)
- {
- unsigned long t = compute_levels (i->type_info (), cur + 1, map);
- if (t > ret) ret = t;
- }
-
- return ret;
- }
-
- void
- flatten_tree (TypeInfo const& ti, TypeInfoSet& set)
- {
- set.insert (ti);
-
- for (TypeInfo::BaseIterator i = ti.begin_base ();
- i != ti.end_base ();
- i++)
- {
- flatten_tree (i->type_info (), set);
- }
- }
-
- void Dispatcher::
- dispatch (SyntaxTree::NodePtr const& n)
- {
- LevelMap levels;
-
- unsigned long max = compute_levels (n->type_info (), 0, levels);
-
- //cerr << "starting dispatch process for "
- // << n->type_info ().type_id () << " with "
- // << max << " levels" << endl;
-
- for (unsigned long l = 0; l < max + 1; l++)
- {
- TypeInfoSet dispatched;
-
- for (LevelMap::const_iterator i = levels.begin ();
- i != levels.end ();
- i++)
- {
- if (i->second == l)
- {
- TraversalMap::const_iterator v =
- traversal_map_.find (i->first.type_id ());
-
- if (v != traversal_map_.end () && !(v->second.suppressed))
- {
- //cerr << "dispatching traverser for "
- // << n->type_info ().type_id () << " as "
- // << i->first.type_id () << endl;
-
- v->second.traverser->traverse (n);
- flatten_tree (i->first, dispatched);
- }
- }
- }
-
- // Remove traversed types from level map.
- for (TypeInfoSet::const_iterator i = dispatched.begin ();
- i != dispatched.end ();
- i++)
- {
- levels.erase (*i);
- }
- }
- }
- }
-}
diff --git a/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp b/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp
deleted file mode 100644
index 2b6697abae9..00000000000
--- a/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp
+++ /dev/null
@@ -1,386 +0,0 @@
-// file : CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp
-// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
-// cvs-id : $Id$
-
-#ifndef CDD_TRAVERSAL_HPP
-#define CDD_TRAVERSAL_HPP
-
-#include <map>
-#include <vector>
-
-#include "CCF/CompilerElements/Introspection.hpp"
-
-#include "SyntaxTree.hpp"
-
-namespace CDD
-{
- namespace Traversal
- {
- //
- //
- //
- class TraverserInterface
- {
- protected:
- virtual
- ~TraverserInterface ()
- {
- }
-
- virtual void
- traverse (SyntaxTree::NodePtr const& n) = 0;
-
- friend class Dispatcher;
- };
-
-
- //
- //
- //
- class Dispatcher
- {
- public:
- virtual
- ~Dispatcher ()
- {
- }
-
- virtual void
- dispatch (SyntaxTree::NodePtr const& n);
-
- protected:
-
- class Ambiguous {};
-
- void
- map (Introspection::TypeId id,
- TraverserInterface* t,
- bool suppress_ambiguity = false)
- throw (Ambiguous)
- {
- if (!traversal_map_.insert (std::make_pair (id, t)).second)
- {
- if (suppress_ambiguity)
- {
- traversal_map_[id].suppressed = true;
- }
- else
- {
- throw Ambiguous ();
- }
- }
- }
-
- private:
-
- struct TraverserDescriptor
- {
- TraverserDescriptor (TraverserInterface* t = 0)
- : traverser (t),
- suppressed (false)
- {
- }
-
- TraverserInterface* traverser;
- bool suppressed;
- };
-
- typedef
- std::map<Introspection::TypeId, TraverserDescriptor>
- TraversalMap;
-
- public:
- typedef
- TraversalMap::const_iterator
- Iterator;
-
- Iterator
- begin () const
- {
- return traversal_map_.begin ();
- }
-
- Iterator
- end () const
- {
- return traversal_map_.end ();
- }
-
- private:
- TraversalMap traversal_map_;
- };
-
-
- //
- //
- //
- class Discriminator : public virtual Dispatcher
- {
- public:
- virtual void
- add (Dispatcher* d) throw (Ambiguous)
- {
- for (Iterator i = d->begin (); i != d->end (); i++)
- {
- map (i->first, i->second.traverser, true);
- }
- }
- };
-
-
- //
- //
- //
- class Traverser : public TraverserInterface,
- public virtual Dispatcher
- {
- public:
- virtual void
- add_delegate (Dispatcher* d)
- {
- delegates_.push_back (d);
- }
-
- protected:
- virtual bool
- delegate (SyntaxTree::NodePtr const& n) const
- {
- if (delegates_.empty ()) return false;
-
- for (DispatcherList::const_iterator i = delegates_.begin ();
- i != delegates_.end ();
- i++)
- {
- (*i)->dispatch (n);
- }
-
- return true;
- }
-
- protected:
- typedef
- std::vector<Dispatcher*>
- DispatcherList;
-
- DispatcherList delegates_;
- };
-
-
- //
- //
- //
- struct PortInstance : Traverser
- {
- typedef
- SyntaxTree::PortInstancePtr
- NodePtr;
-
- PortInstance ()
- {
- map (typeid (SyntaxTree::PortInstance), this);
- }
-
- virtual void
- traverse (SyntaxTree::NodePtr const& n)
- {
- traverse (n->dynamic_type<SyntaxTree::PortInstance> ());
- }
-
- virtual void
- traverse (NodePtr const& n)
- {
- delegate (n);
- }
- };
-
-
- //
- //
- //
- struct ComponentInstance : Traverser
- {
- public:
-
- virtual void
- add_port_delegate (Dispatcher* d)
- {
- port_delegates_.push_back (d);
- }
-
- public:
- typedef
- SyntaxTree::ComponentInstancePtr
- NodePtr;
-
- ComponentInstance ()
- {
- map (typeid (SyntaxTree::ComponentInstance), this);
- }
-
- virtual void
- traverse (SyntaxTree::NodePtr const& n)
- {
- traverse (n->dynamic_type<SyntaxTree::ComponentInstance> ());
- }
-
- virtual void
- traverse (NodePtr const& n)
- {
- if (!delegate (n))
- {
- pre (n);
- ports (n);
- post (n);
- }
- }
-
- virtual void
- pre (NodePtr const&)
- {
- }
-
- virtual void
- ports (NodePtr const& n)
- {
- delegate_port (n);
- }
-
- virtual void
- post (NodePtr const&)
- {
- }
-
- protected:
- virtual void
- delegate_port (NodePtr const& s)
- {
- for (SyntaxTree::ComponentInstance::Iterator n = s->begin ();
- n != s->end ();
- n++)
- {
- dispatch (*n);
-
- for (DispatcherList::const_iterator i = port_delegates_.begin ();
- i != port_delegates_.end ();
- i++)
- {
- (*i)->dispatch (*n);
- }
- }
- }
-
- protected:
- DispatcherList port_delegates_;
- };
-
-
- //
- //
- //
- struct Connection : Traverser
- {
- typedef
- SyntaxTree::ConnectionPtr
- NodePtr;
-
- Connection ()
- {
- map (typeid (SyntaxTree::Connection), this);
- }
-
- virtual void
- traverse (SyntaxTree::NodePtr const& n)
- {
- traverse (n->dynamic_type<SyntaxTree::Connection> ());
- }
-
- virtual void
- traverse (NodePtr const& n)
- {
- delegate (n);
- }
- };
-
-
- //
- //
- //
- struct Descriptor : Traverser
- {
- public:
-
- virtual void
- add_node_delegate (Dispatcher* d)
- {
- node_delegates_.push_back (d);
- }
-
- public:
- typedef
- SyntaxTree::DescriptorPtr
- NodePtr;
-
- Descriptor ()
- {
- map (typeid (SyntaxTree::Descriptor), this);
- }
-
- virtual void
- traverse (SyntaxTree::NodePtr const& n)
- {
- traverse (n->dynamic_type<SyntaxTree::Descriptor> ());
- }
-
- virtual void
- traverse (NodePtr const& n)
- {
- if (!delegate (n))
- {
- pre (n);
- ports (n);
- post (n);
- }
- }
-
- virtual void
- pre (NodePtr const&)
- {
- }
-
- virtual void
- ports (NodePtr const& n)
- {
- delegate_node (n);
- }
-
- virtual void
- post (NodePtr const&)
- {
- }
-
- protected:
- virtual void
- delegate_node (NodePtr const& s)
- {
- for (SyntaxTree::Descriptor::Iterator n = s->begin ();
- n != s->end ();
- n++)
- {
- dispatch (*n);
-
- for (DispatcherList::const_iterator i = node_delegates_.begin ();
- i != node_delegates_.end ();
- i++)
- {
- (*i)->dispatch (*n);
- }
- }
- }
-
- protected:
- DispatcherList node_delegates_;
- };
- }
-}
-
-#endif // CDD_TRAVERSAL_HPP
diff --git a/CIAO/CCF/Example/ComponentDeploymentDescriptor/cdd.cpp b/CIAO/CCF/Example/ComponentDeploymentDescriptor/cdd.cpp
deleted file mode 100644
index 737260014bc..00000000000
--- a/CIAO/CCF/Example/ComponentDeploymentDescriptor/cdd.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-// file : CCF/Example/ComponentDeploymentDescriptor/cdd.cpp
-// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
-// cvs-id : $Id$
-
-#include <iostream>
-
-#include "CCF/CodeGenerationKit/IndentationXML.hpp"
-#include "CCF/CodeGenerationKit/IndentationImplanter.hpp"
-
-#include "SyntaxTree.hpp"
-#include "Traversal.hpp"
-
-using std::cout;
-using std::cerr;
-using std::endl;
-
-using namespace CDD;
-
-/*
-struct CI_Emitter : public virtual Traversal::ComponentInstance
-{
- virtual void
- pre (NodePtr const& n)
- {
- cout << "component instance " << n->name () << " of type "
- << n->type () << endl << "{" << endl;
-
- }
-
- virtual void
- post (NodePtr const& n)
- {
- cout << "}" << endl;
- }
-
-};
-
-struct PI_Emitter : public virtual Traversal::PortInstance
-{
- virtual void
- traverse (NodePtr const& n)
- {
- cout << " port " << n->name () << ";" << endl;
- }
-};
-
-struct C_Emitter : public virtual Traversal::Connection
-{
- virtual void
- traverse (NodePtr const& n)
- {
- cout << "connection " << n->left ()->name ()
- << "<--->" << n->right ()->name () << ";" << endl;
- }
-};
-
-*/
-
-
-struct CI_Emitter : public virtual Traversal::ComponentInstance
-{
- virtual void
- pre (NodePtr const& n)
- {
- cout << "<ComponentInstance name=\"" << n->name () << "\" type=\""
- << n->type () << "\" >" << endl;
-
- }
-
- virtual void
- post (NodePtr const& n)
- {
- cout << "</ComponentInstance>" << endl << endl;
- }
-
-};
-
-struct PI_Emitter : public virtual Traversal::PortInstance
-{
- virtual void
- traverse (NodePtr const& n)
- {
- cout << "<Port name=\"" << n->name () << "\" />" << endl;
- }
-};
-
-struct C_Emitter : public virtual Traversal::Connection
-{
- virtual void
- traverse (NodePtr const& n)
- {
- cout << "<Connection left=\"" << n->left ()->name () << "\" "
- << "right=\"" << n->right ()->name () << "\" />" << endl;
- }
-};
-
-
-int
-main ()
-{
- using namespace SyntaxTree;
-
- try
- {
- // Construct tree
-
- DescriptorPtr d (new Descriptor);
-
- PortInstancePtr ap (new PortInstance ("ap"));
- ComponentInstancePtr a (new ComponentInstance ("a", "A"));
- a->insert (ap);
- d->insert (a);
-
- PortInstancePtr bp (new PortInstance ("bp"));
- ComponentInstancePtr b (new ComponentInstance ("b", "B"));
- b->insert (bp);
- d->insert (b);
-
- ConnectionPtr c (new Connection (ap, bp));
- d->insert (c);
-
- // Construct Traverser
-
- Traversal::Descriptor dt;
-
- CI_Emitter cie;
- PI_Emitter pie;
- cie.add_port_delegate (&pie);
-
- C_Emitter ce;
-
- dt.add_node_delegate (&cie);
- dt.add_node_delegate (&ce);
-
- // Set auto-indentation for cout
- Indentation::Implanter<Indentation::XML> guard (cout);
-
- dt.traverse (d);
- }
- catch (...)
- {
- cerr << "caught something" << endl;
- }
-}