#pragma once class CCHImageData; class CSharedMemory { public: CSharedMemory(void) { m_pSemaPhore = NULL; m_pAsignedMemory = NULL; m_pSharedMemory = NULL; Reset(); } virtual ~CSharedMemory(void) { Reset(); } int GetMemoryCount() { return m_nMemoryCount; } BOOL LockMemory(int nMemoryIndex) { if (nMemoryIndex<0 || nMemoryIndex>=m_nMemoryCount) return FALSE; if (m_pSemaPhore[nMemoryIndex]) { m_pSemaPhore[nMemoryIndex]->Lock(); } else { return FALSE; } return TRUE; } BOOL UnlockMemory(int nMemoryIndex) { if (nMemoryIndex<0 || nMemoryIndex>=m_nMemoryCount) return FALSE; if (m_pSemaPhore[nMemoryIndex]) { m_pSemaPhore[nMemoryIndex]->Unlock(); } else { return FALSE; } return TRUE; } protected: void Reset() { if(m_pSharedMemory) { for (int i=0; i