Last change
on this file was
5635,
checked in by westram, 16 years ago
|
- class GB_transaction:
- replaced abort() by close(error). close() is similar to GB_end_transaction()
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
1.2 KB
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include "arbdb.h" |
---|
3 | #include "arbdbt.h" |
---|
4 | |
---|
5 | |
---|
6 | GB_transaction::GB_transaction(GBDATA *gb_main) |
---|
7 | : ta_main(gb_main) |
---|
8 | , ta_open(false) |
---|
9 | , ta_err(NULL) |
---|
10 | { |
---|
11 | if (ta_main) { |
---|
12 | ta_err = GB_push_transaction(ta_main); |
---|
13 | if (!ta_err) { |
---|
14 | ta_open = true; |
---|
15 | } |
---|
16 | } |
---|
17 | else { |
---|
18 | ta_err = "NULL-Transaction"; |
---|
19 | } |
---|
20 | } |
---|
21 | |
---|
22 | GB_ERROR GB_transaction::close(GB_ERROR error) { |
---|
23 | // abort transaction if error != NULL |
---|
24 | |
---|
25 | if (error) { |
---|
26 | if (ta_err) { |
---|
27 | ta_err = GBS_global_string("%s\n(previous error: %s)", error, ta_err); |
---|
28 | } |
---|
29 | else { |
---|
30 | ta_err = error; |
---|
31 | } |
---|
32 | } |
---|
33 | |
---|
34 | #if defined(DEVEL_RALF) |
---|
35 | #warning check for exported error here (when GB_export_error gets redesigned) |
---|
36 | #endif // DEVEL_RALF |
---|
37 | |
---|
38 | if (ta_open) { |
---|
39 | ta_err = GB_end_transaction(ta_main, ta_err); |
---|
40 | ta_open = false; |
---|
41 | } |
---|
42 | |
---|
43 | return ta_err; |
---|
44 | } |
---|
45 | |
---|
46 | GB_transaction::~GB_transaction() { |
---|
47 | if (ta_open) { |
---|
48 | GB_ERROR error = close(NULL); |
---|
49 | if (error) { |
---|
50 | fprintf(stderr, "Error while closing transaction: %s\n", error); |
---|
51 | gb_assert(0); // you need to manually use close() |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | int GB_info(struct gb_data_base_type2 *gbd){ |
---|
58 | return GB_info((GBDATA *)gbd); |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.