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>
33 #include <GenApi/IPortConstruct.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 
41 namespace 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 
105  void DetachPort();
106 
108  void AttachChunk(uint8_t *pBaseAddress, int64_t ChunkOffset, int64_t Length, bool Cache);
109 
111  void DetachChunk();
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 
129  void ClearCache();
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 
145  uint8_t *m_pBaseAddress;
146 
148  int64_t m_ChunkOffset;
149 
151  int64_t m_Length;
152 
154  int64_t m_LengthAlloc;
155 
158 
161 
164 
166  uint8_t *m_pChunkData;
167 
170 
172  uint64_t m_ChunkIDNumber;
173 
176  };
177 
178 }
179 
180 #ifdef _MSC_VER
181 # pragma warning(pop)
182 #endif
183 
184 #endif // GENAPI_CHUNKPORT_H
uint8_t * m_pChunkIDBuffer
Binary version of the chunk ID.
Definition: ChunkPort.h:160
int64_t m_ChunkOffset
The chunk&#39;s offset within the buffer.
Definition: ChunkPort.h:148
uint64_t m_ChunkIDNumber
Chunk ID stored as a number (for more straightforward access)
Definition: ChunkPort.h:172
enum GENAPI_NAMESPACE::_EYesNo EYesNo
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IPortConstruct
Interface for ports.
Definition: IPortConstruct.h:50
int64_t m_LengthAlloc
Space allocated for the chunk.
Definition: ChunkPort.h:154
int m_ChunkIDLength
Length of the chunk ID buffer.
Definition: ChunkPort.h:163
no
Definition: Types.h:141
uint8_t * m_pBaseAddress
Pointer to the begin of the buffer.
Definition: ChunkPort.h:145
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition: GCException.h:246
CNodePtr m_ptrPort
Pointer to the node holding a reference to this implementation.
Definition: ChunkPort.h:157
virtual EYesNo GetSwapEndianess()
Determines if the port adapter must perform an endianess swap.
Definition: ChunkPort.h:85
enum GENAPI_NAMESPACE::_EAccessMode EAccessMode
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IPort
Interface for ports.
Definition: IPort.h:55
Definition of interface INodeMap.
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
virtual EInterfaceType GetPrincipalInterfaceType() const =0
Get the type of the main interface of a node.
virtual void InvalidateNode()=0
Indicates that the node&#39;s value may have changed.
Definition of interface IPortConstruct.
enum GENAPI_NAMESPACE::_EInterfaceType EInterfaceType
uint8_t * m_pChunkData
cache for the chunk data
Definition: ChunkPort.h:166
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IPortStacked
Interface for ports.
Definition: IPortStacked.h:62
virtual CLock & GetLock() const =0
Returns the lock which guards the node map.
bool m_CacheData
indicates if the data needs to be cached
Definition: ChunkPort.h:169
int GetChunkIDLength()
Gets the ChunkID length.
Definition: ChunkPort.h:114
Definition of template CPointer.
int64_t m_Length
Length of the chunk.
Definition: ChunkPort.h:151
Port attachable to a chunk in a buffer.
Definition: ChunkPort.h:48
virtual void Write(const void *pBuffer, int64_t Address, int64_t Length)=0
Writes a chunk of bytes to the port.
Definition: ChunkAdapter.h:37
A lock class.
Definition: Synch.h:61