ICE 3.4.2
[php5-ice-freebsdport.git] / cpp / src / Freeze / TransactionI.h
blob5ee0ab3bbe47cd95e70a938db8caab5a5afb84c3
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 #ifndef FREEZE_TRANSACTIONI_H
11 #define FREEZE_TRANSACTIONI_H
13 #include <Ice/CommunicatorF.h>
14 #include <Freeze/Transaction.h>
15 #include <db_cxx.h>
17 namespace Freeze
20 class ConnectionI;
21 typedef IceUtil::Handle<ConnectionI> ConnectionIPtr;
23 struct SharedMutex;
24 typedef IceUtil::Handle<SharedMutex> SharedMutexPtr;
26 class SharedDbEnv;
27 typedef IceUtil::Handle<SharedDbEnv> SharedDbEnvPtr;
29 class PostCompletionCallback : public virtual IceUtil::Shared
31 public:
33 virtual void postCompletion(bool, bool, const SharedDbEnvPtr&) = 0;
35 typedef IceUtil::Handle<PostCompletionCallback> PostCompletionCallbackPtr;
37 class TransactionI : public Transaction
39 public:
41 virtual void commit();
43 virtual void rollback();
46 virtual ConnectionPtr getConnection() const;
49 // Custom refcounting implementation
51 virtual void __incRef();
52 virtual void __decRef();
53 virtual int __getRef() const;
55 void rollbackInternal(bool);
56 void setPostCompletionCallback(const PostCompletionCallbackPtr&);
58 TransactionI(ConnectionI*);
59 ~TransactionI();
61 DbTxn*
62 dbTxn() const
64 return _txn;
67 private:
69 friend class ConnectionI;
71 int __getRefNoSync() const;
73 void postCompletion(bool, bool);
75 const Ice::CommunicatorPtr _communicator;
76 ConnectionIPtr _connection;
77 const Ice::Int _txTrace;
78 const Ice::Int _warnRollback;
79 DbTxn* _txn;
80 PostCompletionCallbackPtr _postCompletionCallback;
81 SharedMutexPtr _refCountMutex;
82 int _refCount;
85 typedef IceUtil::Handle<TransactionI> TransactionIPtr;
88 #endif