Feature.hpp
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: Feature.hpp
10 
11  Description: Inline wrapper functions for class AVT::VmbAPI::Feature.
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 
28 #ifndef AVT_VMBAPI_FEATURE_HPP
29 #define AVT_VMBAPI_FEATURE_HPP
30 //
31 // Inline wrapper functions that allocate memory for STL objects in the application's context
32 // and to pass data across DLL boundaries using arrays
33 //
34 inline VmbErrorType Feature::GetValues( StringVector &rValues )
35 {
36  VmbErrorType res;
37  VmbUint32_t nSize;
38 
39  res = GetValues( (const char **)NULL, nSize );
40  if ( VmbErrorSuccess == res )
41  {
42  if ( 0 != nSize)
43  {
44  try
45  {
46  std::vector<const char*> data( nSize );
47  res = GetValues( &data[0], nSize );
48  if ( VmbErrorSuccess == res )
49  {
50  StringVector tmpValues( data.size() );
51  std::copy( data.begin(), data.end(), tmpValues.begin() );
52  rValues.swap( tmpValues);
53  }
54  }
55  catch(...)
56  {
57  return VmbErrorResources;
58  }
59  }
60  else
61  {
62  rValues.clear();
63  }
64  }
65 
66  return res;
67 }
68 
69 inline VmbErrorType Feature::GetEntries( EnumEntryVector &rEntries )
70 {
71  VmbErrorType res;
72  VmbUint32_t nSize;
73 
74  res = GetEntries( (EnumEntry*)NULL, nSize );
75  if ( VmbErrorSuccess == res )
76  {
77  if( 0 != nSize )
78  {
79  try
80  {
81  EnumEntryVector tmpEntries( nSize );
82  res = GetEntries( &tmpEntries[0], nSize );
83  if( VmbErrorSuccess == res)
84  {
85  rEntries.swap( tmpEntries );
86  }
87  }
88  catch(...)
89  {
90  return VmbErrorResources;
91  }
92  }
93  else
94  {
95  rEntries.clear();
96  }
97  }
98 
99  return res;
100 }
101 
102 inline VmbErrorType Feature::GetValues( Int64Vector &rValues )
103 {
104  VmbErrorType res;
105  VmbUint32_t nSize;
106 
107  res = GetValues( (VmbInt64_t*)NULL, nSize );
108  if ( VmbErrorSuccess == res )
109  {
110  if( 0 != nSize)
111  {
112  try
113  {
114  Int64Vector tmpValues( nSize );
115  res = GetValues( &tmpValues[0], nSize );
116  if( VmbErrorSuccess == res)
117  {
118  rValues.swap( tmpValues );
119  }
120  }
121  catch(...)
122  {
123  return VmbErrorResources;
124  }
125  }
126  else
127  {
128  rValues.clear();
129  }
130  }
131 
132  return res;
133 }
134 
135 inline VmbErrorType Feature::GetValue( std::string &rStrValue ) const
136 {
137  VmbErrorType res;
138  VmbUint32_t nLength;
139 
140  res = GetValue( (char * const)NULL, nLength );
141  if ( VmbErrorSuccess == res )
142  {
143  if ( 0 != nLength )
144  {
145  try
146  {
147  std::vector<std::string::value_type> tmpValue( nLength + 1, '\0' );
148  res = GetValue( &tmpValue[0], nLength );
149  if ( VmbErrorSuccess == res )
150  {
151  rStrValue = &*tmpValue.begin();
152  }
153  }
154  catch(...)
155  {
156  return VmbErrorResources;
157  }
158  }
159  else
160  {
161  rStrValue.clear();
162  }
163  }
164 
165  return res;
166 }
167 
168 inline VmbErrorType Feature::GetValue( UcharVector &rValue ) const
169 {
170  VmbUint32_t i;
171  return GetValue( rValue, i );
172 }
173 inline VmbErrorType Feature::GetValue( UcharVector &rValue, VmbUint32_t &rnSizeFilled ) const
174 {
175  VmbErrorType res;
176  VmbUint32_t nSize;
177 
178  res = GetValue( NULL, nSize, rnSizeFilled );
179  if ( VmbErrorSuccess == res )
180  {
181  if( 0 != nSize)
182  {
183  try
184  {
185  UcharVector tmpValue( nSize );
186  res = GetValue( &tmpValue[0], nSize, rnSizeFilled );
187  if( VmbErrorSuccess == res )
188  {
189  rValue.swap( tmpValue);
190  }
191  }
192  catch(...)
193  {
194  return VmbErrorResources;
195  }
196  }
197  else
198  {
199  rValue.clear();
200  }
201  }
202 
203  return res;
204 }
205 
206 inline VmbErrorType Feature::SetValue( const UcharVector &rValue )
207 {
208  if ( rValue.empty() )
209  {
210  return VmbErrorBadParameter;
211  }
212  return SetValue( &rValue[0], (VmbUint32_t)rValue.size() );
213 }
214 
215 inline VmbErrorType Feature::GetName( std::string &rStrName ) const
216 {
217  VmbErrorType res;
218  VmbUint32_t nLength;
219 
220  res = GetName( NULL, nLength );
221  if ( VmbErrorSuccess == res )
222  {
223  if ( 0 != nLength )
224  {
225  try
226  {
227  std::vector<std::string::value_type> tmpName( nLength + 1, '\0' );
228  res = GetName( &tmpName[0], nLength );
229  if( VmbErrorSuccess == res)
230  {
231  rStrName = &*tmpName.begin();
232  }
233  }
234  catch(...)
235  {
236  return VmbErrorResources;
237  }
238  }
239  else
240  {
241  rStrName.clear();
242  }
243  }
244 
245  return res;
246 }
247 
248 inline VmbErrorType Feature::GetDisplayName( std::string &rStrDisplayName ) const
249 {
250  VmbErrorType res;
251  VmbUint32_t nLength;
252 
253  res = GetDisplayName( NULL, nLength );
254  if ( VmbErrorSuccess == res )
255  {
256  if ( 0 != nLength )
257  {
258  try
259  {
260  std::vector<std::string::value_type> tmpDisplayName( nLength + 1, '\0' );
261  res = GetDisplayName( &tmpDisplayName[0], nLength );
262  if( VmbErrorSuccess == res )
263  {
264  rStrDisplayName = &*tmpDisplayName.begin();
265  }
266  }
267  catch(...)
268  {
269  return VmbErrorResources;
270  }
271  }
272  else
273  {
274  rStrDisplayName.clear();
275  }
276  }
277 
278  return res;
279 }
280 
281 inline VmbErrorType Feature::GetCategory( std::string &rStrCategory ) const
282 {
283  VmbErrorType res;
284  VmbUint32_t nLength;
285 
286  res = GetCategory( NULL, nLength );
287  if ( VmbErrorSuccess == res )
288  {
289  if ( 0 != nLength )
290  {
291  try
292  {
293  std::vector<std::string::value_type> tmpCategory( nLength + 1, '\0' );
294  res = GetCategory( &tmpCategory[0], nLength );
295  if( VmbErrorSuccess == res )
296  {
297  rStrCategory = &*tmpCategory.begin();
298  }
299  }
300  catch(...)
301  {
302  return VmbErrorResources;
303  }
304  }
305  else
306  {
307  rStrCategory.clear();
308  }
309  }
310 
311  return res;
312 }
313 
314 inline VmbErrorType Feature::GetUnit( std::string &rStrUnit ) const
315 {
316  VmbErrorType res;
317  VmbUint32_t nLength;
318 
319  res = GetUnit( NULL, nLength );
320  if ( VmbErrorSuccess == res )
321  {
322  if ( 0 != nLength )
323  {
324  try
325  {
326  std::vector<std::string::value_type> tmpUnit( nLength + 1, '\0' );
327  res = GetUnit( &tmpUnit[0], nLength );
328  if( VmbErrorSuccess == res )
329  {
330  rStrUnit = &*tmpUnit.begin();
331  }
332  }
333  catch(...)
334  {
335  return VmbErrorResources;
336  }
337  }
338  else
339  {
340  rStrUnit.clear();
341  }
342  }
343 
344  return res;
345 }
346 
347 inline VmbErrorType Feature::GetRepresentation( std::string &rStrRepresentation ) const
348 {
349  VmbErrorType res;
350  VmbUint32_t nLength;
351 
352  res = GetRepresentation( NULL, nLength );
353  if ( VmbErrorSuccess == res )
354  {
355  if ( 0 != nLength )
356  {
357  try
358  {
359  std::vector<std::string::value_type> tmpRepresentation( nLength + 1, '\0' );
360  res = GetRepresentation( &tmpRepresentation[0], nLength );
361  if( VmbErrorSuccess == res )
362  {
363  rStrRepresentation = &*tmpRepresentation.begin();
364  }
365  }
366  catch(...)
367  {
368  return VmbErrorResources;
369  }
370  }
371  else
372  {
373  rStrRepresentation.clear();
374  }
375  }
376 
377  return res;
378 }
379 
380 inline VmbErrorType Feature::GetToolTip( std::string &rStrToolTip ) const
381 {
382  VmbErrorType res;
383  VmbUint32_t nLength;
384 
385  res = GetToolTip( NULL, nLength );
386  if ( VmbErrorSuccess == res )
387  {
388  if ( 0 != nLength )
389  {
390  try
391  {
392  std::vector<std::string::value_type> tmpToolTip( nLength + 1, '\0');
393  res = GetToolTip( &tmpToolTip[0], nLength );
394  if( VmbErrorSuccess == res )
395  {
396  rStrToolTip = &*tmpToolTip.begin();
397  }
398  }
399  catch(...)
400  {
401  return VmbErrorResources;
402  }
403  }
404  else
405  {
406  rStrToolTip.clear();
407  }
408  }
409 
410  return res;
411 }
412 
413 inline VmbErrorType Feature::GetDescription( std::string &rStrDescription ) const
414 {
415  VmbErrorType res;
416  VmbUint32_t nLength;
417 
418  res = GetDescription( NULL, nLength );
419  if ( VmbErrorSuccess == res )
420  {
421  if ( 0 != nLength )
422  {
423  try
424  {
425  std::vector<std::string::value_type> tmpDescription( nLength + 1, '\0');
426  res = GetDescription( &tmpDescription[0], nLength );
427  if( VmbErrorSuccess == res )
428  {
429  rStrDescription = &*tmpDescription.begin();
430  }
431  }
432  catch(...)
433  {
434  return VmbErrorResources;
435  }
436  }
437  else
438  {
439  rStrDescription.clear();
440  }
441  }
442 
443  return res;
444 }
445 
446 inline VmbErrorType Feature::GetSFNCNamespace( std::string &rStrSFNCNamespace ) const
447 {
448  VmbErrorType res;
449  VmbUint32_t nLength;
450 
451  res = GetSFNCNamespace( NULL, nLength );
452  if ( VmbErrorSuccess == res )
453  {
454  if ( 0 != nLength )
455  {
456  try
457  {
458  std::vector<std::string::value_type> tmpSFNCNamespace( nLength + 1, '\0' );
459  res = GetSFNCNamespace( &tmpSFNCNamespace[0], nLength );
460  if( VmbErrorSuccess == res )
461  {
462  rStrSFNCNamespace = &*tmpSFNCNamespace.begin();
463  }
464  }
465  catch(...)
466  {
467  return VmbErrorResources;
468  }
469  }
470  else
471  {
472  rStrSFNCNamespace.clear();
473  }
474  }
475 
476  return res;
477 }
478 
479 inline VmbErrorType Feature::GetAffectedFeatures( FeaturePtrVector &rAffectedFeatures )
480 {
481  VmbErrorType res;
482  VmbUint32_t nSize;
483 
484  res = GetAffectedFeatures( NULL, nSize );
485  if ( VmbErrorSuccess == res )
486  {
487  if( 0 != nSize)
488  {
489  try
490  {
491  FeaturePtrVector tmpAffectedFeatures( nSize );
492  res = GetAffectedFeatures( &tmpAffectedFeatures[0], nSize );
493  if( VmbErrorSuccess == res )
494  {
495  rAffectedFeatures.swap( tmpAffectedFeatures );
496  }
497  }
498  catch(...)
499  {
500  return VmbErrorResources;
501  }
502  }
503  else
504  {
505  rAffectedFeatures.clear();
506  }
507  }
508 
509  return res;
510 }
511 
512 inline VmbErrorType Feature::GetSelectedFeatures( FeaturePtrVector &rSelectedFeatures )
513 {
514  VmbErrorType res;
515  VmbUint32_t nSize;
516 
517  res = GetSelectedFeatures( NULL, nSize );
518  if ( VmbErrorSuccess == res )
519  {
520  if( 0 != nSize )
521  {
522  try
523  {
524  FeaturePtrVector tmpSelectedFeatures( nSize );
525  res = GetSelectedFeatures( &tmpSelectedFeatures[0], nSize );
526  if( VmbErrorSuccess == res )
527  {
528  rSelectedFeatures.swap ( tmpSelectedFeatures );
529  }
530  }
531  catch(...)
532  {
533  return VmbErrorResources;
534  }
535  }
536  else
537  {
538  rSelectedFeatures.clear();
539  }
540  }
541 
542  return res;
543 }
544 
545 #endif
std::vector< EnumEntry > EnumEntryVector
long long VmbInt64_t
data
VmbErrorType
std::vector< std::string > StringVector
std::vector< VmbUchar_t > UcharVector
unsigned int VmbUint32_t
std::vector< FeaturePtr > FeaturePtrVector
Definition: Feature.h:46
std::vector< VmbInt64_t > Int64Vector


avt_vimba_camera
Author(s): Miquel Massot , Allied Vision Technologies
autogenerated on Mon Jun 10 2019 12:50:39