source: tags/svn.1.5.4/ARBDB/arbdbpp.cxx

Last change on this file was 7337, checked in by westram, 14 years ago
  • possibility to toggle the TODO-warnings via config.makefile
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : arbdbpp.cxx                                       //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include "gb_local.h"
12
13GB_transaction::GB_transaction(GBDATA *gb_main)
14    : ta_main(gb_main)
15    , ta_open(false)
16    , ta_err(NULL)
17{
18    if (ta_main) {
19        ta_err = GB_push_transaction(ta_main);
20        if (!ta_err) {
21            ta_open = true;
22        }
23    }
24    else {
25        ta_err = "NULL-Transaction";
26    }
27}
28
29ARB_ERROR GB_transaction::close(ARB_ERROR& error) {
30    return close(error.deliver());
31}
32GB_ERROR GB_transaction::close(GB_ERROR error) {
33    // abort transaction if error != NULL
34
35    if (error) {
36        if (ta_err) {
37            ta_err = GBS_global_string("%s\n(previous error: %s)", error, ta_err);
38        }
39        else {
40            ta_err = error;
41        }
42    }
43
44#if defined(WARN_TODO)
45#warning check for exported error here (when GB_export_error gets redesigned)
46#endif
47
48    if (ta_open) {
49        ta_err  = GB_end_transaction(ta_main, ta_err);
50        ta_open = false;
51    }
52
53    return ta_err;
54}
55
56GB_transaction::~GB_transaction() {
57    if (ta_open) {
58        GB_ERROR error = close(NULL);
59        if (error) {
60            fprintf(stderr, "Error while closing transaction: %s\n", error);
61            gb_assert(0); // you need to manually use close()
62        }
63    }
64}
65
66
67int GB_info(GBCONTAINER *gbd) {
68    return GB_info((GBDATA *)gbd);
69}
Note: See TracBrowser for help on using the repository browser.