aboutsummaryrefslogtreecommitdiff
path: root/tracer/object
diff options
context:
space:
mode:
Diffstat (limited to 'tracer/object')
-rw-r--r--tracer/object/driver.cxx234
-rw-r--r--tracer/object/makefile104
-rw-r--r--tracer/object/test.hxx27
-rw-r--r--tracer/object/test.std108
4 files changed, 0 insertions, 473 deletions
diff --git a/tracer/object/driver.cxx b/tracer/object/driver.cxx
deleted file mode 100644
index 4ea6329..0000000
--- a/tracer/object/driver.cxx
+++ /dev/null
@@ -1,234 +0,0 @@
-// file : tracer/object/driver.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
-// license : GNU GPL v2; see accompanying LICENSE file
-
-// Test object persistence operations.
-//
-
-#include <memory>
-#include <cassert>
-#include <iostream>
-
-#include <odb/exceptions.hxx>
-#include <odb/transaction.hxx>
-#include <odb/tracer/database.hxx>
-
-#include "test.hxx"
-#include "test-odb.hxx"
-
-using namespace std;
-using namespace odb::core;
-
-int
-main ()
-{
- odb::tracer::database db;
-
- // database operation out of transaction
- //
- cout << "\ntest 001" << endl;
- {
- object o1 (1);
- try
- {
- cout << "s 1" << endl;
- db.persist (o1);
- cout << "s 2.a" << endl;
- }
- catch (const not_in_transaction&)
- {
- cout << "s 2.b" << endl;
- }
- }
-
- // transient -> persistent
- //
- cout << "\ntest 002" << endl;
- {
- object o1 (1);
- transaction t (db.begin ());
- cout << "s 1" << endl;
- db.persist (o1);
- cout << "s 2" << endl;
- t.commit ();
- cout << "s 3" << endl;
- }
-
- // transient -> persistent (already exist)
- //
- cout << "\ntest 003" << endl;
- {
- object o1 (0);
- transaction t (db.begin ());
- cout << "s 1" << endl;
- try
- {
- db.persist (o1);
- }
- catch (const object_already_persistent&)
- {
- cout << "object already persistent" << endl;
- }
- cout << "s 2" << endl;
- }
-
- // persistent -> transient
- //
- cout << "\ntest 004" << endl;
- {
- object o1 (1);
- object o2 (2);
- transaction t (db.begin ());
- cout << "s 1" << endl;
- db.persist (o1);
- db.persist (o2);
- cout << "s 2" << endl;
- db.erase (o1);
- db.erase<object> (2);
- cout << "s 3" << endl;
- t.commit ();
- cout << "s 4" << endl;
- }
-
- // persistent -> transient (not exist)
- //
- cout << "\ntest 005" << endl;
- {
- object o1 (0);
- transaction t (db.begin ());
- cout << "s 1" << endl;
- try
- {
- db.erase (o1);
- }
- catch (const object_not_persistent&)
- {
- cout << "object not persistent" << endl;
- }
- cout << "s 2" << endl;
- }
-
- // load new object
- //
- cout << "\ntest 006" << endl;
- {
- transaction t (db.begin ());
- cout << "s 1" << endl;
- auto_ptr<object> o1 (db.load<object> (1));
- cout << "s 2" << endl;
- t.commit ();
- cout << "s 3" << endl;
- }
-
- // load new object (not exist)
- //
- cout << "\ntest 007" << endl;
- {
- transaction t (db.begin ());
- cout << "s 1" << endl;
- try
- {
- auto_ptr<object> o1 (db.load<object> (0));
- }
- catch (const object_not_persistent&)
- {
- cout << "object not persistent" << endl;
- }
- cout << "s 2" << endl;
- }
-
- // load into existing object
- //
- cout << "\ntest 008" << endl;
- {
- object o1;
- transaction t (db.begin ());
- cout << "s 1" << endl;
- db.load (1, o1);
- cout << "s 2" << endl;
- t.commit ();
- cout << "s 3" << endl;
- }
-
- // load into existing object (not exist)
- //
- cout << "\ntest 009" << endl;
- {
- object o1;
- transaction t (db.begin ());
- cout << "s 1" << endl;
- try
- {
- db.load (0, o1);
- }
- catch (const object_not_persistent&)
- {
- cout << "object not persistent" << endl;
- }
- cout << "s 2" << endl;
- }
-
- // update
- //
- cout << "\ntest 010" << endl;
- {
- transaction t (db.begin ());
- cout << "s 1" << endl;
- auto_ptr<object> o1 (db.load<object> (1));
- cout << "s 2" << endl;
- db.update (*o1);
- cout << "s 3" << endl;
- t.commit ();
- cout << "s 4" << endl;
- }
-
- // update (not exist)
- //
- cout << "\ntest 011" << endl;
- {
- object o1 (0);
- transaction t (db.begin ());
- cout << "s 1" << endl;
- try
- {
- db.update (o1);
- }
- catch (const object_not_persistent&)
- {
- cout << "object not persistent" << endl;
- }
- cout << "s 2" << endl;
- }
-
- // find new object
- //
- cout << "\ntest 012" << endl;
- {
- transaction t (db.begin ());
- cout << "s 1" << endl;
- auto_ptr<object> o1 (db.find<object> (1));
- assert (o1.get () != 0);
- auto_ptr<object> o2 (db.find<object> (0));
- assert (o2.get () == 0);
- cout << "s 2" << endl;
- t.commit ();
- cout << "s 3" << endl;
- }
-
- // load into existing object
- //
- cout << "\ntest 013" << endl;
- {
- object o1;
- transaction t (db.begin ());
- cout << "s 1" << endl;
- bool r (db.find (1, o1));
- assert (r);
- r = db.find (0, o1);
- assert (!r);
- cout << "s 2" << endl;
- t.commit ();
- cout << "s 3" << endl;
- }
-}
diff --git a/tracer/object/makefile b/tracer/object/makefile
deleted file mode 100644
index bd0efca..0000000
--- a/tracer/object/makefile
+++ /dev/null
@@ -1,104 +0,0 @@
-# file : tracer/object/makefile
-# author : Boris Kolpackov <boris@codesynthesis.com>
-# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
-# license : GNU GPL v2; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
-
-cxx_tun := driver.cxx
-odb_hdr := test.hxx
-cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o))
-cxx_od := $(cxx_obj:.o=.o.d)
-
-driver := $(out_base)/driver
-dist := $(out_base)/.dist
-test := $(out_base)/.test
-clean := $(out_base)/.clean
-
-# Import.
-#
-$(call import,\
- $(scf_root)/import/odb/stub.make,\
- odb: odb,odb-rules: odb_rules)
-
-$(call import,\
- $(scf_root)/import/libodb/stub.make,\
- l: odb.l,cpp-options: odb.l.cpp-options)
-
-$(call import,\
- $(scf_root)/import/libodb-tracer/stub.make,\
- l: odb_tracer.l,cpp-options: odb_tracer.l.cpp-options)
-
-# Build.
-#
-$(driver): $(cxx_obj) $(odb_tracer.l) $(odb.l)
-$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
-$(cxx_obj) $(cxx_od): $(odb_tracer.l.cpp-options) $(odb.l.cpp-options)
-
-genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx)
-gen := $(addprefix $(out_base)/,$(genf))
-
-$(gen): $(odb)
-$(gen): odb := $(odb)
-$(gen) $(dist): export odb_options += --database tracer
-$(gen): cpp_options := -I$(src_base)
-$(gen): $(odb_tracer.l.cpp-options) $(odb.l.cpp-options)
-
-$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-
-# Alias for default target.
-#
-$(out_base)/: $(driver)
-
-# Dist
-#
-$(dist): sources := $(cxx_tun)
-$(dist): headers := $(odb_hdr)
-$(dist): data_dist := test.std
-$(dist): export name := $(subst /,-,$(subst $(src_root)/tracer/,,$(src_base)))
-$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \
-$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters
-$(dist):
- $(call dist-data,$(sources) $(headers) $(data_dist))
- $(call meta-automake,../template/Makefile.am)
- $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
- $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
-
-# Test.
-#
-$(test): $(driver) $(src_base)/test.std
- $(call message,test $<,$< >$(out_base)/test.out)
- $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out)
- $(call message,,rm -f $(out_base)/test.out)
-
-# Clean.
-#
-$(clean): \
- $(driver).o.clean \
- $(addsuffix .cxx.clean,$(cxx_obj)) \
- $(addsuffix .cxx.clean,$(cxx_od)) \
- $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean))
- $(call message,,rm -f $(out_base)/test.out)
-
-# Generated .gitignore.
-#
-ifeq ($(out_base),$(src_base))
-$(driver): | $(out_base)/.gitignore
-
-$(out_base)/.gitignore: files := driver $(genf)
-$(clean): $(out_base)/.gitignore.clean
-
-$(call include,$(bld_root)/git/gitignore.make)
-endif
-
-# How to.
-#
-$(call include,$(bld_root)/dist.make)
-$(call include,$(bld_root)/meta/vc9proj.make)
-$(call include,$(bld_root)/meta/vc10proj.make)
-$(call include,$(bld_root)/meta/automake.make)
-
-$(call include,$(odb_rules))
-$(call include,$(bld_root)/cxx/cxx-d.make)
-$(call include,$(bld_root)/cxx/cxx-o.make)
-$(call include,$(bld_root)/cxx/o-e.make)
diff --git a/tracer/object/test.hxx b/tracer/object/test.hxx
deleted file mode 100644
index 38bbd7f..0000000
--- a/tracer/object/test.hxx
+++ /dev/null
@@ -1,27 +0,0 @@
-// file : tracer/object/test.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
-// license : GNU GPL v2; see accompanying LICENSE file
-
-#ifndef TEST_HXX
-#define TEST_HXX
-
-#include <odb/core.hxx>
-
-#pragma db object
-struct object
-{
- object (unsigned long id)
- : id_ (id)
- {
- }
-
- object ()
- {
- }
-
- #pragma db id
- unsigned long id_;
-};
-
-#endif // TEST_HXX
diff --git a/tracer/object/test.std b/tracer/object/test.std
deleted file mode 100644
index aa495e7..0000000
--- a/tracer/object/test.std
+++ /dev/null
@@ -1,108 +0,0 @@
-
-test 001
-s 1
-s 2.b
-
-test 002
-begin transaction
-s 1
-insert ::object id 1
-s 2
-commit transaction
-s 3
-
-test 003
-begin transaction
-s 1
-insert ::object id 0
-object already persistent
-s 2
-rollback transaction
-
-test 004
-begin transaction
-s 1
-insert ::object id 1
-insert ::object id 2
-s 2
-delete ::object id 1
-delete ::object id 2
-s 3
-commit transaction
-s 4
-
-test 005
-begin transaction
-s 1
-delete ::object id 0
-object not persistent
-s 2
-rollback transaction
-
-test 006
-begin transaction
-s 1
-select ::object id 1
-s 2
-commit transaction
-s 3
-
-test 007
-begin transaction
-s 1
-select ::object id 0
-object not persistent
-s 2
-rollback transaction
-
-test 008
-begin transaction
-s 1
-select ::object id 1
-s 2
-commit transaction
-s 3
-
-test 009
-begin transaction
-s 1
-select ::object id 0
-object not persistent
-s 2
-rollback transaction
-
-test 010
-begin transaction
-s 1
-select ::object id 1
-s 2
-update ::object id 1
-s 3
-commit transaction
-s 4
-
-test 011
-begin transaction
-s 1
-update ::object id 0
-object not persistent
-s 2
-rollback transaction
-
-test 012
-begin transaction
-s 1
-select ::object id 1
-select ::object id 0
-s 2
-commit transaction
-s 3
-
-test 013
-begin transaction
-s 1
-select ::object id 1
-select ::object id 0
-s 2
-commit transaction
-s 3