EnumFeature.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: EnumFeature.cpp
10 
11  Description: Implementation of class AVT::VmbAPI::EnumFeature.
12  (For internal use only)
13 
14 -------------------------------------------------------------------------------
15 
16  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
17  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
18  NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 =============================================================================*/
28 
30 #include <memory.h>
31 
32 namespace AVT {
33 namespace VmbAPI {
34 
35 EnumFeature::EnumFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer )
36  :BaseFeature( featureInfo, pFeatureContainer )
37 {
38 }
39 
40 VmbErrorType EnumFeature::GetValue( char * const pStrValue, VmbUint32_t &rnSize ) const
41 {
42  VmbErrorType res;
43  if ( NULL == m_pFeatureContainer )
44  {
45  return VmbErrorDeviceNotOpen;
46  }
47 
48  const char* pStrTempValue;
49  res = (VmbErrorType)VmbFeatureEnumGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &pStrTempValue );
50 
51  if ( VmbErrorSuccess == res )
52  {
53  VmbUint32_t nLength=0;
54  while ( pStrTempValue[nLength] != '\0' )
55  {
56  ++nLength;
57  }
58 
59  if ( NULL == pStrValue )
60  {
61  rnSize = nLength;
62  }
63  else if ( nLength <= rnSize )
64  {
65  ::memcpy( pStrValue, pStrTempValue, (size_t)nLength );
66  rnSize = nLength;
67  }
68  else
69  {
70  res = VmbErrorMoreData;
71  }
72  }
73 
74  return res;
75 }
76 
78 {
79  if ( NULL == m_pFeatureContainer )
80  {
81  return VmbErrorDeviceNotOpen;
82  }
83 
84  const char *pName = NULL;
86  if ( VmbErrorSuccess == res )
87  {
88  res = VmbFeatureEnumAsInt( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pName, &rnValue );
89  }
90 
91  return (VmbErrorType)res;
92 }
93 
94 VmbErrorType EnumFeature::GetEntry( EnumEntry &rEntry, const char * pStrEntryName ) const
95 {
96  if ( NULL == m_pFeatureContainer )
97  {
98  return VmbErrorDeviceNotOpen;
99  }
100 
101  VmbFeatureEnumEntry_t entry;
102  VmbError_t res = VmbFeatureEnumEntryGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pStrEntryName, &entry, sizeof( VmbFeatureEnumEntry_t ));
103  if ( VmbErrorSuccess == res )
104  {
105  rEntry = EnumEntry( entry.name, entry.displayName, entry.description, entry.tooltip, entry.sfncNamespace, entry.visibility, entry.intValue );
106  }
107 
108  return (VmbErrorType)res;
109 }
110 
111 VmbErrorType EnumFeature::SetValue( const char *pStrValue )
112 {
113  if ( NULL == m_pFeatureContainer )
114  {
115  return VmbErrorDeviceNotOpen;
116  }
117 
119 }
120 
122 {
123  if ( NULL == m_pFeatureContainer )
124  {
125  return VmbErrorDeviceNotOpen;
126  }
127 
128  const char *pName = NULL;
130  if ( VmbErrorSuccess == res )
131  {
133  }
134 
135  return (VmbErrorType)res;
136 }
137 
138 VmbErrorType EnumFeature::GetValues( const char **pRange, VmbUint32_t &rnSize )
139 {
140  if ( NULL == m_pFeatureContainer )
141  {
142  return VmbErrorDeviceNotOpen;
143  }
144 
145  VmbUint32_t nCount = 0;
147 
148  if ( VmbErrorSuccess == res
149  && 0 < nCount )
150  {
151  std::vector<const char*> data( nCount );
152 
153  res = VmbFeatureEnumRangeQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &data[0], nCount, &nCount );
154 
155  if ( VmbErrorSuccess == res )
156  {
157  m_EnumStringValues.clear();
158 
159  for ( std::vector<const char*>::iterator iter = data.begin();
160  data.end() != iter;
161  ++iter )
162  {
163  m_EnumStringValues.push_back( std::string( *iter ));
164  }
165 
166  if ( NULL == pRange )
167  {
168  rnSize = (VmbUint32_t)m_EnumStringValues.size();
169  res = VmbErrorSuccess;
170  }
171  else if ( m_EnumStringValues.size() <= rnSize )
172  {
173  VmbUint32_t i = 0;
174  for ( StringVector::iterator iter = m_EnumStringValues.begin();
175  m_EnumStringValues.end() != iter;
176  ++iter, ++i )
177  {
178  pRange[i] = iter->c_str();
179  }
180  rnSize = (VmbUint32_t)m_EnumStringValues.size();
181  res = VmbErrorSuccess;
182  }
183  else
184  {
185  res = VmbErrorMoreData;
186  }
187  }
188  }
189 
190  return (VmbErrorType)res;
191 }
192 
194 {
195  if ( NULL == m_pFeatureContainer )
196  {
197  return VmbErrorDeviceNotOpen;
198  }
199 
200  VmbUint32_t nCount = 0;
201  VmbError_t res = GetValues( (const char**)NULL, nCount );
202 
203  if ( VmbErrorSuccess == res
204  && 0 < nCount )
205  {
206  std::vector<const char*> data( nCount );
207 
208  res = GetValues( &data[0], nCount );
209 
210  if ( VmbErrorSuccess == res )
211  {
212  m_EnumIntValues.clear();
213 
214  VmbInt64_t nValue;
215  for ( std::vector<const char*>::iterator iter = data.begin();
216  data.end() != iter;
217  ++iter )
218  {
219  res = VmbFeatureEnumAsInt( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), (*iter), &nValue );
220 
221  if ( VmbErrorSuccess == res )
222  {
223  m_EnumIntValues.push_back( nValue );
224  }
225  else
226  {
227  m_EnumIntValues.clear();
228  break;
229  }
230  }
231 
232  if ( VmbErrorSuccess == res )
233  {
234  if ( NULL == pValues )
235  {
236  rnSize = (VmbUint32_t)m_EnumIntValues.size();
237  }
238  else if ( m_EnumIntValues.size() <= rnSize )
239  {
240  VmbUint32_t i = 0;
241  for ( Int64Vector::iterator iter = m_EnumIntValues.begin();
242  m_EnumIntValues.end() != iter;
243  ++iter, ++i )
244  {
245  pValues[i] = (*iter);
246  }
247  rnSize = (VmbUint32_t)m_EnumIntValues.size();
248  }
249  else
250  {
251  res = VmbErrorMoreData;
252  }
253  }
254  }
255  }
256 
257  return (VmbErrorType)res;
258 }
259 
261 {
262  VmbErrorType res = GetValues( (const char**)NULL, rnSize );
263 
264  if ( 0 < m_EnumStringValues.size()
265  && VmbErrorSuccess == res )
266  {
267  m_EnumEntries.clear();
268 
269  for ( StringVector::iterator iter = m_EnumStringValues.begin();
270  m_EnumStringValues.end() != iter;
271  ++iter )
272  {
273  EnumEntry entry;
274  res = GetEntry( entry, (*iter).c_str() );
275  if ( VmbErrorSuccess == res )
276  {
277  m_EnumEntries.push_back( entry );
278  }
279  else
280  {
281  m_EnumEntries.clear();
282  break;
283  }
284  }
285 
286  if ( VmbErrorSuccess == res )
287  {
288  if ( NULL == pEntries )
289  {
290  rnSize = (VmbUint32_t)m_EnumEntries.size();
291  }
292  else if ( m_EnumEntries.size() <= rnSize )
293  {
294  VmbUint32_t i = 0;
295  for ( EnumEntryVector::iterator iter = m_EnumEntries.begin();
296  m_EnumEntries.end() != iter;
297  ++iter, ++i )
298  {
299  pEntries[i] = (*iter);
300  }
301  rnSize = (VmbUint32_t)m_EnumIntValues.size();
302  }
303  else
304  {
305  res = VmbErrorMoreData;
306  }
307  }
308  }
309 
310  return res;
311 }
312 
313 VmbErrorType EnumFeature::IsValueAvailable( const char *pStrValue, bool &bAvailable ) const
314 {
315  if ( NULL == m_pFeatureContainer )
316  {
317  return VmbErrorDeviceNotOpen;
318  }
319 
320  return (VmbErrorType)VmbFeatureEnumIsAvailable( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pStrValue, &bAvailable );
321 }
322 
323 VmbErrorType EnumFeature::IsValueAvailable( const VmbInt64_t nValue, bool &rbAvailable ) const
324 {
325  if ( NULL == m_pFeatureContainer )
326  {
327  return VmbErrorDeviceNotOpen;
328  }
329 
330  const char* pName = NULL;
332  if ( VmbErrorSuccess == res )
333  {
334  res = IsValueAvailable( pName, rbAvailable );
335  }
336 
337  return (VmbErrorType)res;
338 }
339 
340 }} // namespace AVT::VmbAPI
341 
VmbInt32_t VmbError_t
EnumEntryVector m_EnumEntries
Definition: EnumFeature.h:59
EnumFeature(const VmbFeatureInfo_t *featureInfo, FeatureContainer *const pFeatureContainer)
Definition: EnumFeature.cpp:35
IMEXPORTC VmbError_t VMB_CALL VmbFeatureEnumEntryGet(const VmbHandle_t handle, const char *featureName, const char *entryName, VmbFeatureEnumEntry_t *pFeatureEnumEntry, VmbUint32_t sizeofFeatureEnumEntry)
long long VmbInt64_t
IMEXPORTC VmbError_t VMB_CALL VmbFeatureEnumRangeQuery(const VmbHandle_t handle, const char *name, const char **pNameArray, VmbUint32_t arrayLength, VmbUint32_t *pNumFilled)
IMEXPORTC VmbError_t VMB_CALL VmbFeatureEnumAsString(const VmbHandle_t handle, const char *name, VmbInt64_t intValue, const char **pStringValue)
StringVector m_EnumStringValues
Definition: EnumFeature.h:57
data
virtual IMEXPORT VmbErrorType GetEntries(EnumEntry *pEntries, VmbUint32_t &size)
IMEXPORTC VmbError_t VMB_CALL VmbFeatureEnumSet(const VmbHandle_t handle, const char *name, const char *value)
VmbErrorType
IMEXPORTC VmbError_t VMB_CALL VmbFeatureEnumIsAvailable(const VmbHandle_t handle, const char *name, const char *value, VmbBool_t *pIsAvailable)
struct VmbFeatureEnumEntry VmbFeatureEnumEntry_t
IMEXPORTC VmbError_t VMB_CALL VmbFeatureEnumAsInt(const VmbHandle_t handle, const char *name, const char *value, VmbInt64_t *pIntVal)
virtual IMEXPORT VmbErrorType GetValue(VmbInt64_t &value) const
Definition: EnumFeature.cpp:77
unsigned int VmbUint32_t
IMEXPORTC VmbError_t VMB_CALL VmbFeatureEnumGet(const VmbHandle_t handle, const char *name, const char **pValue)
virtual IMEXPORT VmbErrorType IsValueAvailable(const char *pStrValue, bool &available) const
virtual IMEXPORT VmbErrorType GetEntry(EnumEntry &entry, const char *pEntryName) const
Definition: EnumFeature.cpp:94
Int64Vector m_EnumIntValues
Definition: EnumFeature.h:58
virtual IMEXPORT VmbErrorType SetValue(const char *pValue)
FeatureContainer * m_pFeatureContainer
Definition: BaseFeature.h:108
virtual IMEXPORT VmbErrorType GetValues(const char **pValues, VmbUint32_t &size)


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