00001 //----------------------------------------------------------------------------- 00002 // (c) 2006-8 by Basler Vision Technologies 00003 // Section: Vision Components 00004 // Project: GenApi 00005 // Author: Fritz Dierks 00006 // $Header$ 00007 // 00008 // License: This file is published under the license of the EMVA GenICam Standard Group. 00009 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. 00010 // If for some reason you are missing this file please contact the EMVA or visit the website 00011 // (http://www.genicam.org) for a full copy. 00012 // 00013 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" 00014 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00015 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00016 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP 00017 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00018 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00019 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00020 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00021 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 // POSSIBILITY OF SUCH DAMAGE. 00024 //----------------------------------------------------------------------------- 00031 #ifndef GENAPI_CHUNKPORT_H 00032 #define GENAPI_CHUNKPORT_H 00033 00034 #include <GenApi/Pointer.h> 00035 #include <GenApi/IPortConstruct.h> 00036 #include <GenApi/INodeMap.h> 00037 00038 #pragma warning(push) 00039 #pragma warning(disable: 4251) // GenApi::CChunkPort::m_ptrPort' : class 'GenApi::CPointer<T>' needs to have dll-interface 00040 00041 namespace GENAPI_NAMESPACE 00042 { 00043 00048 class GENAPI_DECL CChunkPort : public IPortConstruct 00049 { 00050 00051 public: 00052 00054 CChunkPort(IPort* pPort = NULL); 00055 00057 virtual ~CChunkPort(); 00058 00059 //------------------------------------------------------------- 00060 // IPortConstruct implementation 00061 //------------------------------------------------------------- 00062 00064 virtual EAccessMode GetAccessMode() const; 00065 00067 virtual EInterfaceType GetPrincipalInterfaceType() const; 00068 00070 virtual void Read(void *pBuffer, int64_t Address, int64_t Length); 00071 00073 virtual void Write(const void *pBuffer, int64_t Address, int64_t Length); 00074 00076 virtual void SetPortImpl(GENAPI_NAMESPACE::IPort* pPort); 00077 00079 virtual EYesNo GetSwapEndianess() 00080 { 00081 return No; 00082 } 00083 00084 //--------------------------------------------------------------- 00085 // Implementation 00086 //--------------------------------------------------------------- 00087 00088 // Invalidates the chunk port node 00089 void InvalidateNode(); 00090 00091 //------------------------------------------------------------- 00092 // Initializing 00093 //------------------------------------------------------------- 00094 00096 bool AttachPort(GENAPI_NAMESPACE::IPort* pPort); 00097 00099 void DetachPort(); 00100 00102 void AttachChunk(uint8_t *pBaseAddress, int64_t ChunkOffset, int64_t Length, bool Cache); 00103 00105 void DetachChunk(); 00106 00108 int GetChunkIDLength() 00109 { 00110 return m_ChunkIDLength; 00111 } 00112 00114 bool CheckChunkID(uint8_t* pChunkIDBuffer, int ChunkIDLength); 00115 00117 bool CheckChunkID(uint64_t ChunkID); 00118 00120 void UpdateBuffer(uint8_t *pBaseAddress); 00121 00123 void ClearCache(); 00124 protected: 00125 00126 CLock& GetLock() const 00127 { 00128 if (!m_ptrPort.IsValid()) 00129 throw RUNTIME_EXCEPTION("The event port is not attached to a node"); 00130 00131 return m_ptrPort->GetNodeMap()->GetLock(); 00132 } 00133 00134 //------------------------------------------------------------- 00135 // Member variables 00136 //------------------------------------------------------------- 00137 00139 uint8_t *m_pBaseAddress; 00140 00142 int64_t m_ChunkOffset; 00143 00145 int64_t m_Length; 00146 00148 int64_t m_LengthAlloc; 00149 00151 CNodePtr m_ptrPort; 00152 00154 uint8_t *m_pChunkIDBuffer; 00155 00157 int m_ChunkIDLength; 00158 00160 uint8_t *m_pChunkData; 00161 00163 bool m_CacheData; 00164 00166 uint64_t m_ChunkIDNumber; 00167 00169 bool m_ChunkIDNumberValid; 00170 }; 00171 00172 } 00173 00174 #pragma warning(pop) 00175 00176 #endif // GENAPI_CHUNKPORT_H