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: Mutex.h 00010 00011 Description: Definition of class AVT::VmbAPI::Mutex. 00012 (This include file is 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_MUTEX 00030 #define AVT_VMBAPI_MUTEX 00031 00032 #include <VimbaCPP/Include/VimbaCPPCommon.h> 00033 00034 #ifdef _WIN32 00035 #include <windows.h> 00036 #else 00037 #include <pthread.h> 00038 #endif 00039 00040 namespace AVT { 00041 namespace VmbAPI { 00042 00043 class Mutex 00044 { 00045 public: 00046 IMEXPORT explicit Mutex( bool bInitLock = false ); 00047 IMEXPORT ~Mutex(); 00048 00049 IMEXPORT void Lock(); 00050 IMEXPORT void Unlock(); 00051 00052 protected: 00053 #ifdef _WIN32 00054 HANDLE m_hMutex; 00055 #else 00056 pthread_mutex_t m_Mutex; 00057 #endif 00058 00059 private: 00060 Mutex& operator=( const Mutex& ); 00061 Mutex( const Mutex& ); 00062 }; 00063 00064 }} //namespace AVT::VmbAPI 00065 00066 #endif //AVT_VMBAPI_MUTEX