summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/ConnectionI.h
blob: 987077b1adf0bcd1b9e86e59db7b45aac9d9a7a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// **********************************************************************
//
// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#ifndef FREEZE_CONNECTIONI_H
#define FREEZE_CONNECTIONI_H

#include <Freeze/Connection.h>
#include <Freeze/Initialize.h>
#include <Freeze/TransactionI.h>
#include <Freeze/SharedDbEnv.h>
#include <list>

namespace Freeze
{

class MapHelperI;

class ConnectionI : public Connection
{
public:

    virtual TransactionPtr
    beginTransaction();

    virtual TransactionPtr
    currentTransaction() const;

    virtual void
    close();
    
    virtual Ice::CommunicatorPtr
    getCommunicator() const;

    virtual std::string
    getName() const;

    virtual ~ConnectionI();

    ConnectionI(const Ice::CommunicatorPtr& communicator, 
                const std::string& envName, DbEnv*);

    void
    closeAllIterators();

    void
    registerMap(MapHelperI*);

    void
    unregisterMap(MapHelperI*);

    void
    clearTransaction();

    DbTxn*
    dbTxn() const;

    const SharedDbEnvPtr&
    dbEnv() const;
       
    const Ice::CommunicatorPtr&
    communicator() const;

    const std::string& 
    envName() const;
    
    Ice::Int
    trace() const;

    Ice::Int
    txTrace() const;

    bool
    deadlockWarning() const;

private:

    Ice::CommunicatorPtr _communicator;
    SharedDbEnvPtr _dbEnv;
    std::string _envName;
    TransactionIPtr _transaction;
    std::list<MapHelperI*> _mapList;
    Ice::Int _trace;
    Ice::Int _txTrace;
    bool _deadlockWarning;
};  

inline void
ConnectionI::clearTransaction()
{
    _transaction = 0;
}

inline DbTxn*
ConnectionI::dbTxn() const
{
    if(_transaction == 0)
    {
        return 0;
    }
    else
    {
        return _transaction->dbTxn();
    }
}

inline const SharedDbEnvPtr&
ConnectionI::dbEnv() const
{
    return _dbEnv;
}

inline const std::string& 
ConnectionI::envName() const
{
    return _envName;
}

inline const Ice::CommunicatorPtr&
ConnectionI::communicator() const
{
    return _communicator;
}

inline Ice::Int
ConnectionI::trace() const
{
    return _trace;
}

inline Ice::Int
ConnectionI::txTrace() const
{
    return _txTrace;
}

inline bool
ConnectionI::deadlockWarning() const
{
    return _deadlockWarning;
}

}

#endif