~ubuntu-branches/ubuntu/precise/gnat-gps/precise

« back to all changes in this revision

Viewing changes to kernel/src_info/sn/snsrc/db-2.7.7/include/cxx_int.h

  • Committer: Package Import Robot
  • Author(s): Ludovic Brenta
  • Date: 2012-01-15 15:42:21 UTC
  • mfrom: (10.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120115154221-ccysuzvh02pkhuwq
Tags: 5.0-6
Rebuild against libgtkada 2.24.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-
2
 
 * See the file LICENSE for redistribution information.
3
 
 *
4
 
 * Copyright (c) 1997, 1998
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 *
7
 
 *      @(#)cxx_int.h   10.5 (Sleepycat) 4/10/98
8
 
 */
9
 
 
10
 
#ifndef _CXX_INT_H_
11
 
#define _CXX_INT_H_
12
 
 
13
 
// private data structures known to the implementation only
14
 
 
15
 
#include <assert.h>             // used by defines below
16
 
 
17
 
//
18
 
// Using FooImp classes will allow the implementation to change in the
19
 
// future without any modification to user code or even to header files
20
 
// that the user includes. FooImp * is just like void * except that it
21
 
// provides a little extra protection, since you cannot randomly assign
22
 
// any old pointer to a FooImp* as you can with void *.  Currently, a
23
 
// pointer to such an opaque class is always just a pointer to the
24
 
// appropriate underlying implementation struct.  These are converted
25
 
// back and forth using the various overloaded wrap()/unwrap() methods.
26
 
// This is essentially a use of the "Bridge" Design Pattern.
27
 
//
28
 
// WRAPPED_CLASS implements the appropriate wrap() and unwrap() methods
29
 
// for a wrapper class that has an underlying pointer representation.
30
 
//
31
 
#define WRAPPED_CLASS(_WRAPPER_CLASS, _IMP_CLASS, _WRAPPED_TYPE)           \
32
 
                                                                           \
33
 
        class _IMP_CLASS {};                                               \
34
 
                                                                           \
35
 
        inline _WRAPPED_TYPE unwrap(_WRAPPER_CLASS *val)                   \
36
 
        {                                                                  \
37
 
            if (!val) return 0;                                            \
38
 
            return (_WRAPPED_TYPE)(val->imp());                            \
39
 
        }                                                                  \
40
 
                                                                           \
41
 
        inline const _WRAPPED_TYPE unwrapConst(const _WRAPPER_CLASS *val)  \
42
 
        {                                                                  \
43
 
            if (!val) return 0;                                            \
44
 
            return (const _WRAPPED_TYPE)(val->imp());                      \
45
 
        }                                                                  \
46
 
                                                                           \
47
 
        inline _IMP_CLASS *wrap(_WRAPPED_TYPE val)                         \
48
 
        {                                                                  \
49
 
            return (_IMP_CLASS*)val;                                       \
50
 
        }
51
 
 
52
 
WRAPPED_CLASS(DbLockTab, DbLockTabImp, DB_LOCKTAB*)
53
 
WRAPPED_CLASS(DbLog, DbLogImp, DB_LOG*)
54
 
WRAPPED_CLASS(DbMpool, DbMpoolImp, DB_MPOOL*)
55
 
WRAPPED_CLASS(DbMpoolFile, DbMpoolFileImp, DB_MPOOLFILE*)
56
 
WRAPPED_CLASS(Db, DbImp, DB*)
57
 
WRAPPED_CLASS(DbTxn, DbTxnImp, DB_TXN*)
58
 
WRAPPED_CLASS(DbTxnMgr, DbTxnMgrImp, DB_TXNMGR*)
59
 
 
60
 
// Macros that handle detected errors, in case we want to
61
 
// change the default behavior.  runtime_error() throws an
62
 
// exception by default.
63
 
//
64
 
// Since it's unusual to throw an exception in a destructor,
65
 
// we have a separate macro.  For now, we silently ignore such
66
 
// detected errors.
67
 
//
68
 
#define DB_ERROR(caller, ecode) \
69
 
    DbEnv::runtime_error(caller, ecode)
70
 
 
71
 
#define DB_DESTRUCTOR_ERROR(caller, ecode) \
72
 
    DbEnv::runtime_error(caller, ecode, 1)
73
 
 
74
 
 
75
 
////////////////////////////////////////////////////////////////
76
 
////////////////////////////////////////////////////////////////
77
 
//
78
 
// These defines are for tedious flag or field set/get access methods.
79
 
//
80
 
 
81
 
// Define setName() and getName() methods that twiddle
82
 
// the _flags field.
83
 
//
84
 
#define DB_FLAG_METHODS(_class, _flags, _cxx_name, _flag_name) \
85
 
                                                               \
86
 
void _class::set##_cxx_name(int onOrOff)                       \
87
 
{                                                              \
88
 
    if (onOrOff)                                               \
89
 
        _flags |= _flag_name;                                  \
90
 
    else                                                       \
91
 
        _flags &= ~(_flag_name);                               \
92
 
}                                                              \
93
 
                                                               \
94
 
int _class::get##_cxx_name() const                             \
95
 
{                                                              \
96
 
    return (_flags & _flag_name) ? 1 : 0;                      \
97
 
}
98
 
 
99
 
 
100
 
#define DB_RO_ACCESS(_class, _type, _cxx_name, _field)         \
101
 
                                                               \
102
 
_type _class::get_##_cxx_name() const                          \
103
 
{                                                              \
104
 
    return _field;                                             \
105
 
}
106
 
 
107
 
#define DB_WO_ACCESS(_class, _type, _cxx_name, _field)         \
108
 
                                                               \
109
 
void _class::set_##_cxx_name(_type value)                      \
110
 
{                                                              \
111
 
    _field = value;                                            \
112
 
}                                                              \
113
 
 
114
 
#define DB_RW_ACCESS(_class, _type, _cxx_name, _field)         \
115
 
        DB_RO_ACCESS(_class, _type, _cxx_name, _field)         \
116
 
        DB_WO_ACCESS(_class, _type, _cxx_name, _field)
117
 
 
118
 
#endif /* !_CXX_INT_H_ */