Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #pragma warning(disable:4996)
00028 #include <map>
00029 #pragma warning(default:4996)
00030
00031 #include <VimbaCPP/Include/Interface.h>
00032
00033 namespace AVT {
00034 namespace VmbAPI {
00035
00036 struct Interface::Impl
00037 {
00038
00039 struct InterfaceInfo
00040 {
00041 std::string interfaceIdString;
00042 VmbInterface_t interfaceType;
00043 std::string interfaceName;
00044 std::string serialString;
00045 VmbAccessMode_t permittedAccess;
00046 } m_interfaceInfo;
00047 };
00048
00049 Interface::Interface()
00050 {
00051
00052 }
00053
00054 Interface::Interface( const Interface& )
00055 {
00056
00057 }
00058
00059 Interface& Interface::operator=( const Interface& )
00060 {
00061
00062 return *this;
00063 }
00064
00065 Interface::Interface(const VmbInterfaceInfo_t *pInterfaceInfo)
00066 : m_pImpl( new Impl() )
00067 {
00068 m_pImpl->m_interfaceInfo.interfaceIdString.assign( pInterfaceInfo->interfaceIdString ? pInterfaceInfo->interfaceIdString : "" );
00069 m_pImpl->m_interfaceInfo.interfaceName.assign( pInterfaceInfo->interfaceName ? pInterfaceInfo->interfaceName : "" );
00070 m_pImpl->m_interfaceInfo.interfaceType = pInterfaceInfo->interfaceType;
00071 m_pImpl->m_interfaceInfo.permittedAccess = pInterfaceInfo->permittedAccess;
00072 m_pImpl->m_interfaceInfo.serialString.assign( pInterfaceInfo->serialString ? pInterfaceInfo->serialString : "" );
00073 }
00074
00075 VmbErrorType Interface::Open()
00076 {
00077 VmbError_t res;
00078 VmbHandle_t hHandle;
00079
00080 res = VmbInterfaceOpen( m_pImpl->m_interfaceInfo.interfaceIdString.c_str(), &hHandle );
00081
00082
00083 if ( VmbErrorSuccess == res )
00084 {
00085 SetHandle( hHandle );
00086 }
00087
00088 return (VmbErrorType)res;
00089 }
00090
00091 Interface::~Interface()
00092 {
00093 Close();
00094
00095 delete m_pImpl;
00096 }
00097
00098 VmbErrorType Interface::Close()
00099 {
00100 VmbError_t res = VmbErrorSuccess;
00101
00102 if ( NULL != GetHandle() )
00103 {
00104 Reset();
00105
00106 res = VmbInterfaceClose( GetHandle() );
00107
00108 RevokeHandle();
00109 }
00110
00111 return (VmbErrorType)res;
00112 }
00113
00114 VmbErrorType Interface::GetID( char * const pStrID, VmbUint32_t &rnLength ) const
00115 {
00116 VmbErrorType res;
00117
00118 if ( NULL == pStrID )
00119 {
00120 rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceIdString.length();
00121 res = VmbErrorSuccess;
00122 }
00123 else if ( m_pImpl->m_interfaceInfo.interfaceIdString.length() <= rnLength )
00124 {
00125 std::copy( m_pImpl->m_interfaceInfo.interfaceIdString.begin(), m_pImpl->m_interfaceInfo.interfaceIdString.end(), pStrID );
00126 pStrID[m_pImpl->m_interfaceInfo.interfaceIdString.length()] = '\0';
00127 rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceIdString.length();
00128 res = VmbErrorSuccess;
00129 }
00130 else
00131 {
00132 res = VmbErrorMoreData;
00133 }
00134
00135 return res;
00136 }
00137
00138 VmbErrorType Interface::GetType( VmbInterfaceType &reType ) const
00139 {
00140 reType = (VmbInterfaceType)m_pImpl->m_interfaceInfo.interfaceType;
00141
00142 return VmbErrorSuccess;
00143 }
00144
00145 VmbErrorType Interface::GetName( char * const pStrName, VmbUint32_t &rnLength ) const
00146 {
00147 VmbErrorType res;
00148
00149 if ( NULL == pStrName )
00150 {
00151 rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceName.length();
00152 res = VmbErrorSuccess;
00153 }
00154 else if ( m_pImpl->m_interfaceInfo.interfaceName.length() <= rnLength )
00155 {
00156 std::copy( m_pImpl->m_interfaceInfo.interfaceName.begin(), m_pImpl->m_interfaceInfo.interfaceName.end(), pStrName );
00157 pStrName[m_pImpl->m_interfaceInfo.interfaceName.length()] = '\0';
00158 rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceName.length();
00159 res = VmbErrorSuccess;
00160 }
00161 else
00162 {
00163 res = VmbErrorMoreData;
00164 }
00165
00166 return res;
00167 }
00168
00169 VmbErrorType Interface::GetSerialNumber( char * const pStrSerial, VmbUint32_t &rnLength ) const
00170 {
00171 VmbErrorType res;
00172
00173 if ( NULL == pStrSerial )
00174 {
00175 rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.serialString.length();
00176 res = VmbErrorSuccess;
00177 }
00178 else if ( m_pImpl->m_interfaceInfo.serialString.length() <= rnLength )
00179 {
00180 std::copy( m_pImpl->m_interfaceInfo.serialString.begin(), m_pImpl->m_interfaceInfo.serialString.end(), pStrSerial );
00181 pStrSerial[m_pImpl->m_interfaceInfo.serialString.length()] = '\0';
00182 rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.serialString.length();
00183 res = VmbErrorSuccess;
00184 }
00185 else
00186 {
00187 res = VmbErrorMoreData;
00188 }
00189
00190 return res;
00191 }
00192
00193 VmbErrorType Interface::GetPermittedAccess( VmbAccessModeType &reAccessMode ) const
00194 {
00195 reAccessMode = (VmbAccessModeType)m_pImpl->m_interfaceInfo.permittedAccess;
00196
00197 return VmbErrorSuccess;
00198 }
00199
00200 }}