Interface.cpp
Go to the documentation of this file.
1 /*=============================================================================
2  Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
3 
4  Redistribution of this file, in original or modified form, without
5  prior written consent of Allied Vision Technologies is prohibited.
6 
7 -------------------------------------------------------------------------------
8 
9  File: Interface.cpp
10 
11  Description: Implementation of class AVT::VmbAPI::Interface.
12 
13 -------------------------------------------------------------------------------
14 
15  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
16  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
17  NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
23  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 =============================================================================*/
27 #pragma warning(disable:4996)
28 #include <map>
29 #pragma warning(default:4996)
30 
32 
33 namespace AVT {
34 namespace VmbAPI {
35 
37 {
38  // Copy of interface infos
40  {
41  std::string interfaceIdString; // Unique identifier for each interface
42  VmbInterface_t interfaceType; // Interface type
43  std::string interfaceName; // Interface name, given by the transport layer
44  std::string serialString; // Serial number
45  VmbAccessMode_t permittedAccess; // Used access mode, see VmbAccessMode_t
47 };
48 
50 {
51  // No default ctor
52 }
53 
55 {
56  // No copy ctor
57 }
58 
60 {
61  // No assignment operator
62  return *this;
63 }
64 
66  : m_pImpl( new Impl() )
67 {
68  m_pImpl->m_interfaceInfo.interfaceIdString.assign( pInterfaceInfo->interfaceIdString ? pInterfaceInfo->interfaceIdString : "" );
69  m_pImpl->m_interfaceInfo.interfaceName.assign( pInterfaceInfo->interfaceName ? pInterfaceInfo->interfaceName : "" );
72  m_pImpl->m_interfaceInfo.serialString.assign( pInterfaceInfo->serialString ? pInterfaceInfo->serialString : "" );
73 }
74 
76 {
77  VmbError_t res;
78  VmbHandle_t hHandle;
79 
80  res = VmbInterfaceOpen( m_pImpl->m_interfaceInfo.interfaceIdString.c_str(), &hHandle );
81 
82 
83  if ( VmbErrorSuccess == res )
84  {
85  SetHandle( hHandle );
86  }
87 
88  return (VmbErrorType)res;
89 }
90 
92 {
93  Close();
94 
95  delete m_pImpl;
96 }
97 
99 {
101 
102  if ( NULL != GetHandle() )
103  {
104  Reset();
105 
106  res = VmbInterfaceClose( GetHandle() );
107 
108  RevokeHandle();
109  }
110 
111  return (VmbErrorType)res;
112 }
113 
114 VmbErrorType Interface::GetID( char * const pStrID, VmbUint32_t &rnLength ) const
115 {
116  VmbErrorType res;
117 
118  if ( NULL == pStrID )
119  {
121  res = VmbErrorSuccess;
122  }
123  else if ( m_pImpl->m_interfaceInfo.interfaceIdString.length() <= rnLength )
124  {
126  pStrID[m_pImpl->m_interfaceInfo.interfaceIdString.length()] = '\0';
128  res = VmbErrorSuccess;
129  }
130  else
131  {
132  res = VmbErrorMoreData;
133  }
134 
135  return res;
136 }
137 
139 {
141 
142  return VmbErrorSuccess;
143 }
144 
145 VmbErrorType Interface::GetName( char * const pStrName, VmbUint32_t &rnLength ) const
146 {
147  VmbErrorType res;
148 
149  if ( NULL == pStrName )
150  {
151  rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceName.length();
152  res = VmbErrorSuccess;
153  }
154  else if ( m_pImpl->m_interfaceInfo.interfaceName.length() <= rnLength )
155  {
156  std::copy( m_pImpl->m_interfaceInfo.interfaceName.begin(), m_pImpl->m_interfaceInfo.interfaceName.end(), pStrName );
157  pStrName[m_pImpl->m_interfaceInfo.interfaceName.length()] = '\0';
158  rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceName.length();
159  res = VmbErrorSuccess;
160  }
161  else
162  {
163  res = VmbErrorMoreData;
164  }
165 
166  return res;
167 }
168 
169 VmbErrorType Interface::GetSerialNumber( char * const pStrSerial, VmbUint32_t &rnLength ) const
170 {
171  VmbErrorType res;
172 
173  if ( NULL == pStrSerial )
174  {
175  rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.serialString.length();
176  res = VmbErrorSuccess;
177  }
178  else if ( m_pImpl->m_interfaceInfo.serialString.length() <= rnLength )
179  {
180  std::copy( m_pImpl->m_interfaceInfo.serialString.begin(), m_pImpl->m_interfaceInfo.serialString.end(), pStrSerial );
181  pStrSerial[m_pImpl->m_interfaceInfo.serialString.length()] = '\0';
182  rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.serialString.length();
183  res = VmbErrorSuccess;
184  }
185  else
186  {
187  res = VmbErrorMoreData;
188  }
189 
190  return res;
191 }
192 
194 {
196 
197  return VmbErrorSuccess;
198 }
199 
200 }} // namespace AVT::VmbAPI
VmbInt32_t VmbError_t
VmbInterface_t interfaceType
Definition: VimbaC.h:139
IMEXPORTC VmbError_t VMB_CALL VmbInterfaceOpen(const char *idString, VmbHandle_t *pInterfaceHandle)
const char * serialString
Definition: VimbaC.h:141
virtual IMEXPORT VmbErrorType Open()
Definition: Interface.cpp:75
VmbUint32_t VmbAccessMode_t
Definition: VimbaC.h:130
VmbErrorType GetID(std::string &interfaceID) const
VmbErrorType GetName(std::string &name) const
virtual IMEXPORT VmbErrorType Close()
Definition: Interface.cpp:98
VmbErrorType
VmbAccessModeType
Definition: VimbaC.h:122
void * VmbHandle_t
VmbAccessMode_t permittedAccess
Definition: VimbaC.h:142
IMEXPORT VmbErrorType GetPermittedAccess(VmbAccessModeType &accessMode) const
Definition: Interface.cpp:193
VmbInterfaceType
Definition: VimbaC.h:107
struct AVT::VmbAPI::Interface::Impl::InterfaceInfo m_interfaceInfo
unsigned int VmbUint32_t
IMEXPORTC VmbError_t VMB_CALL VmbInterfaceClose(const VmbHandle_t interfaceHandle)
Interface & operator=(const Interface &)
Definition: Interface.cpp:59
const char * interfaceName
Definition: VimbaC.h:140
VmbErrorType GetSerialNumber(std::string &serialNumber) const
VmbUint32_t VmbInterface_t
Definition: VimbaC.h:115
void SetHandle(const VmbHandle_t handle)
IMEXPORT VmbErrorType GetType(VmbInterfaceType &type) const
Definition: Interface.cpp:138
const char * interfaceIdString
Definition: VimbaC.h:138


avt_vimba_camera
Author(s): Miquel Massot , Allied Vision Technologies
autogenerated on Wed Jun 5 2019 22:22:40