diff options
Diffstat (limited to 'ACE/contrib/utility/Example')
26 files changed, 0 insertions, 1811 deletions
diff --git a/ACE/contrib/utility/Example/CommandLine/Foo/command.cpp b/ACE/contrib/utility/Example/CommandLine/Foo/command.cpp deleted file mode 100644 index db829909f37..00000000000 --- a/ACE/contrib/utility/Example/CommandLine/Foo/command.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* FUZZ: disable check_for_improper_main_declaration */ - -#include <string> -#include <iostream> - -using std::cerr; -using std::endl; - -class Command -{ -public: - enum Value - { - HELP = 0, - VERSION, - DEFAULT - }; - - Command (Value v = Command::DEFAULT) - : v_ (v) - { - } - - operator Value () const - { - return v_; - } - - friend std::ostream& - operator<< (std::ostream& os, Command c); - - friend std::istream& - operator>> (std::istream& is, Command& c); - -private: - Value v_; - static char* labels_[]; -}; - -char* Command::labels_[] = {"help", "version", "default"}; - - -std::ostream& -operator<< (std::ostream& os, Command c) -{ - return os << Command::labels_[c.v_]; -} - -std::istream& -operator>> (std::istream& is, Command& c) -{ - std::string s; - is >> s; - if (is) - { - if (s == Command::labels_[Command::HELP]) c.v_ = Command::HELP; - else if (s == Command::labels_[Command::VERSION]) c.v_ = Command::VERSION; - else is.setstate (std::ios::failbit); - } - return is; -} - -int -main () -{ - Command c = Command::HELP; - - c = Command::DEFAULT; - - Command c1 (Command::HELP); - - c = c1; - - cerr << c << endl; - - switch (c) - { - case Command::HELP: - { - cerr << "iiihuuu!!!" << endl; - } - } - - std::cin >> c1; - if (std::cin) cerr << c1 << endl; - else cerr << "*failed" << endl; -} -//$Id$ diff --git a/ACE/contrib/utility/Example/CommandLine/Foo/foo.cpp b/ACE/contrib/utility/Example/CommandLine/Foo/foo.cpp deleted file mode 100644 index 550d1f6f170..00000000000 --- a/ACE/contrib/utility/Example/CommandLine/Foo/foo.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include <typeinfo> -#include <string> -#include <iostream> - -/* FUZZ: disable check_for_improper_main_declaration */ - -namespace CommandLine -{ - struct Parser - { - }; -} - -using std::string; -using std::cerr; -using std::endl; - -using namespace CommandLine; - -class Command -{ -public: - enum Value - { - HELP, - VERSION, - DEFAULT - }; - - Command (Value v = Command::DEFAULT) - : v_ (v) - { - } - - operator Value () const - { - return v_; - } - -private: - Value v_; -}; - - -int -version (); - -int -help (int argc, char* argv[]); - -int -main (int argc, char* argv[]) -{ - - // Step 1: determine command - // - // * there is usually one command - // * command can be optional - // * command usually takes up one argument - // - - CommandParser<Command> cp; - - switch (cp.parse (argc, argv)) - { - case Command::VERSION: - { - return version (); - } - case Command::HELP: - { - return help (argc, argv); - } - } - - // Step 2: parse options - // - // * options are usually optional - // * options are usually position-independant - // * options usually do not repeat - // * options can take up more than one argument - // - - OptionMap om; - - CompositeParser op; - - op.add (OptionParser<string> ("string", "--string", "-s")); - op.add (OptionParser<unsigned long> ("number", "--number", "-n")); - - while (argc != 1 && !op.empty ()) - { - om.insert (op.parse (argc, argv)); - } - - // Step 3: parse operands - // - // * operands usually position-dependant - // * operand usually take up one argument - // - - OperandParser<string> odp; - - string str = odp.parse (argc, argv); - - unsigned long num = 0; - - if (argc != 1) - { - OperandParser<unsigned long> op; - num = op.parse (argc, argv); - } - - string s = om.count ("string") ? om["string"] : "default"; - unsigned long l = om["number"]; - - // om.at () - // om.get () - // om.resolve () - // om.option () - // om.value () - - cerr << "opreation settings are:" << endl << endl - << "option string : " << om.get<string> ("string", "default") << endl - << "option number : " << om.get ("number", 10UL) << endl - << "operand string : " << str << endl - << "operand number : " << num << endl; -} - - -// -// -// -int -version () -{ - cerr << "foo 1.0" << endl; - return 0; -} - - -// -// -// -int -help (int argc, char* argv[]) -{ - Command subject; - - if (argc != 1) - { - OperandParser<Command> op; - subject = op.parse (argc, argv); - } - - switch (subject) - { - case Command::HELP: - { - cerr << "foo help [<command>]" << endl << endl - << "\t If <command> is specified then print extended help" << endl - << "\t information for specified command. Otherwise print" << endl - << "\t general usage information." << endl; - break; - } - case Command::VERSION: - { - cerr << "foo version" << endl << endl - << "\t Print version information." << endl; - break; - } - default: - { - cerr << "foo version" << endl - << "foo help [<command>]" << endl - << "foo [-s|--string <str>] [-n|--number <num>] <str> [<num>]" - << endl; - break; - } - } - - return 0; -} -//$Id$ diff --git a/ACE/contrib/utility/Example/ExH/BadCast/Makefile b/ACE/contrib/utility/Example/ExH/BadCast/Makefile deleted file mode 100644 index 9963d9708a1..00000000000 --- a/ACE/contrib/utility/Example/ExH/BadCast/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# file : Example/ExH/BadCast/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Executable.pre.rules) - - -cxx_translation_units := bad_cast.cpp - -module_base := bad_cast -module_prefix := -module_suffix := - - -CXX_PREPROCESS_FLAGS += -I $(root) - - -$(call include, $(root)/BuildRules/Executable.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/ExH/BadCast/bad_cast.cpp b/ACE/contrib/utility/Example/ExH/BadCast/bad_cast.cpp deleted file mode 100644 index 699add03047..00000000000 --- a/ACE/contrib/utility/Example/ExH/BadCast/bad_cast.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// file : Example/ExH/BadCast/bad_cast.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -/* FUZZ: disable check_for_improper_main_declaration */ - -#include "Utility/ExH/System/Exception.hpp" - -#include <iostream> - -using std::cerr; -using std::endl; - - -struct A -{ - virtual - ~A() {} -}; - -struct B -{ - void - foo () {} -}; - -void -foo () -{ - A a; - - A& ar (a); - - B& br (dynamic_cast<B&> (ar)); - - br.foo (); -} - -int -main () -{ - try - { - foo (); - } - catch (Utility::ExH::System::Exception const& ex) - { - cerr << "Caught Utility::ExH::System::Exception: " - << ex.what () - << endl; - } -} -//$Id$ diff --git a/ACE/contrib/utility/Example/ExH/Compound/Makefile b/ACE/contrib/utility/Example/ExH/Compound/Makefile deleted file mode 100644 index 8bd588587d5..00000000000 --- a/ACE/contrib/utility/Example/ExH/Compound/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# file : Example/ExH/Compound/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Executable.pre.rules) - - -cxx_translation_units := compound.cpp - -module_base := compound -module_prefix := -module_suffix := - - -CXX_PREPROCESS_FLAGS += -I $(root) - - -$(call include, $(root)/BuildRules/Executable.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/ExH/Compound/compound.cpp b/ACE/contrib/utility/Example/ExH/Compound/compound.cpp deleted file mode 100644 index e9f585ce6d3..00000000000 --- a/ACE/contrib/utility/Example/ExH/Compound/compound.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// file : Example/ExH/Compound/compound.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -/* FUZZ: disable check_for_improper_main_declaration */ - -#include "Utility/ExH/Compound.hpp" -#include "Utility/ExH/System/Exception.hpp" -#include "Utility/ExH/Logic/DescriptiveException.hpp" - -// Include some helper converters to allow exception initialization -// with std::ostringstream - -#include "Utility/ExH/StringStreamConverter.hpp" - -#include <iostream> - -using std::cerr; -using std::endl; -using std::string; -using std::ostringstream; - -using namespace Utility::ExH; - -// Here are our components - -class Base -{ -public: - - // - // Exception definitions. - // - - // Base logic exception class for component. - class Exception_ {}; - typedef - Compound <Exception_, Logic::DescriptiveException> - Exception; - - class InvalidArgument_ {}; - typedef - Compound <InvalidArgument_, Exception> - InvalidArgument; - - class NotInitialized_ {}; - typedef - Compound <NotInitialized_, Exception> - NotInitialized; - -public: - - void - foo (char const* str) - { - // This is just an example. - - if (str == 0) - { - throw InvalidArgument ("Base::foo: first parameter is zero."); - } - else - { - ostringstream ostr; - ostr << "Base::foo [this = " << this << "]: object is not initialized."; - - throw NotInitialized (ostr); - } - } - - - // We don't know what implementation may decide to throw so - // we allow to throw System exception and any logic exception - // derived from Base::Exception - virtual void - vfoo () = 0; -}; - -class Derived : public Base -{ -public: - - // Define some Derived-specific logic exception. - class NotImplemented_ {}; - typedef - Compound <NotImplemented_, Exception> - NotImplemented; - -public: - virtual void - vfoo () - { - std::string str ("Derived::vfoo: not implemented yet."); - throw NotImplemented (str); - } -}; - -int -main () -{ - try - { - - Derived d; - Base* pb (&d); - - // We can use generic handler. - try - { - pb->vfoo (); - } - catch (Base::Exception const& ex) - { - cerr << "Caught Base::Exception: " << ex.what () << endl; - } - - - // Or use more precise control. - try - { - pb->foo ("hello"); - } - catch (Base::NotInitialized const& ex) - { - cerr << "Caught Base::NotInitialized: " << ex.what () << endl; - } - - // Or use application-level handler. - pb->foo (0); - - } - catch (Logic::Exception const& ex) - { - cerr << "Caught Logic::Exception: " << ex.what () << endl; - } - catch (...) - { - cerr << "Caught unknown exception using catch-all handler" << endl; - return -1; - } - -} -//$Id$ diff --git a/ACE/contrib/utility/Example/ExH/HelloWorld/Makefile b/ACE/contrib/utility/Example/ExH/HelloWorld/Makefile deleted file mode 100644 index 93debef0e7c..00000000000 --- a/ACE/contrib/utility/Example/ExH/HelloWorld/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# file : Example/ExH/HelloWorld/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Executable.pre.rules) - - -cxx_translation_units := hello_world.cpp - -module_base := hello_world -module_prefix := -module_suffix := - - -CXX_PREPROCESS_FLAGS += -I $(root) - - -$(call include, $(root)/BuildRules/Executable.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp b/ACE/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp deleted file mode 100644 index 9499bf09fe1..00000000000 --- a/ACE/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// file : Example/ExH/HelloWorld/hello_world.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -/* FUZZ: disable check_for_improper_main_declaration */ - -#include <cstdlib> // for std::abort () - -#include <string> -#include <iostream> - -#include "Utility/ExH/System/Exception.hpp" -#include "Utility/ExH/Logic/Exception.hpp" - -using std::cerr; -using std::cout; -using std::endl; - -using namespace Utility; - -class Application -{ -public: - class Exception : public ExH::Logic::Exception {}; - - // Hint: you may want to try again... - class FeelingDizzy : public Exception {}; - - class InvalidArg : public Exception {}; - -public: - Application () - : // The std::string c-tor may throw any kind of exceptions besides - // quite possible std::bad_alloc. - greeting_ ("Hello, world!") - { - } - - Application (char const * greeting) - : greeting_ (greeting == 0 ? "" : greeting) - { - if (greeting == 0) throw InvalidArg (); - } - -public: - - void - run () - { - static unsigned int dizzy_count (0); - - if (dizzy_count++ < 5) throw FeelingDizzy (); - - // The next line can throw full bucket of exceptions - // not to mention ios_base::failure. - cout << greeting_.c_str () << endl; - } - -private: - - std::string greeting_; -}; - - - -int -main () -{ - // This is a catch-all layer that should be in use only - // if we are really in trouble. - try - { - // This is a catch-system layer. Here we will catch exceptions like - // bad_alloc, etc. If we get here it means that nobody wanted/managed - // to recover from this kind of errors. - try - { - // This is a catch-logic layer. If we get here it usually - // indicates an application logic error. - try - { - - // Ok, here we go about our application logic. - try - { - for (int i = 0; i < 10; i++) - { - try - { - Application app ("Hi dude!"); - app.run (); - break; - } - catch (Application::FeelingDizzy const& ) - { - if (i == 9) - { - cerr << "Given up!" << endl; - return -1; - } - else - { - cerr << "Application is feeling dizzy. Trying again..." - << endl; - } - } - } - } - catch (Application::InvalidArg const& ) - { - cerr << "Cought Application::InvalidArg : ...hmm... strange!" - << endl; - return -1; - } - } - catch (ExH::Logic::Exception const& e) - { - cerr << "Caught Logic::Exception : " << e.what () << endl; - return -1; - } - } - catch (const ExH::System::Exception& e) - { - cerr << "Caught System::Exception : " << e.what () << endl; - return -1; - } - catch (...) - { - cerr << "Caught unknown exception using catch-all handler. " << endl; - return -1; - } - } - catch (...) - { - // We get here in cases of some hard failure. For example when handling - // exception, operator << throws another exception. Usually application - // cannot handle such failures itself so we just propagate it futher. - std::abort (); - } -} -//$Id$ diff --git a/ACE/contrib/utility/Example/ExH/LogicToSystem/Makefile b/ACE/contrib/utility/Example/ExH/LogicToSystem/Makefile deleted file mode 100644 index 789413c0a3c..00000000000 --- a/ACE/contrib/utility/Example/ExH/LogicToSystem/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# file : Example/ExH/LogicToSystem/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Executable.pre.rules) - - -cxx_translation_units := logic_to_system.cpp - -module_base := logic_to_system -module_prefix := -module_suffix := - - -CXX_PREPROCESS_FLAGS += -I $(root) - - -$(call include, $(root)/BuildRules/Executable.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp b/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp deleted file mode 100644 index 6f718e9c694..00000000000 --- a/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// file : Example/ExH/LogicToSystem/logic_to_system.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -/* FUZZ: disable check_for_improper_main_declaration */ - -#include "Utility/ExH/System/Exception.hpp" -#include "Utility/ExH/Logic/Exception.hpp" - -#include <iostream> - -using std::cerr; -using std::endl; - - -struct SubsystemA -{ - class Exception : public Utility::ExH::Logic::Exception {}; - - void - foo () - { - throw Exception (); - } -}; - - -struct SubsystemB -{ - void - foo () - { - SubsystemA a; - a.foo (); - - // Here SubsystemB is using SunsystemA but cannot (forgot, doesnt't - // want to, doesn't know how to, etc - pick your favorite) handle - // exception thrown by SubsystemA. As a result exception is - // 'converted' to System::Exception. - } -}; - - -int -main () -{ - try - { - SubsystemB b; - b.foo (); - } - catch (Utility::ExH::System::Exception const& ex) - { - cerr << "Caught Utility::ExH::System::Exception: " - << ex.what () - << endl; - } -} -//$Id$ diff --git a/ACE/contrib/utility/Example/ExH/Makefile b/ACE/contrib/utility/Example/ExH/Makefile deleted file mode 100644 index 99eb95cf62f..00000000000 --- a/ACE/contrib/utility/Example/ExH/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : Example/ExH/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Recursion.pre.rules) - -target_makefile_list := -target_directory_list := BadCast Compound HelloWorld LogicToSystem - -$(call include, $(root)/BuildRules/Recursion.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/Hetero/Container/Makefile b/ACE/contrib/utility/Example/Hetero/Container/Makefile deleted file mode 100644 index 29135f54046..00000000000 --- a/ACE/contrib/utility/Example/Hetero/Container/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# file : Example/Hetero/Container/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Executable.pre.rules) - - -cxx_translation_units := container.cpp - -module_base := container -module_prefix := -module_suffix := - - -CXX_PREPROCESS_FLAGS += -I $(root) - - -$(call include, $(root)/BuildRules/Executable.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/Hetero/Container/container.cpp b/ACE/contrib/utility/Example/Hetero/Container/container.cpp deleted file mode 100644 index 30bc05fc1b9..00000000000 --- a/ACE/contrib/utility/Example/Hetero/Container/container.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// file : Example/Hetero/Container/container.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -/* FUZZ: disable check_for_improper_main_declaration */ - -#include "Utility/Hetero/Container.hpp" -#include "Utility/Hetero/TypedContainer.hpp" -#include "Utility/Hetero/Vector.hpp" -#include "Utility/Hetero/Shell.hpp" - -#include <string> -#include <iostream> -#include <algorithm> - -using std::string; - -using std::cout; -using std::cerr; -using std::endl; - -namespace Hetero = Utility::Hetero; - -using Hetero::Container; -using Hetero::TypedContainer; -using Hetero::TypeList; -using Hetero::Shell; - - -struct PrintCore -{ - typedef void RetType; - - template <typename T> - void - operator() (T const& t) - { - cout << t << endl; - } -}; - -typedef Shell<PrintCore> Print; - -void -print (bool b) -{ - cout << (b ? "T" : "NIL") << endl; -} - -int -main () -{ - try - { - Container a (10L); - Container b (true); - Container c (string ("hello")); - - string s = c + string (" world"); - - long l = a + 20L; - - cout << s << "; " << l << endl; - - print (b); - - // - // - // - - typedef - TypedContainer <TypeList<long, bool, string> > - MyContainer; - - MyContainer x (true); - MyContainer y (10L); - MyContainer z (string ("hey dude")); - - Print print; - - print (x); - print (y); - print (z); - - // - // - // - - typedef - Hetero::Vector<long, bool, string> - vector; - - vector v; - v.push_back (10L); - v.push_back (true); - v.push_back (false); - v.push_back (string ("hey")); - - for (vector::iterator i = v.begin (); i != v.end (); i++) - { - print (*i); - } - - std::for_each (v.begin (), v.end (), print); - } - catch (Hetero::Typing const&) - { - cerr << "typing error" << endl; - } -} -//$Id$ diff --git a/ACE/contrib/utility/Example/Hetero/Makefile b/ACE/contrib/utility/Example/Hetero/Makefile deleted file mode 100644 index a55938e9502..00000000000 --- a/ACE/contrib/utility/Example/Hetero/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : Example/Hetero/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Recursion.pre.rules) - -target_makefile_list := -target_directory_list := Container - -$(call include, $(root)/BuildRules/Recursion.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.cpp b/ACE/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.cpp deleted file mode 100644 index 0dbc616483e..00000000000 --- a/ACE/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// file : Hierarchy.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -#include "Hierarchy.hpp" - -// A -// -// - -using Introspection::Object; -using Introspection::Access; - -namespace -{ - TypeInfo - a_init_ () - { - TypeInfo ti (typeid (A)); - ti.add_base (Access::PUBLIC, true, Object::static_type_info ()); - return ti; - } - - TypeInfo a_ (a_init_ ()); -} - -TypeInfo const& A:: -static_type_info () -{ - return a_; -} - -// B -// -// - -namespace -{ - TypeInfo - b_init_ () - { - TypeInfo ti (typeid (B)); - ti.add_base (Access::PUBLIC, false, A::static_type_info ()); - return ti; - } - - TypeInfo b_ (b_init_ ()); -} - -TypeInfo const& B:: -static_type_info () -{ - return b_; -} - -// C -// -// - -namespace -{ - TypeInfo - c_init_ () - { - TypeInfo ti (typeid (C)); - ti.add_base (Access::PUBLIC, true, A::static_type_info ()); - return ti; - } - - TypeInfo c_ (c_init_ ()); -} - -TypeInfo const& C:: -static_type_info () -{ - return c_; -} - - -// D -// -// - -namespace -{ - TypeInfo - d_init_ () - { - TypeInfo ti (typeid (D)); - ti.add_base (Access::PUBLIC, true, B::static_type_info ()); - ti.add_base (Access::PUBLIC, false, C::static_type_info ()); - return ti; - } - - TypeInfo d_ (d_init_ ()); -} - -TypeInfo const& D:: -static_type_info () -{ - return d_; -} -//$Id$ diff --git a/ACE/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.hpp b/ACE/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.hpp deleted file mode 100644 index 213e0593f6b..00000000000 --- a/ACE/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// file : Example/Introspection/InheritanceTree/Hierarchy.hpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -#ifndef HIERARCHY_HPP -#define HIERARCHY_HPP - -#include "Utility/Introspection/Introspection.hpp" - -namespace Introspection = Utility::Introspection; - -using Introspection::TypeInfo; -using Introspection::TypeId; - -struct A : virtual Introspection::Object -{ - A () - { - type_info (static_type_info ()); - } - - static TypeInfo const& - static_type_info (); -}; - -struct B : virtual A -{ - B () - { - type_info (static_type_info ()); - } - - static TypeInfo const& - static_type_info (); -}; - -struct C : virtual A -{ - C () - { - type_info (static_type_info ()); - } - - static TypeInfo const& - static_type_info (); -}; - -struct D : virtual B, C -{ - D () - { - type_info (static_type_info ()); - } - - static TypeInfo const& - static_type_info (); -}; - -#endif // HIERARCHY_HPP -//$Id$ diff --git a/ACE/contrib/utility/Example/Introspection/InheritanceTree/Makefile b/ACE/contrib/utility/Example/Introspection/InheritanceTree/Makefile deleted file mode 100644 index 9b839c2111f..00000000000 --- a/ACE/contrib/utility/Example/Introspection/InheritanceTree/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# file : Example/Introspection/InheritanceTree/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Executable.pre.rules) - - -cxx_translation_units := Hierarchy.cpp inheritance_tree.cpp - -module_base := inheritance_tree - -CXX_PREPROCESS_FLAGS += -I $(root) - -CXX_LINK_LIBS += -L$(root)/Utility/Introspection -lIntrospection - -$(call include, $(root)/BuildRules/Executable.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp b/ACE/contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp deleted file mode 100644 index 61f68ab6aa5..00000000000 --- a/ACE/contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// file : Example/Introspection/InheritanceTree/inheritance_tree.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -// Note: This example is by no means complete. In fact properly printing -// arbitrary C++ inheritance tree is a non-trivial task. If you would like -// to improve this example please feel free to send your results back ;-). - -/* FUZZ: disable check_for_improper_main_declaration */ - -#include "Hierarchy.hpp" - -#include <set> -#include <iostream> - -using std::endl; - -typedef -std::set<TypeId> -TypeIdSet; - -void -print_inheritance_tree_core (std::ostream& os, - TypeInfo const& ti, - TypeIdSet& set) -{ - bool nl = false; - - for (TypeInfo::BaseIterator i = ti.begin_base (); - i != ti.end_base (); - i++) - { - TypeId tid (i->type_info ().type_id ()); - - if (set.find (tid) != set.end ()) continue; - - nl = true; - set.insert (tid); - print_inheritance_tree_core (os, i->type_info (), set); - } - - if (nl) os << endl; - - os << ti.type_id () << " "; -} - -void -print_inheritance_tree (std::ostream& os, TypeInfo const& ti) -{ - TypeIdSet set; - print_inheritance_tree_core (os, ti, set); - os << endl; -} - -int -main () -{ - B* b = new D; - - print_inheritance_tree (std::cout, b->type_info ()); - - delete b; -} -//$Id$ diff --git a/ACE/contrib/utility/Example/Introspection/Makefile b/ACE/contrib/utility/Example/Introspection/Makefile deleted file mode 100644 index 2dc0a1f809e..00000000000 --- a/ACE/contrib/utility/Example/Introspection/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : Example/Introspection/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Recursion.pre.rules) - -target_makefile_list := -target_directory_list := InheritanceTree Traversal - -$(call include, $(root)/BuildRules/Recursion.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/Introspection/Traversal/Makefile b/ACE/contrib/utility/Example/Introspection/Traversal/Makefile deleted file mode 100644 index c9b1a8da46a..00000000000 --- a/ACE/contrib/utility/Example/Introspection/Traversal/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# file : Example/Introspection/Traversal/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := ../../.. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Executable.pre.rules) - - -cxx_translation_units := SyntaxTree.cpp Traversal.cpp driver.cpp - -module_base := driver - -CXX_PREPROCESS_FLAGS += -I $(root) - -CXX_LINK_LIBS += -L$(root)/Utility/Introspection -lIntrospection - -$(call include, $(root)/BuildRules/Executable.post.rules) -# $Id$ diff --git a/ACE/contrib/utility/Example/Introspection/Traversal/SyntaxTree.cpp b/ACE/contrib/utility/Example/Introspection/Traversal/SyntaxTree.cpp deleted file mode 100644 index 71115ff2b24..00000000000 --- a/ACE/contrib/utility/Example/Introspection/Traversal/SyntaxTree.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// file : Example/Introspection/Traversal/SyntaxTree.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -#include "SyntaxTree.hpp" - -using namespace Utility::Introspection; - -namespace SyntaxTree -{ - - // Node - // - // - - namespace - { - TypeInfo - node_init_ () - { - TypeInfo ti (typeid (Node)); - ti.add_base (Access::PUBLIC, true, Object::static_type_info ()); - return ti; - } - - TypeInfo node_ (node_init_ ()); - } - - TypeInfo const& Node:: - static_type_info () { return node_; } - - - // Declaration - // - // - - namespace - { - TypeInfo - declaration_init_ () - { - TypeInfo ti (typeid (Declaration)); - ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); - return ti; - } - - TypeInfo declaration_ (declaration_init_ ()); - } - - TypeInfo const& Declaration:: - static_type_info () { return declaration_; } - - - // Scope - // - // - - namespace - { - TypeInfo - scope_init_ () - { - TypeInfo ti (typeid (Scope)); - ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); - return ti; - } - - TypeInfo scope_ (scope_init_ ()); - } - - TypeInfo const& Scope:: - static_type_info () { return scope_; } - - - // InterfaceDecl - // - // - - namespace - { - TypeInfo - interface_decl_init_ () - { - TypeInfo ti (typeid (InterfaceDecl)); - ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); - return ti; - } - - TypeInfo interface_decl_ (interface_decl_init_ ()); - } - - TypeInfo const& InterfaceDecl:: - static_type_info () { return interface_decl_; } - - - // InterfaceDef - // - // - - namespace - { - TypeInfo - interface_def_init_ () - { - TypeInfo ti (typeid (InterfaceDef)); - ti.add_base (Access::PUBLIC, true, InterfaceDecl::static_type_info ()); - ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); - return ti; - } - - TypeInfo interface_def_ (interface_def_init_ ()); - } - - TypeInfo const& InterfaceDef:: - static_type_info () { return interface_def_; } - -} -//$Id$ diff --git a/ACE/contrib/utility/Example/Introspection/Traversal/SyntaxTree.hpp b/ACE/contrib/utility/Example/Introspection/Traversal/SyntaxTree.hpp deleted file mode 100644 index 7bd824ce683..00000000000 --- a/ACE/contrib/utility/Example/Introspection/Traversal/SyntaxTree.hpp +++ /dev/null @@ -1,95 +0,0 @@ -// file : Example/Introspection/Traversal/SyntaxTree.hpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -#ifndef SYNTAX_TREE_HPP -#define SYNTAX_TREE_HPP - -#include <vector> - -#include "Utility/Introspection/Introspection.hpp" - -namespace SyntaxTree -{ - // - // - // - - struct Node : virtual Utility::Introspection::Object - { - Node () - { - type_info (static_type_info ()); - } - - static Utility::Introspection::TypeInfo const& - static_type_info (); - }; - - // - // - // - - struct Declaration : virtual Node - { - Declaration () - { - type_info (static_type_info ()); - } - - static Utility::Introspection::TypeInfo const& - static_type_info (); - }; - - typedef - std::vector<Declaration*> - DeclarationList; - - // - // - // - struct Scope : virtual Declaration - { - Scope () - { - type_info (static_type_info ()); - } - - static Utility::Introspection::TypeInfo const& - static_type_info (); - - DeclarationList content_; - }; - - // - // - // - struct InterfaceDecl : virtual Declaration - { - InterfaceDecl () - { - type_info (static_type_info ()); - } - - static Utility::Introspection::TypeInfo const& - static_type_info (); - }; - - // - // - // - struct InterfaceDef : virtual InterfaceDecl, virtual Scope - { - InterfaceDef () - { - type_info (static_type_info ()); - } - - static Utility::Introspection::TypeInfo const& - static_type_info (); - }; -} - -#endif // SYNTAX_TREE_HPP -//$Id$ diff --git a/ACE/contrib/utility/Example/Introspection/Traversal/Traversal.cpp b/ACE/contrib/utility/Example/Introspection/Traversal/Traversal.cpp deleted file mode 100644 index 9fa94327c2c..00000000000 --- a/ACE/contrib/utility/Example/Introspection/Traversal/Traversal.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// file : Example/Introspection/Traversal/Traversal.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -#include "Traversal.hpp" - -#include <set> -#include <map> - -using namespace Utility::Introspection; - -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::Node* n) - { - LevelMap levels; - - unsigned long max = compute_levels (n->type_info (), 0, levels); - - 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->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); - } - } - } -} -//$Id$ diff --git a/ACE/contrib/utility/Example/Introspection/Traversal/Traversal.hpp b/ACE/contrib/utility/Example/Introspection/Traversal/Traversal.hpp deleted file mode 100644 index 7ee84523fc0..00000000000 --- a/ACE/contrib/utility/Example/Introspection/Traversal/Traversal.hpp +++ /dev/null @@ -1,157 +0,0 @@ -// file : Example/Introspection/Traversal/Traversal.hpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -#ifndef TRAVERSAL_HPP -#define TRAVERSAL_HPP - -#include <map> -#include <iostream> - -#include "Utility/Introspection/Introspection.hpp" - -#include "SyntaxTree.hpp" - -namespace Traversal -{ - class Traverser; - - // - // - // - class Dispatcher - { - public: - virtual - ~Dispatcher () - { - } - - virtual void - dispatch (SyntaxTree::Node* n); - - protected: - void - map (Utility::Introspection::TypeId id, Traverser* t) - { - traversal_map_[id] = t; - } - - private: - typedef - std::map<Utility::Introspection::TypeId, Traverser*> - TraversalMap; - - TraversalMap traversal_map_; - }; - - - // - // - // - class Traverser : public virtual Dispatcher - { - public: - virtual void - traverse (SyntaxTree::Node* n) = 0; - }; - - // - // - // - struct Node : Traverser - { - Node () - { - map (typeid (SyntaxTree::Node), this); - } - - virtual void - traverse (SyntaxTree::Node*) - { - std::cerr << "node" << std::endl; - } - }; - - - // - // - // - struct Declaration : Traverser - { - Declaration () - { - map (typeid (SyntaxTree::Declaration), this); - } - - virtual void - traverse (SyntaxTree::Node*) - { - std::cerr << "declaration" << std::endl; - } - }; - - // - // - // - struct Scope : Traverser - { - Scope () - { - map (typeid (SyntaxTree::Scope), this); - } - - virtual void - traverse (SyntaxTree::Node* n) - { - std::cerr << "scope" << std::endl; - - SyntaxTree::Scope* s = dynamic_cast<SyntaxTree::Scope*> (n); - - for (SyntaxTree::DeclarationList::iterator i = s->content_.begin (); - i != s->content_.end (); - i++) - { - dispatch (*i); - } - } - }; - - // - // - // - struct InterfaceDecl : Traverser - { - InterfaceDecl () - { - map (typeid (SyntaxTree::InterfaceDecl), this); - } - - virtual void - traverse (SyntaxTree::Node*) - { - std::cerr << "interface declaration" << std::endl; - } - }; - - // - // - // - struct InterfaceDef : Traverser - { - InterfaceDef () - { - map (typeid (SyntaxTree::InterfaceDef), this); - } - - virtual void - traverse (SyntaxTree::Node*) - { - std::cerr << "interface definition" << std::endl; - } - }; -} - -#endif // TRAVERSAL_HPP -//$Id$ diff --git a/ACE/contrib/utility/Example/Introspection/Traversal/driver.cpp b/ACE/contrib/utility/Example/Introspection/Traversal/driver.cpp deleted file mode 100644 index 30e1a4a3ab7..00000000000 --- a/ACE/contrib/utility/Example/Introspection/Traversal/driver.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// file : Example/Introspection/Traversal/driver.cpp -// author : Boris Kolpackov <boris@kolpackov.net> -// copyright : Copyright (c) 2002-2003 Boris Kolpackov -// license : http://kolpackov.net/license.html - -/* FUZZ: disable check_for_improper_main_declaration */ - -#include <iostream> - -#include "SyntaxTree.hpp" -#include "Traversal.hpp" - -int -main () -{ - using namespace SyntaxTree; - - /* - Create a syntax tree that looks something like this: - - scope - { - interface declaration; - - scope - { - interface definition - { - decalartion; - }; - }; - }; - - */ - - Scope s1; - - InterfaceDecl i1; - s1.content_.push_back (&i1); - - Scope s2; - s1.content_.push_back (&s2); - - InterfaceDef i2; - s2.content_.push_back (&i2); - - Declaration d1; - i2.content_.push_back (&d1); - - SyntaxTree::Node* root = &s1; - - // Now different ways of traversing this tree: - - { - std::cout << "test #1" << std::endl; - - struct Generator : Traversal::Declaration, Traversal::Scope - { - }; - - Generator g; - g.dispatch (root); - - std::cout << std::endl; - } - - { - std::cout << "test #2" << std::endl; - - struct Generator : Traversal::Scope, Traversal::InterfaceDecl - { - }; - - Generator g; - g.dispatch (root); - - std::cout << std::endl; - } - - { - std::cout << "test #3" << std::endl; - - struct Generator : Traversal::Scope, Traversal::InterfaceDef - { - }; - - Generator g; - g.dispatch (root); - - std::cout << std::endl; - } -} -//$Id$ diff --git a/ACE/contrib/utility/Example/Makefile b/ACE/contrib/utility/Example/Makefile deleted file mode 100644 index 1caefc91a39..00000000000 --- a/ACE/contrib/utility/Example/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : Example/Makefile -# author : Boris Kolpackov <boris@kolpackov.net> -# copyright : Copyright (c) 2002-2003 Boris Kolpackov -# license : http://kolpackov.net/license.html - -root := .. - -include $(root)/BuildRules/Bootstrap.rules - -$(call include, $(root)/BuildRules/Recursion.pre.rules) - -target_makefile_list := -target_directory_list := ExH Hetero Introspection - -$(call include, $(root)/BuildRules/Recursion.post.rules) -# $Id$ |