GenApi 3.5.1
ChunkPort.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// (c) 2006-2008 by Basler Vision Technologies
3// Author: Fritz Dierks
4//
5// License: This file is published under the license of the EMVA GenICam Standard Group.
6// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
7// If for some reason you are missing this file please contact the EMVA or visit the website
8// (http://www.genicam.org) for a full copy.
9//
10// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
11// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
12// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
13// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
14// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
15// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20// POSSIBILITY OF SUCH DAMAGE.
21//
22//-----------------------------------------------------------------------------
29#ifndef GENAPI_CHUNKPORT_H
30#define GENAPI_CHUNKPORT_H
31
32#include <GenApi/Pointer.h>
34#include <GenApi/INodeMap.h>
35
36#ifdef _MSC_VER
37# pragma warning(push)
38# pragma warning(disable: 4251) // GenApi::CChunkPort::m_ptrPort' : class 'GenApi::CPointer<T>' needs to have dll-interface
39#endif
40
41namespace GENAPI_NAMESPACE
42{
43
48 class GENAPI_DECL CChunkPort : public IPortConstruct
49 {
50
51 public:
52
54 CChunkPort(IPort* pPort = NULL);
55
57 virtual ~CChunkPort();
58 private:
59 CChunkPort(const CChunkPort&); // copy constructor is not implemented
60 CChunkPort& operator =(const CChunkPort&); // assignment operator is not implemented
61 public:
62 //-------------------------------------------------------------
63 // IPortConstruct implementation
64 //-------------------------------------------------------------
65
67 virtual EAccessMode GetAccessMode() const;
68
71
73 virtual void Read(void *pBuffer, int64_t Address, int64_t Length);
74
76 virtual void Write(const void *pBuffer, int64_t Address, int64_t Length);
77
79 virtual void SetPortImpl(GENAPI_NAMESPACE::IPort* pPort);
80
82 virtual void SetPortImpl(GENAPI_NAMESPACE::IPortStacked* pPort);
83
86 {
87 return No;
88 }
89
90 //---------------------------------------------------------------
91 // Implementation
92 //---------------------------------------------------------------
93
94 // Invalidates the chunk port node
95 void InvalidateNode();
96
97 //-------------------------------------------------------------
98 // Initializing
99 //-------------------------------------------------------------
100
102 bool AttachPort(GENAPI_NAMESPACE::IPort* pPort);
103
106
108 void AttachChunk(uint8_t *pBaseAddress, int64_t ChunkOffset, int64_t Length, bool Cache);
109
112
115 {
116 return m_ChunkIDLength;
117 }
118
120 bool CheckChunkID(uint8_t* pChunkIDBuffer, int ChunkIDLength);
121
123 bool CheckChunkID(uint64_t ChunkID);
124
126 void UpdateBuffer(uint8_t *pBaseAddress);
127
130 protected:
131
132 CLock& GetLock() const
133 {
134 if (!m_ptrPort.IsValid())
135 throw RUNTIME_EXCEPTION("The event port is not attached to a node");
136
137 return m_ptrPort->GetNodeMap()->GetLock();
138 }
139
140 //-------------------------------------------------------------
141 // Member variables
142 //-------------------------------------------------------------
143
146
149
151 int64_t m_Length;
152
155
158
161
164
166 uint8_t *m_pChunkData;
167
170
173
176 };
177
178}
179
180#ifdef _MSC_VER
181# pragma warning(pop)
182#endif
183
184#endif // GENAPI_CHUNKPORT_H
Definition of interface INodeMap.
virtual CLock & GetLock() const =0
Returns the lock which guards the node map.
virtual void InvalidateNode()=0
Indicates that the node's value may have changed.
Definition of interface IPortConstruct.
Definition of template CPointer.
Port attachable to a chunk in a buffer.
Definition ChunkPort.h:49
uint8_t * m_pChunkIDBuffer
Binary version of the chunk ID.
Definition ChunkPort.h:160
int m_ChunkIDLength
Length of the chunk ID buffer.
Definition ChunkPort.h:163
CNodePtr m_ptrPort
Pointer to the node holding a reference to this implementation.
Definition ChunkPort.h:157
bool CheckChunkID(uint8_t *pChunkIDBuffer, int ChunkIDLength)
Checks if a ChunkID matches.
virtual void SetPortImpl(GENAPI_NAMESPACE::IPortStacked *pPort)
Called from the port node to give the chunk port a pointer to itself.
virtual EYesNo GetSwapEndianess()
Determines if the port adapter must perform an endianess swap.
Definition ChunkPort.h:85
virtual void SetPortImpl(GENAPI_NAMESPACE::IPort *pPort)
Called from the port node to give the chunk port a pointer to itself.
int GetChunkIDLength()
Gets the ChunkID length.
Definition ChunkPort.h:114
void DetachChunk()
Detaches the Chunk from the ChunkPort.
virtual void Write(const void *pBuffer, int64_t Address, int64_t Length)
Writes a chunk of bytes to the port.
uint64_t m_ChunkIDNumber
Chunk ID stored as a number (for more straightforward access)
Definition ChunkPort.h:172
bool m_CacheData
indicates if the data needs to be cached
Definition ChunkPort.h:169
void DetachPort()
Detaches the ChunkPort to the Port.
int64_t m_Length
Length of the chunk.
Definition ChunkPort.h:151
bool CheckChunkID(uint64_t ChunkID)
Checks if a ChunkID matches, version using uint64_t ID representation.
bool m_ChunkIDNumberValid
indicates if the m_ChunkIDNumber is valid (could be invalid eg. if the ID does not fit in 64-bit rang...
Definition ChunkPort.h:175
uint8_t * m_pBaseAddress
Pointer to the begin of the buffer.
Definition ChunkPort.h:145
virtual void Read(void *pBuffer, int64_t Address, int64_t Length)
Reads a chunk of bytes from the port.
virtual EAccessMode GetAccessMode() const
Get the access mode of the node.
virtual EInterfaceType GetPrincipalInterfaceType() const
Get the type of the main interface of a node.
bool AttachPort(GENAPI_NAMESPACE::IPort *pPort)
Attaches the ChunkPort to the Port.
int64_t m_ChunkOffset
The chunk's offset within the buffer.
Definition ChunkPort.h:148
uint8_t * m_pChunkData
cache for the chunk data
Definition ChunkPort.h:166
virtual ~CChunkPort()
Destructor; detaches from the port.
int64_t m_LengthAlloc
Space allocated for the chunk.
Definition ChunkPort.h:154
CChunkPort(IPort *pPort=NULL)
Constructor; can attach to a port.
void UpdateBuffer(uint8_t *pBaseAddress)
Updates the base address of the chunk.
void ClearCache()
Clears the chunk cache.
void AttachChunk(uint8_t *pBaseAddress, int64_t ChunkOffset, int64_t Length, bool Cache)
Attaches the Chunk to the ChunkPort.
A lock class.
Definition Synch.h:62
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition GCException.h:246
enum GENAPI_NAMESPACE::_EInterfaceType EInterfaceType
enum GENAPI_NAMESPACE::_EYesNo EYesNo
enum GENAPI_NAMESPACE::_EAccessMode EAccessMode
@ No
no
Definition Types.h:141