From 10e1c1963096586b484988958539756385ce2c35 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Nov 2011 12:36:25 +0200 Subject: Get rid of special tracer database The include, types, and pragma tests have been moved to the common/ directory while the object test has been merged into common/lifecycle. The transaction test will be re-implemented as common/ test as soon as SQL statement tracing support is merged. --- odb/context.cxx | 5 -- odb/generator.cxx | 26 -------- odb/makefile | 7 -- odb/option-functions.cxx | 4 -- odb/option-types.cxx | 3 +- odb/option-types.hxx | 3 +- odb/options.cli | 2 +- odb/processor.cxx | 7 +- odb/tracer/generate.hxx | 30 --------- odb/tracer/header.cxx | 145 ----------------------------------------- odb/tracer/inline.cxx | 92 -------------------------- odb/tracer/source.cxx | 165 ----------------------------------------------- 12 files changed, 5 insertions(+), 484 deletions(-) delete mode 100644 odb/tracer/generate.hxx delete mode 100644 odb/tracer/header.cxx delete mode 100644 odb/tracer/inline.cxx delete mode 100644 odb/tracer/source.cxx diff --git a/odb/context.cxx b/odb/context.cxx index 2e96ba9..9842a22 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -128,11 +128,6 @@ create_context (ostream& os, r.reset (new relational::sqlite::context (os, unit, ops, m)); break; } - case database::tracer: - { - r.reset (new context (os, unit, ops)); - break; - } } return r; diff --git a/odb/generator.cxx b/odb/generator.cxx index 6c1fda4..d7ceb86 100644 --- a/odb/generator.cxx +++ b/odb/generator.cxx @@ -19,7 +19,6 @@ #include #include -#include #include using namespace std; @@ -111,11 +110,6 @@ generate (options const& ops, semantics::unit& unit, path const& p) model = relational::model::generate (); break; } - case database::tracer: - { - cerr << "error: the tracer database does not have schema" << endl; - throw failed (); - } } } @@ -267,11 +261,6 @@ generate (options const& ops, semantics::unit& unit, path const& p) relational::header::generate (); break; } - case database::tracer: - { - tracer::header::generate (); - break; - } } hxx << "#include " << ctx->process_include_path (ixx_name) << endl @@ -319,11 +308,6 @@ generate (options const& ops, semantics::unit& unit, path const& p) relational::inline_::generate (); break; } - case database::tracer: - { - tracer::inline_::generate (); - break; - } } // Copy epilogue. @@ -366,11 +350,6 @@ generate (options const& ops, semantics::unit& unit, path const& p) relational::source::generate (); break; } - case database::tracer: - { - tracer::source::generate (); - break; - } } // Copy epilogue. @@ -405,11 +384,6 @@ generate (options const& ops, semantics::unit& unit, path const& p) relational::schema::generate (); break; } - case database::tracer: - { - cerr << "error: the tracer database does not have schema" << endl; - throw failed (); - } } // Copy epilogue. diff --git a/odb/makefile b/odb/makefile index dd277de..3550c50 100644 --- a/odb/makefile +++ b/odb/makefile @@ -26,13 +26,6 @@ parser.cxx \ plugin.cxx \ pragma.cxx -# Tracer. -# -cxx_ptun += \ -tracer/header.cxx \ -tracer/inline.cxx \ -tracer/source.cxx - # Relational. # cxx_ptun += \ diff --git a/odb/option-functions.cxx b/odb/option-functions.cxx index bd4ec09..4410817 100644 --- a/odb/option-functions.cxx +++ b/odb/option-functions.cxx @@ -32,10 +32,6 @@ process_options (options& o) f.insert (schema_format::embedded); break; } - case database::tracer: - { - break; - } } o.schema_format (f); diff --git a/odb/option-types.cxx b/odb/option-types.cxx index d1cccb4..c3c02fb 100644 --- a/odb/option-types.cxx +++ b/odb/option-types.cxx @@ -19,8 +19,7 @@ static const char* database_[] = "mysql", "oracle", "pgsql", - "sqlite", - "tracer" + "sqlite" }; const char* database:: diff --git a/odb/option-types.hxx b/odb/option-types.hxx index 683095d..60d602a 100644 --- a/odb/option-types.hxx +++ b/odb/option-types.hxx @@ -17,8 +17,7 @@ struct database mysql, oracle, pgsql, - sqlite, - tracer + sqlite }; database (value v = value (0)) : v_ (v) {} diff --git a/odb/options.cli b/odb/options.cli index 898d0d9..6008d56 100644 --- a/odb/options.cli +++ b/odb/options.cli @@ -49,7 +49,7 @@ class options { "", "Generate code for the database. Valid values are \cb{mysql}, - \cb{oracle}, \cb{pgsql}, \cb{sqlite}, and \cb{tracer}." + \cb{oracle}, \cb{pgsql}, and \cb{sqlite}." }; bool --generate-query | -q diff --git a/odb/processor.cxx b/odb/processor.cxx index 2779957..590042c 100644 --- a/odb/processor.cxx +++ b/odb/processor.cxx @@ -19,11 +19,8 @@ process (options const& ops, semantics::unit& unit, semantics::path const&) { // Process types. // - if (ops.database () != database::tracer) - { - auto_ptr ctx (create_context (cerr, unit, ops, 0)); - relational::process (); - } + auto_ptr ctx (create_context (cerr, unit, ops, 0)); + relational::process (); } catch (operation_failed const&) { diff --git a/odb/tracer/generate.hxx b/odb/tracer/generate.hxx deleted file mode 100644 index 32cd993..0000000 --- a/odb/tracer/generate.hxx +++ /dev/null @@ -1,30 +0,0 @@ -// file : odb/tracer/generate.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v3; see accompanying LICENSE file - -#ifndef ODB_TRACER_GENERATE_HXX -#define ODB_TRACER_GENERATE_HXX - -namespace tracer -{ - namespace header - { - void - generate (); - } - - namespace inline_ - { - void - generate (); - } - - namespace source - { - void - generate (); - } -} - -#endif // ODB_TRACER_GENERATE_HXX diff --git a/odb/tracer/header.cxx b/odb/tracer/header.cxx deleted file mode 100644 index f4a3a72..0000000 --- a/odb/tracer/header.cxx +++ /dev/null @@ -1,145 +0,0 @@ -// file : odb/tracer/header.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v3; see accompanying LICENSE file - -#include -#include -#include - -using namespace std; - -namespace tracer -{ - namespace - { - struct class_: traversal::class_, context - { - virtual void - traverse (type& c) - { - if (c.file () != unit.file ()) - return; - - if (!object (c)) - return; - - string const& type (c.fq_name ()); - - semantics::data_member& id (*id_member (c)); - bool auto_id (id.count ("auto")); - - os << "// " << c.name () << endl - << "//" << endl; - - os << "template <>" << endl - << "class access::object_traits< " << type << " >" - << "{" - << "public:" << endl; - - // object_type & pointer_type - // - os << "typedef " << type << " object_type;" - << "typedef object_type* pointer_type;"; - - // id_type - // - { - semantics::names* hint; - semantics::type& t (utype (id, hint)); - - os << "typedef " << t.fq_name (hint) << " id_type;" - << endl; - } - - // type_name () - // - os << "static const char*" << endl - << "type_name ();" - << endl; - - // id () - // - os << "static id_type" << endl - << "id (const object_type&);" - << endl; - - // persist () - // - os << "static void" << endl - << "persist (database&, " << (auto_id ? "" : "const ") << - "object_type&);" - << endl; - - // update () - // - os << "static void" << endl - << "update (database&, const object_type&);" - << endl; - - // erase (id_type) - // - os << "static void" << endl - << "erase (database&, const id_type&);" - << endl; - - // erase (object_type) - // - os << "static void" << endl - << "erase (database&, const object_type&);" - << endl; - - // find () - // - os << "static pointer_type" << endl - << "find (database&, const id_type&);" - << endl; - - os << "static bool" << endl - << "find (database&, const id_type&, object_type&);"; - - // callback () - // - os << "static void" << endl - << "callback (database&, object_type&, callback_event);" - << endl; - - os << "static void" << endl - << "callback (database&, const object_type&, callback_event);" - << endl; - - os << "};"; - } - }; - } - - namespace header - { - void - generate () - { - context ctx; - ostream& os (ctx.os); - - traversal::unit unit; - traversal::defines unit_defines; - traversal::namespace_ ns; - class_ c; - - unit >> unit_defines >> ns; - unit_defines >> c; - - traversal::defines ns_defines; - - ns >> ns_defines >> ns; - ns_defines >> c; - - os << "namespace odb" - << "{"; - - unit.dispatch (ctx.unit); - - os << "}"; - } - } -} diff --git a/odb/tracer/inline.cxx b/odb/tracer/inline.cxx deleted file mode 100644 index de4282a..0000000 --- a/odb/tracer/inline.cxx +++ /dev/null @@ -1,92 +0,0 @@ -// file : odb/tracer/inline.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v3; see accompanying LICENSE file - -#include -#include -#include - -using namespace std; - -namespace tracer -{ - namespace - { - struct class_: traversal::class_, context - { - virtual void - traverse (type& c) - { - if (c.file () != unit.file ()) - return; - - if (!object (c)) - return; - - string const& type (c.fq_name ()); - string traits ("access::object_traits< " + type + " >"); - - semantics::data_member& id (*id_member (c)); - - os << "// " << c.name () << endl - << "//" << endl - << endl; - - // id () - // - os << "inline" << endl - << traits << "::id_type" << endl - << traits << "::" << endl - << "id (const object_type& obj)" - << "{" - << "return obj." << id.name () << ";" << endl - << "}"; - - // callback () - // - os << "inline" << endl - << "void " << traits << "::" << endl - << "callback (database&, object_type&, callback_event)" - << "{" - << "}"; - - os << "inline" << endl - << "void " << traits << "::" << endl - << "callback (database&, const object_type&, callback_event)" - << "{" - << "}"; - } - }; - } - - namespace inline_ - { - void - generate () - { - context ctx; - ostream& os (ctx.os); - - traversal::unit unit; - traversal::defines unit_defines; - traversal::namespace_ ns; - class_ c; - - unit >> unit_defines >> ns; - unit_defines >> c; - - traversal::defines ns_defines; - - ns >> ns_defines >> ns; - ns_defines >> c; - - os << "namespace odb" - << "{"; - - unit.dispatch (ctx.unit); - - os << "}"; - } - } -} diff --git a/odb/tracer/source.cxx b/odb/tracer/source.cxx deleted file mode 100644 index 5eaa5ad..0000000 --- a/odb/tracer/source.cxx +++ /dev/null @@ -1,165 +0,0 @@ -// file : odb/tracer/source.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v3; see accompanying LICENSE file - -#include -#include -#include - -using namespace std; - -namespace tracer -{ - namespace - { - struct class_: traversal::class_, context - { - virtual void - traverse (type& c) - { - if (c.file () != unit.file ()) - return; - - if (!object (c)) - return; - - string const& type (c.fq_name ()); - string traits ("access::object_traits< " + type + " >"); - - semantics::data_member& id (*id_member (c)); - bool auto_id (id.count ("auto")); - - os << "// " << c.name () << endl - << "//" << endl - << endl; - - // type_name () - // - os << "const char* " << traits << "::" << endl - << "type_name ()" - << "{" - << "return \"" << type << "\";" - << "}"; - - // persist () - // - os << "void " << traits << "::" << endl - << "persist (database&, " << (auto_id ? "" : "const ") << - "object_type& obj)" - << "{" - << "std::cout << \"insert \" << type_name () << \" id \" << " << - "id (obj) << std::endl;" - << endl - << "if (id (obj) == id_type ())" << endl - << "throw object_already_persistent ();" - << "}"; - - // update () - // - os << "void " << traits << "::" << endl - << "update (database&, const object_type& obj)" - << "{" - << "std::cout << \"update \" << type_name () << \" id \" << " << - "id (obj) << std::endl;" - << endl - << "if (id (obj) == id_type ())" << endl - << "throw object_not_persistent ();" - << "}"; - - // erase (id_type) - // - os << "void " << traits << "::" << endl - << "erase (database&, const id_type& id)" - << "{" - << "std::cout << \"delete \" << type_name () << \" id \" << " << - "id << std::endl;" - << endl - << "if (id == id_type ())" << endl - << "throw object_not_persistent ();" - << "}"; - - // erase (object_type) - // - os << "void " << traits << "::" << endl - << "erase (database&, const object_type& obj)" - << "{" - << "std::cout << \"delete \" << type_name () << \" id \" << " << - "obj." << id.name () << " << std::endl;" - << endl - << "if (obj." << id.name () << " == id_type ())" << endl - << "throw object_not_persistent ();" - << "}"; - - // find () - // - os << traits << "::pointer_type" << endl - << traits << "::" << endl - << "find (database&, const id_type& id)" - << "{" - << "std::cout << \"select \" << type_name () << \" id \" << " << - "id << std::endl;" - << endl - << "if (id == id_type ())" << endl - << "return pointer_type (0);" - << endl - << "pointer_type r (access::object_factory< object_type, " << - "pointer_type >::create ());" - << "pointer_traits< pointer_type >::guard g (r);" - << "r->" << id.name () << " = id;" - << "g.release ();" - << "return r;" - << "}"; - - os << "bool " << traits << "::" << endl - << "find (database&, const id_type& id, object_type& obj)" - << "{" - << "std::cout << \"select \" << type_name () << \" id \" << " << - "id << std::endl;" - << endl - << "if (id == id_type ())" << endl - << "return false;" - << endl - << "obj." << id.name () << " = id;" - << "return true;" - << "}"; - } - }; - } - - namespace source - { - void - generate () - { - context ctx; - ostream& os (ctx.os); - - traversal::unit unit; - traversal::defines unit_defines; - traversal::namespace_ ns; - class_ c; - - unit >> unit_defines >> ns; - unit_defines >> c; - - traversal::defines ns_defines; - - ns >> ns_defines >> ns; - ns_defines >> c; - - os << "#include " << endl - << endl; - - os << "#include " << endl - << endl; - - os << "namespace odb" - << "{"; - - unit.dispatch (ctx.unit); - - os << "}"; - } - } -} -- cgit v1.1