From b6df953c8fb19cd00aed47b95b28677e34892f59 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 2 Jul 2014 14:05:27 +0200 Subject: Drop unnecessary ITransactionManager base class Change-Id: Iebed1d63ff76fdc9b82ce6ce8860592606500e38 --- framework/inc/threadhelp/itransactionmanager.h | 133 --------------------- framework/inc/threadhelp/transactionguard.hxx | 6 +- framework/inc/threadhelp/transactionmanager.hxx | 87 ++++++++++++-- .../source/fwi/threadhelp/transactionmanager.cxx | 5 - 4 files changed, 78 insertions(+), 153 deletions(-) delete mode 100644 framework/inc/threadhelp/itransactionmanager.h (limited to 'framework') diff --git a/framework/inc/threadhelp/itransactionmanager.h b/framework/inc/threadhelp/itransactionmanager.h deleted file mode 100644 index baffdb437b77..000000000000 --- a/framework/inc/threadhelp/itransactionmanager.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_ITRANSACTIONMANAGER_H -#define INCLUDED_FRAMEWORK_INC_THREADHELP_ITRANSACTIONMANAGER_H - -#include -#include -#include - -namespace framework{ - -/*-************************************************************************************************************ - @descr Describe different states of a feature of following implementation. - During lifetime of an object different working states occur: - initialization - working - closing - closed - If you wish to implement thread safe classes you should use this feature to protect - your code against calls at wrong time. e.g. you are not full initialized but somewhere - call an interface method (initialize phase means startup time from creating object till - calling specified first method e.g. XInitialization::initialze()!) then you should refuse - this call. The same for closing/disposing the object! -*//*-*************************************************************************************************************/ -enum EWorkingMode -{ - E_INIT , // We stand in a init method -> some calls are accepted - some one are rejected - E_WORK , // Object is ready for working -> all calls are accepted - E_BEFORECLOSE, // We stand in a close method -> some calls are accepted - some one are rejected - E_CLOSE // Object is dead! -> all calls are rejected! -}; - -/*-************************************************************************************************************ - @descr If a request was refused by a transaction manager (internal state different E_WORK ...) - user can check the reason by using this enum values. -*//*-*************************************************************************************************************/ -enum ERejectReason -{ - E_UNINITIALIZED , - E_NOREASON , - E_INCLOSE , - E_CLOSED -}; - -/*-************************************************************************************************************ - @descr A transaction object should support throwing exceptions if user used it at wrong working mode. - e.g. We can throw a DisposedException if user try to work and our mode is E_CLOSE! - But sometimes he dont need this feature - will handle it by himself. - Then we must differ between some exception-modi: - E_NOEXCEPTIONS We never throw any exceptions! User handle it private and looks for ERejectReason. - E_HARDEXCEPTIONS We throw exceptions for all working modes different from E_WORK! - E_SOFTEXCEPTIONS We throw exceptions for all working modes different from E_WORK AND E_INCLOSE! - This mode is useful for impl-methods which should be callable from dispose() method! - - e.g. void dispose() - { - m_aTransactionManager.setWorkingMode( E_BEFORECLOSE ); - ... - impl_setA( 0 ); - ... - m_aTransactionManager.setWorkingMode( E_CLOSE ); - } - - void impl_setA( int nA ) - { - ERejectReason EReason; - TransactionGuard aTransactionGuard( m_aTransactionManager, E_SOFTEXCEPTIONS, eReason ); - - m_nA = nA; - } - - Normaly (if E_HARDEXCEPTIONS was used!) creation of guard - will throw an exception ... but using of E_SOFTEXCEPTIONS suppress it - and member "A" can be set. -*//*-*************************************************************************************************************/ -enum EExceptionMode -{ - E_NOEXCEPTIONS , - E_HARDEXCEPTIONS, - E_SOFTEXCEPTIONS -}; - -/*-************************************************************************************************************ - @descr How can you use the transaction manager? - Use it in combination with an TransactionGuard, which register your transaction in ctor - and release in dtor automatically! Follow interface class can be used to make using - of different manager implmentations possible by using same guard. -*//*-*************************************************************************************************************/ -class ITransactionManager -{ - - // public methods - - public: - - /*-**************************************************************************************************** - @descr These functions must be supported by a derived class! - getWorkingMode() -return current set working mode - setWorkingMode() -change working mode - (This will block till all current transactions are finished!) - isCallRejected() -test method to check if a call will be rejected by wrong working mode or not - registerTransaction() -start new transaction (increase internal transaction count) - unregisterTransaction() -finish transaction (decrease internal transaction count) - *//*-*****************************************************************************************************/ - virtual EWorkingMode getWorkingMode ( ) const = 0; - virtual void setWorkingMode ( EWorkingMode eMode ) = 0; - virtual bool isCallRejected ( ERejectReason& eReason ) const = 0; - virtual void registerTransaction ( EExceptionMode eMode , ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException ) = 0; - virtual void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException ) = 0; - - protected: - ~ITransactionManager() {} -}; // class ITransactionManager - -} // namespace framework - -#endif // INCLUDED_FRAMEWORK_INC_THREADHELP_ITRANSACTIONMANAGER_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/threadhelp/transactionguard.hxx b/framework/inc/threadhelp/transactionguard.hxx index 10d9b0134fc9..4395a5872316 100644 --- a/framework/inc/threadhelp/transactionguard.hxx +++ b/framework/inc/threadhelp/transactionguard.hxx @@ -21,7 +21,7 @@ #define INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONGUARD_HXX #include -#include +#include namespace framework{ @@ -56,7 +56,7 @@ class TransactionGuard : private boost::noncopyable @param "eMode" enable/disable throwing of exceptions for rejected calls @param "eReason" returns reason for rejected calls if "eMode=E_NOEXCEPTIONS"! *//*-*****************************************************************************************************/ - inline TransactionGuard( ITransactionManager& rManager, EExceptionMode eMode, ERejectReason* eReason = NULL ) + inline TransactionGuard( TransactionManager& rManager, EExceptionMode eMode, ERejectReason* eReason = NULL ) : m_pManager( &rManager ) { // If exception mode is set to E_HARDEXCETIONS we don't need a buffer to return reason! @@ -115,7 +115,7 @@ class TransactionGuard : private boost::noncopyable private: - ITransactionManager* m_pManager; /// pointer to safed transaction manager + TransactionManager* m_pManager; /// pointer to safed transaction manager }; // class TransactionGuard diff --git a/framework/inc/threadhelp/transactionmanager.hxx b/framework/inc/threadhelp/transactionmanager.hxx index 438794868ada..d89896e21155 100644 --- a/framework/inc/threadhelp/transactionmanager.hxx +++ b/framework/inc/threadhelp/transactionmanager.hxx @@ -21,7 +21,6 @@ #define INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONMANAGER_HXX #include -#include #include #include @@ -34,6 +33,74 @@ namespace framework{ +/*-************************************************************************************************************ + @descr Describe different states of a feature of following implementation. + During lifetime of an object different working states occur: + initialization - working - closing - closed + If you wish to implement thread safe classes you should use this feature to protect + your code against calls at wrong time. e.g. you are not full initialized but somewhere + call an interface method (initialize phase means startup time from creating object till + calling specified first method e.g. XInitialization::initialze()!) then you should refuse + this call. The same for closing/disposing the object! +*//*-*************************************************************************************************************/ +enum EWorkingMode +{ + E_INIT , // We stand in a init method -> some calls are accepted - some one are rejected + E_WORK , // Object is ready for working -> all calls are accepted + E_BEFORECLOSE, // We stand in a close method -> some calls are accepted - some one are rejected + E_CLOSE // Object is dead! -> all calls are rejected! +}; + +/*-************************************************************************************************************ + @descr If a request was refused by a transaction manager (internal state different E_WORK ...) + user can check the reason by using this enum values. +*//*-*************************************************************************************************************/ +enum ERejectReason +{ + E_UNINITIALIZED , + E_NOREASON , + E_INCLOSE , + E_CLOSED +}; + +/*-************************************************************************************************************ + @descr A transaction object should support throwing exceptions if user used it at wrong working mode. + e.g. We can throw a DisposedException if user try to work and our mode is E_CLOSE! + But sometimes he dont need this feature - will handle it by himself. + Then we must differ between some exception-modi: + E_NOEXCEPTIONS We never throw any exceptions! User handle it private and looks for ERejectReason. + E_HARDEXCEPTIONS We throw exceptions for all working modes different from E_WORK! + E_SOFTEXCEPTIONS We throw exceptions for all working modes different from E_WORK AND E_INCLOSE! + This mode is useful for impl-methods which should be callable from dispose() method! + + e.g. void dispose() + { + m_aTransactionManager.setWorkingMode( E_BEFORECLOSE ); + ... + impl_setA( 0 ); + ... + m_aTransactionManager.setWorkingMode( E_CLOSE ); + } + + void impl_setA( int nA ) + { + ERejectReason EReason; + TransactionGuard aTransactionGuard( m_aTransactionManager, E_SOFTEXCEPTIONS, eReason ); + + m_nA = nA; + } + + Normaly (if E_HARDEXCEPTIONS was used!) creation of guard + will throw an exception ... but using of E_SOFTEXCEPTIONS suppress it + and member "A" can be set. +*//*-*************************************************************************************************************/ +enum EExceptionMode +{ + E_NOEXCEPTIONS , + E_HARDEXCEPTIONS, + E_SOFTEXCEPTIONS +}; + /*-************************************************************************************************************ @short implement a transaction manager to support non breakable interface methods @descr Use it to support non breakable interface methods without using any thread @@ -42,13 +109,9 @@ namespace framework{ Use combination of EExceptionMode and ERejectReason to detect rejected requests and react for it. You can enable automatically throwing of exceptions too. - @implements ITransactionManager - @base ITransactionManager - @devstatus draft *//*-*************************************************************************************************************/ -class FWI_DLLPUBLIC TransactionManager : public ITransactionManager - , private boost::noncopyable +class FWI_DLLPUBLIC TransactionManager: private boost::noncopyable { // public methods @@ -56,12 +119,12 @@ class FWI_DLLPUBLIC TransactionManager : public ITransactionManager public: TransactionManager ( ); - virtual ~TransactionManager ( ); - virtual void setWorkingMode ( EWorkingMode eMode ) SAL_OVERRIDE; - virtual EWorkingMode getWorkingMode ( ) const SAL_OVERRIDE; - virtual bool isCallRejected ( ERejectReason& eReason ) const SAL_OVERRIDE; - virtual void registerTransaction ( EExceptionMode eMode, ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException ) SAL_OVERRIDE; - virtual void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException ) SAL_OVERRIDE; + ~TransactionManager ( ); + void setWorkingMode ( EWorkingMode eMode ); + EWorkingMode getWorkingMode ( ) const; + bool isCallRejected ( ERejectReason& eReason ) const; + void registerTransaction ( EExceptionMode eMode, ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException ); + void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException ); // private methods diff --git a/framework/source/fwi/threadhelp/transactionmanager.cxx b/framework/source/fwi/threadhelp/transactionmanager.cxx index 3d001a871997..77a4894c65db 100644 --- a/framework/source/fwi/threadhelp/transactionmanager.cxx +++ b/framework/source/fwi/threadhelp/transactionmanager.cxx @@ -44,7 +44,6 @@ TransactionManager::~TransactionManager() } /*-**************************************************************************************************** - @interface ITransactionManager @short set new working mode @descr These implementation knows for states of working: E_INIT, E_WORK, E_CLOSING, E_CLOSE You can step during this ones only from the left to the right side and start at left side again! @@ -99,7 +98,6 @@ void TransactionManager::setWorkingMode( EWorkingMode eMode ) } /*-**************************************************************************************************** - @interface ITransactionManager @short get current working mode @descr If you stand in your close() or init() method ... but don't know if you called more then ones(!) ... you can use this function to get @@ -143,7 +141,6 @@ EWorkingMode TransactionManager::getWorkingMode() const } /*-**************************************************************************************************** - @interface ITransactionManager @short start new transaction @descr A guard should use this method to start a new transaction. He should looks for rejected calls to by using parameter eMode and eReason. @@ -182,7 +179,6 @@ void TransactionManager::registerTransaction( EExceptionMode eMode, ERejectReas } /*-**************************************************************************************************** - @interface ITransactionManager @short finish transaction @descr A guard should call this method to release current transaction. @@ -206,7 +202,6 @@ void TransactionManager::unregisterTransaction() throw( css::uno::RuntimeExcept } /*-**************************************************************************************************** - @interface ITransactionManager @short look for rejected calls @descr Sometimes user need a possibility to get information about rejected calls without starting a transaction! -- cgit v1.2.3