00001 /*============================================================================= 00002 Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved. 00003 00004 Redistribution of this file, in original or modified form, without 00005 prior written consent of Allied Vision Technologies is prohibited. 00006 00007 ------------------------------------------------------------------------------- 00008 00009 File: MutexGuard.h 00010 00011 Description: Definition of a mutex helper class for locking and unlocking. 00012 (For internal use only) 00013 00014 ------------------------------------------------------------------------------- 00015 00016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 00017 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, 00018 NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00020 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00023 AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00024 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 00027 =============================================================================*/ 00028 00029 #ifndef AVT_VMBAPI_MUTEXGUARD 00030 #define AVT_VMBAPI_MUTEXGUARD 00031 00032 #include <VimbaCPP/Include/Mutex.h> 00033 #include <VimbaCPP/Include/BasicLockable.h> 00034 00035 namespace AVT 00036 { 00037 namespace VmbAPI 00038 { 00039 00040 class MutexGuard 00041 { 00042 public: 00043 MutexGuard(); 00044 MutexGuard( MutexPtr pMutex ); 00045 MutexGuard( BasicLockablePtr pLockable ); 00046 MutexGuard( const BasicLockable &rLockable ); 00047 ~MutexGuard(); 00048 00049 void Protect( MutexPtr pMutex ); 00050 void Protect( BasicLockablePtr pLockable ); 00051 void Protect( const BasicLockable &rLockable ); 00052 00053 bool Release(); 00054 00055 protected: 00056 MutexPtr m_pMutex; 00057 }; 00058 00059 } //namespace VmbAPI 00060 } //namespace AVT 00061 00062 #endif //AVT_VMBAPI_MUTEXGUARD