merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / threadhelp / transactionmanager.hxx
blobad19c1c27e924bf2df0ae1874fa27329c190d28d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: transactionmanager.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONMANAGER_HXX_
32 #define __FRAMEWORK_THREADHELP_TRANSACTIONMANAGER_HXX_
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 #include <threadhelp/inoncopyable.h>
39 #include <threadhelp/itransactionmanager.h>
40 #include <threadhelp/gate.hxx>
41 #include <macros/debug.hxx>
43 //_________________________________________________________________________________________________________________
44 // interface includes
45 //_________________________________________________________________________________________________________________
46 #include <com/sun/star/uno/Reference.hxx>
47 #include <com/sun/star/uno/XInterface.hpp>
48 #include <com/sun/star/uno/RuntimeException.hpp>
49 #include <com/sun/star/lang/DisposedException.hpp>
51 //_________________________________________________________________________________________________________________
52 // other includes
53 //_________________________________________________________________________________________________________________
54 #include <osl/mutex.hxx>
56 //_________________________________________________________________________________________________________________
57 // namespace
58 //_________________________________________________________________________________________________________________
60 namespace framework{
62 //_________________________________________________________________________________________________________________
63 // const
64 //_________________________________________________________________________________________________________________
66 //_________________________________________________________________________________________________________________
67 // declarations
68 //_________________________________________________________________________________________________________________
70 /*-************************************************************************************************************//**
71 @short implement a transaction manager to support non breakable interface methods
72 @descr Use it to support non breakable interface methods without using any thread
73 synchronization like e.g. mutex, rw-lock!
74 That protect your code against wrong calls at wrong time ... e.g. calls after disposing an object!
75 Use combination of EExceptionMode and ERejectReason to detect rejected requests
76 and react for it. You can enable automaticly throwing of exceptions too.
78 @implements ITransactionManager
79 @base INonCopyable
80 ITransactionManager
82 @devstatus draft
83 *//*-*************************************************************************************************************/
84 class TransactionManager : public ITransactionManager
85 , private INonCopyable
87 //-------------------------------------------------------------------------------------------------------------
88 // public methods
89 //-------------------------------------------------------------------------------------------------------------
90 public:
92 TransactionManager ( );
93 virtual ~TransactionManager ( );
94 virtual void setWorkingMode ( EWorkingMode eMode );
95 virtual EWorkingMode getWorkingMode ( ) const;
96 virtual sal_Bool isCallRejected ( ERejectReason& eReason ) const;
97 virtual void registerTransaction ( EExceptionMode eMode, ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException );
98 virtual void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException );
99 static TransactionManager& getGlobalTransactionManager ( );
101 //-------------------------------------------------------------------------------------------------------------
102 // private methods
103 //-------------------------------------------------------------------------------------------------------------
104 private:
106 void impl_throwExceptions( EExceptionMode eMode, ERejectReason eReason ) const throw( css::uno::RuntimeException, css::lang::DisposedException );
108 //-------------------------------------------------------------------------------------------------------------
109 // private member
110 //-------------------------------------------------------------------------------------------------------------
111 private:
113 mutable ::osl::Mutex m_aAccessLock ; /// regulate access on internal member of this instance
114 Gate m_aBarrier ; /// used to block transactions requests during change or work mode
115 EWorkingMode m_eWorkingMode ; /// current working mode of object which use this manager (used to reject calls at wrong time)
116 sal_Int32 m_nTransactionCount ; /// every transaction request is registered by this counter
118 }; // class TransactionManager
120 } // namespace framework
122 #endif // #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONMANAGER_HXX_