BaseFeature.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: BaseFeature.cpp
10 
11  Description: Implementation of base class AVT::VmbAPI::BaseFeature.
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 #pragma warning(disable:4996)
30 #pragma warning(default:4996)
31 
35 #include <VimbaCPP/Source/Helper.h>
36 
37 namespace AVT {
38 namespace VmbAPI {
39 
41 {
43 
48 
51 
52  static void VMB_CALL InvalidationCallback( const VmbHandle_t handle, const char *name, void *context );
53 };
54 
55 BaseFeature::BaseFeature( const VmbFeatureInfo_t *pFeatureInfo, FeatureContainer *pFeatureContainer )
56  : m_pImpl( new Impl() )
57  , m_pFeatureContainer( pFeatureContainer )
58 {
61 
62  if ( NULL != pFeatureInfo )
63  {
64  m_featureInfo.category.assign( pFeatureInfo->category ? pFeatureInfo->category : "" );
65  m_featureInfo.description.assign( pFeatureInfo->description ? pFeatureInfo->description : "" );
66  m_featureInfo.displayName.assign( pFeatureInfo->displayName ? pFeatureInfo->displayName : "" );
68  m_featureInfo.featureFlags = pFeatureInfo->featureFlags;
71  m_featureInfo.name.assign( pFeatureInfo->name ? pFeatureInfo->name : "" );
72  m_featureInfo.pollingTime = pFeatureInfo->pollingTime;
73  m_featureInfo.representation.assign( pFeatureInfo->representation ? pFeatureInfo->representation : "" );
74  m_featureInfo.sfncNamespace.assign( pFeatureInfo->sfncNamespace ? pFeatureInfo->sfncNamespace : "" );
75  m_featureInfo.tooltip.assign( pFeatureInfo->tooltip ? pFeatureInfo->tooltip : "" );
76  m_featureInfo.unit.assign( pFeatureInfo->unit ? pFeatureInfo->unit : "" );
77  m_featureInfo.visibility = pFeatureInfo->visibility;
78  m_featureInfo.isStreamable = pFeatureInfo->isStreamable;
79 
80  if ( NULL == m_pFeatureContainer ) // m_pFeatureContainer == NULL (Just for safety)
81  {
82  // Do some logging
83  LOG_FREE_TEXT( "No valid feature container pointer passed" );
84  }
85  }
86  else // m_featureInfo == NULL (Just for safety)
87  {
88  // Do some logging
89  LOG_FREE_TEXT( "No valid feature info pointer passed" );
90  }
91 }
92 
94 {
95  // No default ctor
96 }
97 
99 {
100  // No copy ctor
101 }
102 
104 {
105  // Before destruction we unregister all observers and all callbacks
107 
108  delete m_pImpl;
109 }
110 
111 // Unregisters all observers before it resets the feature container pointer.
113 {
114  if ( NULL != m_pFeatureContainer )
115  {
116  // Camera still open
117  if ( NULL != m_pFeatureContainer->GetHandle() )
118  {
120  }
121 
122  // Begin exclusive write lock this feature
123  if ( true == m_pImpl->m_conditionHelper.EnterWriteLock( GetMutex(), true ))
124  {
125  m_pFeatureContainer = NULL;
126 
127  // End write lock this feature
129  }
130  else
131  {
132  LOG_FREE_TEXT( "Could not reset a feature's feature container reference. ");
133  }
134 
135  }
136 
137  // Begin exclusive write lock observer list
139  {
140  m_pImpl->m_observers.Vector.clear();
141 
142  // End write lock observer list
144  }
145 }
146 
147 void VMB_CALL BaseFeature::Impl::InvalidationCallback( const VmbHandle_t handle, const char * /*name*/, void *context )
148 {
149  BaseFeature *pFeature = (BaseFeature*)context;
150  if ( NULL != pFeature )
151  {
152  if ( NULL != handle )
153  {
154  // Begin read lock this feature
155  if ( true == pFeature->m_pImpl->m_conditionHelper.EnterReadLock( pFeature->GetMutex() ))
156  {
157  if ( NULL != pFeature->m_pFeatureContainer )
158  {
159  FeaturePtr pFeaturePtrFromMap;
160  if ( VmbErrorSuccess == pFeature->m_pFeatureContainer->GetFeatureByName( pFeature->m_featureInfo.name.c_str(), pFeaturePtrFromMap ) )
161  {
162  // Begin read lock observer list
163  if ( true == pFeature->m_pImpl->m_observersConditionHelper.EnterReadLock( pFeature->m_pImpl->m_observers ))
164  {
165  for ( IFeatureObserverPtrVector::iterator iter = pFeature->m_pImpl->m_observers.Vector.begin();
166  pFeature->m_pImpl->m_observers.Vector.end() != iter;
167  ++iter)
168  {
169  SP_ACCESS(( *iter ))->FeatureChanged( pFeaturePtrFromMap );
170  }
171 
172  // End read lock observer list
174  }
175  else
176  {
177  LOG_FREE_TEXT( "Could not lock feature observer list.")
178  }
179  }
180  else // GetFeatureByName() failed
181  {
182  // Do some logging
183  LOG_FREE_TEXT( "GetFeatureByName failed" )
184  }
185  }
186  else // m_pFeatureContainer == NULL (Feature destroyed or device closed / destroyed)
187  {
188  // Do some logging
189  LOG_FREE_TEXT( "Feature destroyed or device closed / destroyed" );
190  }
191 
192  // End read lock this feature
193  pFeature->m_pImpl->m_conditionHelper.ExitReadLock( pFeature->GetMutex() );
194  }
195  else
196  {
197  LOG_FREE_TEXT( "Could not lock feature.")
198  }
199  }
200  else // m_handle == NULL (device closed / destroyed)
201  {
202  // Do some logging
203  LOG_FREE_TEXT( "Device closed / destroyed" )
204  }
205  }
206  else // pFeature == NULL (Just for safety)
207  {
208  // Do some logging
209  LOG_FREE_TEXT( "Feature pointer is null" )
210  }
211 }
212 
213 VmbErrorType BaseFeature::RegisterObserver( const IFeatureObserverPtr &rObserver )
214 {
215  if ( SP_ISNULL( rObserver ))
216  {
217  return VmbErrorBadParameter;
218  }
219 
220  if ( NULL == m_pFeatureContainer )
221  {
222  return VmbErrorDeviceNotOpen;
223  }
224 
226 
227  // Begin write lock observer list
229  {
230  // The very same observer cannot be registered twice
231  for ( size_t i=0; i<m_pImpl->m_observers.Vector.size(); ++i )
232  {
233  if ( SP_ISEQUAL( rObserver, m_pImpl->m_observers.Vector[i] ))
234  {
235  res = VmbErrorInvalidCall;
236  break;
237  }
238  }
239 
240  if ( VmbErrorSuccess == res )
241  {
242  if ( 0 == m_pImpl->m_observers.Vector.size() )
243  {
245  }
246 
247  if ( VmbErrorSuccess == res )
248  {
249  m_pImpl->m_observers.Vector.push_back( rObserver );
250  }
251  }
252 
253  // End write lock observer list
255  }
256 
257  return (VmbErrorType)res;
258 }
259 
260 VmbErrorType BaseFeature::UnregisterObserver( const IFeatureObserverPtr &rObserver )
261 {
262  if ( SP_ISNULL( rObserver ))
263  {
264  return VmbErrorBadParameter;
265  }
266 
267  if ( NULL == m_pFeatureContainer )
268  {
269  return VmbErrorDeviceNotOpen;
270  }
271 
273 
274  // Begin exclusive write lock observer list
276  {
277  for ( IFeatureObserverPtrVector::iterator iter = m_pImpl->m_observers.Vector.begin();
278  m_pImpl->m_observers.Vector.end() != iter;)
279  {
280  if ( SP_ISEQUAL( rObserver, *iter ))
281  {
282  // If we are about to unregister the last observer we cancel all invalidation notifications
283  if ( 1 == m_pImpl->m_observers.Vector.size() )
284  {
286  }
287  if ( VmbErrorSuccess == res
288  || 1 < m_pImpl->m_observers.Vector.size() )
289  {
290  iter = m_pImpl->m_observers.Vector.erase( iter );
291  res = VmbErrorSuccess;
292  }
293  break;
294  }
295  else
296  {
297  ++iter;
298  }
299  }
300 
301  // End write lock observer list
303  }
304  else
305  {
306  LOG_FREE_TEXT( "Could not lock feature observer list.")
307  res = VmbErrorInternalFault;
308  }
309 
310  return (VmbErrorType)res;
311 }
312 
313 // Gets the value of a feature of type VmbFeatureDataInt
315 {
316  return VmbErrorWrongType;
317 }
318 
319 // Sets the value of a feature of type VmbFeatureDataInt
321 {
322  return VmbErrorWrongType;
323 }
324 
325 // Sets the value of a feature of type VmbFeatureDataInt
327 {
328  return VmbErrorWrongType;
329 }
330 
331 // Gets the range of a feature of type VmbFeatureDataInt
332 VmbErrorType BaseFeature::GetRange( VmbInt64_t & /*rnMinimum*/, VmbInt64_t & /*rnMaximum*/ ) const
333 {
334  return VmbErrorWrongType;
335 }
336 
337 VmbErrorType BaseFeature::HasIncrement( VmbBool_t & /*incrementSupported*/) const
338 {
339  return VmbErrorWrongType;
340 }
341 // Gets the increment of a feature of type VmbFeatureDataInt
343 {
344  return VmbErrorWrongType;
345 }
346 
347 // Gets the increment of a feature of type VmbFeatureDataFloat
348 VmbErrorType BaseFeature::GetIncrement( double & /*rnIncrement*/ ) const
349 {
350  return VmbErrorWrongType;
351 }
352 
353 // Gets the value of a feature of type VmbFeatureDataFloat
354 VmbErrorType BaseFeature::GetValue( double & /*rfValue*/) const
355 {
356  return VmbErrorWrongType;
357 }
358 
359 // Sets the value of a feature of type VmbFeatureDataFloat
360 VmbErrorType BaseFeature::SetValue( const double & /*rfValue*/ )
361 {
362  return VmbErrorWrongType;
363 }
364 
365 // Gets the range of a feature of type VmbFeatureDataFloat
366 VmbErrorType BaseFeature::GetRange( double & /*rfMinimum*/, double & /*rfMaximum*/ ) const
367 {
368  return VmbErrorWrongType;
369 }
370 
371 // Sets the value of a feature of type VmbFeatureDataEnum
372 // Sets the value of a feature of type VmbFeatureDataString
373 VmbErrorType BaseFeature::SetValue( const char * /*pStrValue*/ )
374 {
375  return VmbErrorWrongType;
376 }
377 
378 // Gets the enum entry of a feature of type VmbFeatureDataEnum
379 VmbErrorType BaseFeature::GetEntry( EnumEntry & /*entry*/, const char * /*pStrEntryName*/ ) const
380 {
381  return VmbErrorWrongType;
382 }
383 
384 // Gets all possible enum entries of a feature of type VmbFeatureDataEnum
386 {
387  return VmbErrorWrongType;
388 }
389 
390 // Gets all possible values as string of a feature of type VmbFeatureDataEnum
391 VmbErrorType BaseFeature::GetValues( const char ** /*pStrValues*/, VmbUint32_t & /*rnSize*/ )
392 {
393  return VmbErrorWrongType;
394 }
395 
396 // Gets all possible values as integer of a feature of type VmbFeatureDataEnum
398 {
399  return VmbErrorWrongType;
400 }
401 
402 // Indicates whether a particular enum value as string of a feature of type VmbFeatureDataEnum is available
403 VmbErrorType BaseFeature::IsValueAvailable( const char * /*pStrValue*/, bool & /*bAvailable*/ ) const
404 {
405  return VmbErrorWrongType;
406 }
407 
408 // Indicates whether a particular enum value as integer of a feature of type VmbFeatureDataEnum is available
409 VmbErrorType BaseFeature::IsValueAvailable( const VmbInt64_t /*nValue*/, bool & /*bAvailable*/ ) const
410 {
411  return VmbErrorWrongType;
412 }
413 
414 // Gets the value of a feature of type VmbFeatureDataString
415 // Gets the value of a feature of type VmbFeatureDataEnum
416 VmbErrorType BaseFeature::GetValue( char * const /*pStrValue*/, VmbUint32_t & /*length*/ ) const
417 {
418  return VmbErrorWrongType;
419 }
420 
421 // Gets the value of a feature of type VmbFeatureDataBool
422 VmbErrorType BaseFeature::GetValue( bool & /*rbValue*/ ) const
423 {
424  return VmbErrorWrongType;
425 }
426 
427 // Sets the value of a feature of type VmbFeatureDataBool
429 {
430  return VmbErrorWrongType;
431 }
432 
433 // Executes a feature of type VmbFeatureDataCommand
435 {
436  return VmbErrorWrongType;
437 }
438 
439 // Indicates whether a feature of type VmbFeatureDataCommand finished execution
440 VmbErrorType BaseFeature::IsCommandDone( bool & /*bIsDone*/ ) const
441 {
442  return VmbErrorWrongType;
443 }
444 
445 // Gets the value of a feature of type VmbFeatureDataRaw
446 VmbErrorType BaseFeature::GetValue( VmbUchar_t * /*pValue*/, VmbUint32_t & /*rnSize*/, VmbUint32_t & /*rnSizeFilled*/ ) const
447 {
448  return VmbErrorWrongType;
449 }
450 
451 // Sets the value of a feature of type VmbFeatureDataRaw
453 {
454  return VmbErrorWrongType;
455 }
456 
457 VmbErrorType BaseFeature::GetName( char * const pStrName, VmbUint32_t &rnLength ) const
458 {
459  VmbErrorType res;
460 
461  if ( NULL == pStrName )
462  {
463  rnLength = (VmbUint32_t)m_featureInfo.name.length();
464  res = VmbErrorSuccess;
465  }
466  else if ( m_featureInfo.name.length() <= rnLength )
467  {
468  std::copy( m_featureInfo.name.begin(), m_featureInfo.name.end(), pStrName );
469  rnLength = (VmbUint32_t)m_featureInfo.name.length();
470  res = VmbErrorSuccess;
471  }
472  else
473  {
474  res = VmbErrorMoreData;
475  }
476 
477  return res;
478 }
479 
480 VmbErrorType BaseFeature::GetDisplayName( char * const pStrDisplayName, VmbUint32_t &rnLength ) const
481 {
482  VmbErrorType res;
483 
484  if ( NULL == pStrDisplayName )
485  {
486  rnLength = (VmbUint32_t)m_featureInfo.displayName.length();
487  res = VmbErrorSuccess;
488  }
489  else if ( m_featureInfo.displayName.length() <= rnLength )
490  {
491  std::copy( m_featureInfo.displayName.begin(), m_featureInfo.displayName.end(), pStrDisplayName );
492  rnLength = (VmbUint32_t)m_featureInfo.displayName.length();
493  res = VmbErrorSuccess;
494  }
495  else
496  {
497  res = VmbErrorMoreData;
498  }
499 
500  return res;
501 }
502 
504 {
506 
507  return VmbErrorSuccess;
508 }
509 
511 {
513 
514  return VmbErrorSuccess;
515 }
516 
517 VmbErrorType BaseFeature::GetCategory( char * const pStrCategory, VmbUint32_t &rnLength ) const
518 {
519  VmbErrorType res;
520 
521  if ( NULL == pStrCategory )
522  {
523  rnLength = (VmbUint32_t)m_featureInfo.category.length();
524  res = VmbErrorSuccess;
525  }
526  else if ( m_featureInfo.category.length() <= rnLength )
527  {
528  std::copy( m_featureInfo.category.begin(), m_featureInfo.category.end(), pStrCategory );
529  rnLength = (VmbUint32_t)m_featureInfo.category.length();
530  res = VmbErrorSuccess;
531  }
532  else
533  {
534  res = VmbErrorMoreData;
535  }
536 
537  return res;
538 }
539 
541 {
542  rnPollingTime = m_featureInfo.pollingTime;
543 
544  return VmbErrorSuccess;
545 }
546 
547 VmbErrorType BaseFeature::GetUnit( char * const pStrUnit, VmbUint32_t &rnLength ) const
548 {
549  VmbErrorType res;
550 
551  if ( NULL == pStrUnit )
552  {
553  rnLength = (VmbUint32_t)m_featureInfo.unit.length();
554  res = VmbErrorSuccess;
555  }
556  else if ( m_featureInfo.unit.length() <= rnLength )
557  {
558  std::copy( m_featureInfo.unit.begin(), m_featureInfo.unit.end(), pStrUnit );
559  rnLength = (VmbUint32_t)m_featureInfo.unit.length();
560  res = VmbErrorSuccess;
561  }
562  else
563  {
564  res = VmbErrorMoreData;
565  }
566 
567  return res;
568 }
569 
570 VmbErrorType BaseFeature::GetRepresentation( char * const pStrRepresentation, VmbUint32_t &rnLength ) const
571 {
572  VmbErrorType res;
573 
574  if ( NULL == pStrRepresentation )
575  {
576  rnLength = (VmbUint32_t)m_featureInfo.representation.length();
577  res = VmbErrorSuccess;
578  }
579  else if ( m_featureInfo.representation.length() <= rnLength )
580  {
581  std::copy( m_featureInfo.representation.begin(), m_featureInfo.representation.end(), pStrRepresentation );
582  rnLength = (VmbUint32_t)m_featureInfo.representation.length();
583  res = VmbErrorSuccess;
584  }
585  else
586  {
587  res = VmbErrorMoreData;
588  }
589 
590  return res;
591 }
592 
594 {
596 
597  return VmbErrorSuccess;
598 }
599 
600 VmbErrorType BaseFeature::GetToolTip( char * const pStrToolTip, VmbUint32_t &rnLength ) const
601 {
602  VmbErrorType res;
603 
604  if ( NULL == pStrToolTip )
605  {
606  rnLength = (VmbUint32_t)m_featureInfo.tooltip.length();
607  res = VmbErrorSuccess;
608  }
609  else if ( m_featureInfo.tooltip.length() <= rnLength )
610  {
611  std::copy( m_featureInfo.tooltip.begin(), m_featureInfo.tooltip.end(), pStrToolTip );
612  rnLength = (VmbUint32_t)m_featureInfo.tooltip.length();
613  res = VmbErrorSuccess;
614  }
615  else
616  {
617  res = VmbErrorMoreData;
618  }
619 
620  return res;
621 }
622 
623 VmbErrorType BaseFeature::GetDescription( char * const pStrDescription, VmbUint32_t &rnLength ) const
624 {
625  VmbErrorType res;
626 
627  if ( NULL == pStrDescription )
628  {
629  rnLength = (VmbUint32_t)m_featureInfo.description.length();
630  res = VmbErrorSuccess;
631  }
632  else if ( m_featureInfo.description.length() <= rnLength )
633  {
634  std::copy( m_featureInfo.description.begin(), m_featureInfo.description.end(), pStrDescription );
635  rnLength = (VmbUint32_t)m_featureInfo.description.length();
636  res = VmbErrorSuccess;
637  }
638  else
639  {
640  res = VmbErrorMoreData;
641  }
642 
643  return res;
644 }
645 
646 VmbErrorType BaseFeature::GetSFNCNamespace( char * const pStrSFNCNamespace, VmbUint32_t &rnLength ) const
647 {
648  VmbErrorType res;
649 
650  if ( NULL == pStrSFNCNamespace )
651  {
652  rnLength = (VmbUint32_t)m_featureInfo.sfncNamespace.length();
653  res = VmbErrorSuccess;
654  }
655  else if ( m_featureInfo.sfncNamespace.length() <= rnLength )
656  {
657  std::copy( m_featureInfo.sfncNamespace.begin(), m_featureInfo.sfncNamespace.end(), pStrSFNCNamespace );
658  rnLength = (VmbUint32_t)m_featureInfo.sfncNamespace.length();
659  res = VmbErrorSuccess;
660  }
661  else
662  {
663  res = VmbErrorMoreData;
664  }
665 
666  return res;
667 }
668 
669 VmbErrorType BaseFeature::GetAffectedFeatures( FeaturePtr *pAffectedFeatures, VmbUint32_t &rnSize )
670 {
671  VmbError_t res;
672 
673  if ( NULL == pAffectedFeatures )
674  {
675  // Affected features were fetched before
676  if ( true == m_pImpl->m_bAffectedFeaturesFetched )
677  {
678  rnSize = (VmbUint32_t)m_pImpl->m_affectedFeatures.size();
679 
680  res = VmbErrorSuccess;
681  }
682  // Affected features have not been fetched before
683  else
684  {
685  return (VmbErrorType)VmbFeatureListAffected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &rnSize, sizeof(VmbFeatureInfo_t) );
686  }
687  }
688  else
689  {
690  // Affected features were fetched before
691  if ( true == m_pImpl->m_bAffectedFeaturesFetched )
692  {
693  if ( rnSize < m_pImpl->m_affectedFeatures.size() )
694  {
695  return VmbErrorMoreData;
696  }
697 
698  rnSize = (VmbUint32_t)m_pImpl->m_affectedFeatures.size();
699 
700  std::copy( m_pImpl->m_affectedFeatures.begin(), m_pImpl->m_affectedFeatures.end(), pAffectedFeatures );
701 
702  res = VmbErrorSuccess;
703  }
704  // Affected features have not been fetched before
705  else
706  {
707  // Check whether the given array size fits
708  VmbUint32_t nSize = 0;
709  res = VmbFeatureListAffected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &nSize, sizeof(VmbFeatureInfo_t) );
710 
712 
713  if ( rnSize < nSize )
714  {
715  return VmbErrorMoreData;
716  }
717 
718  rnSize = (VmbUint32_t)nSize;
719 
720  if ( VmbErrorSuccess != res
721  || 0 == rnSize )
722  {
723  return (VmbErrorType)res;
724  }
725 
726  // Fetch affected features and store them as well as hand them out
727  std::vector<VmbFeatureInfo_t> affectedFeatureInfos;
728  affectedFeatureInfos.resize( rnSize );
729 
730  res = VmbFeatureListAffected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &affectedFeatureInfos[0], (VmbUint32_t)affectedFeatureInfos.size(), &nSize, sizeof(VmbFeatureInfo_t) );
731 
732  if ( rnSize < nSize )
733  {
734  return VmbErrorMoreData;
735  }
736 
737  rnSize = (VmbUint32_t)nSize;
738 
739  for ( VmbUint32_t i=0; i<rnSize; ++i )
740  {
741  FeaturePtr pFeature;
742  res = m_pFeatureContainer->GetFeatureByName( affectedFeatureInfos[i].name, pFeature );
743  if ( VmbErrorSuccess != res )
744  {
745  m_pImpl->m_affectedFeatures.clear();
746  return (VmbErrorType)res;
747  }
748  m_pImpl->m_affectedFeatures.push_back( pFeature );
749  pAffectedFeatures[i] = m_pImpl->m_affectedFeatures[i];
750  }
751  }
752  }
753 
754  return (VmbErrorType)res;
755 }
756 
757 VmbErrorType BaseFeature::GetSelectedFeatures( FeaturePtr *pSelectedFeatures, VmbUint32_t &rnSize )
758 {
759  VmbError_t res;
760 
761  if ( NULL == pSelectedFeatures )
762  {
763  // Selected features were fetched before
764  if ( true == m_pImpl->m_bSelectedFeaturesFetched )
765  {
766  rnSize = (VmbUint32_t)m_pImpl->m_selectedFeatures.size();
767 
768  res = VmbErrorSuccess;
769  }
770  // Selected features have not been fetched before
771  else
772  {
773  return (VmbErrorType)VmbFeatureListSelected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &rnSize, sizeof(VmbFeatureInfo_t) );
774  }
775  }
776  else
777  {
778  // Selected features were fetched before
779  if ( true == m_pImpl->m_bSelectedFeaturesFetched )
780  {
781  if ( rnSize < m_pImpl->m_selectedFeatures.size() )
782  {
783  return VmbErrorMoreData;
784  }
785 
786  rnSize = (VmbUint32_t)m_pImpl->m_selectedFeatures.size();
787 
788  std::copy( m_pImpl->m_selectedFeatures.begin(), m_pImpl->m_selectedFeatures.end(), pSelectedFeatures );
789 
790  res = VmbErrorSuccess;
791  }
792  // Selected features have not been fetched before
793  else
794  {
795  // Check whether the given array size fits
796  VmbUint32_t nSize = 0;
797  res = VmbFeatureListSelected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &nSize, sizeof(VmbFeatureInfo_t) );
798 
800 
801  if ( rnSize < nSize )
802  {
803  return VmbErrorMoreData;
804  }
805 
806  rnSize = (VmbUint32_t)nSize;
807 
808  if ( VmbErrorSuccess != res
809  || 0 == rnSize )
810  {
811  return (VmbErrorType)res;
812  }
813 
814  // Fetch selected features and store them as well as hand them out
815  std::vector<VmbFeatureInfo_t> selectedFeatureInfos;
816  selectedFeatureInfos.resize( rnSize );
817 
818  res = VmbFeatureListSelected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &selectedFeatureInfos[0], (VmbUint32_t)selectedFeatureInfos.size(), &nSize, sizeof(VmbFeatureInfo_t) );
819 
820  if ( rnSize < nSize )
821  {
822  return VmbErrorMoreData;
823  }
824 
825  rnSize = (VmbUint32_t)nSize;
826 
827  for ( VmbUint32_t i=0; i<rnSize; ++i )
828  {
829  FeaturePtr pFeature;
830  res = m_pFeatureContainer->GetFeatureByName( selectedFeatureInfos[i].name, pFeature );
831  if ( VmbErrorSuccess != res )
832  {
833  m_pImpl->m_selectedFeatures.clear();
834  return (VmbErrorType)res;
835  }
836  m_pImpl->m_selectedFeatures.push_back( pFeature );
837  pSelectedFeatures[i] = m_pImpl->m_selectedFeatures[i];
838  }
839  }
840  }
841 
842  return (VmbErrorType)res;
843 }
844 
846 {
847  bool bIsWritable = false;
848 
849  if ( NULL == m_pFeatureContainer )
850  {
851  return VmbErrorDeviceNotOpen;
852  }
853 
854  return (VmbErrorType)VmbFeatureAccessQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rbIsReadable, &bIsWritable );
855 }
856 
858 {
859  bool bIsReadable = false;
860 
861  if ( NULL == m_pFeatureContainer )
862  {
863  return VmbErrorDeviceNotOpen;
864  }
865 
866  return (VmbErrorType)VmbFeatureAccessQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &bIsReadable, &rbIsWritable );
867 }
868 
869 VmbErrorType BaseFeature::IsStreamable( bool &rbIsStreamable ) const
870 {
871  rbIsStreamable = m_featureInfo.isStreamable;
872 
873  return VmbErrorSuccess;
874 }
875 
876 
877 }} // namespace AVT::VmbAPI
VmbErrorDeviceNotOpen
@ VmbErrorDeviceNotOpen
Definition: VmbCommonTypes.h:113
AVT::VmbAPI::BaseFeature::RegisterObserver
IMEXPORT VmbErrorType RegisterObserver(const IFeatureObserverPtr &observer)
Definition: BaseFeature.cpp:213
AVT::VmbAPI::BaseFeature::Impl::m_bSelectedFeaturesFetched
bool m_bSelectedFeaturesFetched
Definition: BaseFeature.cpp:47
VmbFeatureInfo::visibility
VmbFeatureVisibility_t visibility
Definition: VimbaC.h:217
AVT::VmbAPI::BaseFeature::GetEntries
virtual IMEXPORT VmbErrorType GetEntries(EnumEntry *pEntries, VmbUint32_t &size)
Definition: BaseFeature.cpp:385
AVT::VmbAPI::BaseFeature::FeatureInfo::representation
std::string representation
Definition: BaseFeature.h:98
AVT::VmbAPI::ConditionHelper
Definition: ConditionHelper.h:39
SP_ACCESS
#define SP_ACCESS(sp)
Definition: SharedPointerDefines.h:49
AVT::VmbAPI::BaseFeature::m_featureInfo
FeatureInfo m_featureInfo
Definition: BaseFeature.h:106
VmbFeatureInvalidationUnregister
IMEXPORTC VmbError_t VMB_CALL VmbFeatureInvalidationUnregister(const VmbHandle_t handle, const char *name, VmbInvalidationCallback callback)
VmbFeatureInfo::category
const char * category
Definition: VimbaC.h:212
AVT::VmbAPI::BaseFeature::HasIncrement
virtual IMEXPORT VmbErrorType HasIncrement(VmbBool_t &incrementSupported) const
Definition: BaseFeature.cpp:337
AVT::VmbAPI::LockableVector< IFeatureObserverPtr >
AVT::VmbAPI::BaseFeature::GetIncrement
virtual IMEXPORT VmbErrorType GetIncrement(VmbInt64_t &increment) const
Definition: BaseFeature.cpp:342
FeatureContainer.h
AVT::VmbAPI::BaseFeature::IsStreamable
IMEXPORT VmbErrorType IsStreamable(bool &isStreamable) const
Definition: BaseFeature.cpp:869
VmbFeatureInfo::unit
const char * unit
Definition: VimbaC.h:215
AVT::VmbAPI::BaseFeature::FeatureInfo::hasSelectedFeatures
bool hasSelectedFeatures
Definition: BaseFeature.h:93
AVT
Definition: AncillaryData.h:35
AVT::VmbAPI::BaseFeature::GetAffectedFeatures
IMEXPORT VmbErrorType GetAffectedFeatures(FeaturePtr *pAffectedFeatures, VmbUint32_t &nSize)
Definition: BaseFeature.cpp:669
AVT::VmbAPI::BaseFeature::FeatureInfo::category
std::string category
Definition: BaseFeature.h:94
VmbErrorType
VmbErrorType
Definition: VmbCommonTypes.h:106
VmbFeatureInfo::featureFlags
VmbFeatureFlags_t featureFlags
Definition: VimbaC.h:211
AVT::VmbAPI::EnumEntry
Definition: EnumEntry.h:45
AVT::VmbAPI::BaseFeature::GetDisplayName
IMEXPORT VmbErrorType GetDisplayName(char *const pDisplayName, VmbUint32_t &length) const
Definition: BaseFeature.cpp:480
AVT::VmbAPI::BasicLockable::GetMutex
MutexPtr & GetMutex()
Definition: BasicLockable.cpp:48
VmbFeatureInfo::displayName
const char * displayName
Definition: VimbaC.h:213
AVT::VmbAPI::BaseFeature::FeatureInfo::featureDataType
VmbFeatureData_t featureDataType
Definition: BaseFeature.h:90
AVT::VmbAPI::ConditionHelper::ExitWriteLock
void ExitWriteLock(BasicLockable &rLockable)
Definition: ConditionHelper.cpp:106
VmbFeatureInfo::featureDataType
VmbFeatureData_t featureDataType
Definition: VimbaC.h:210
VmbFeatureListSelected
IMEXPORTC VmbError_t VMB_CALL VmbFeatureListSelected(const VmbHandle_t handle, const char *name, VmbFeatureInfo_t *pFeatureInfoList, VmbUint32_t listLength, VmbUint32_t *pNumFound, VmbUint32_t sizeofFeatureInfo)
AVT::VmbAPI::BaseFeature::GetFlags
IMEXPORT VmbErrorType GetFlags(VmbFeatureFlagsType &flags) const
Definition: BaseFeature.cpp:510
VmbFeatureInfo::name
const char * name
Definition: VimbaC.h:209
AVT::VmbAPI::BaseFeature::GetSelectedFeatures
IMEXPORT VmbErrorType GetSelectedFeatures(FeaturePtr *pSelectedFeatures, VmbUint32_t &nSize)
Definition: BaseFeature.cpp:757
VimbaSystem.h
AVT::VmbAPI::BaseFeature::Impl::m_conditionHelper
ConditionHelper m_conditionHelper
Definition: BaseFeature.cpp:50
VmbFeatureInfo::tooltip
const char * tooltip
Definition: VimbaC.h:218
AVT::VmbAPI::FeatureContainer::GetHandle
VmbHandle_t GetHandle() const
Definition: FeatureContainer.cpp:188
AVT::VmbAPI::BaseFeature::GetUnit
IMEXPORT VmbErrorType GetUnit(char *const pUnit, VmbUint32_t &length) const
Definition: BaseFeature.cpp:547
LOG_FREE_TEXT
#define LOG_FREE_TEXT(txt)
Definition: LoggerDefines.h:56
VmbErrorMoreData
@ VmbErrorMoreData
Definition: VmbCommonTypes.h:117
VmbFeatureFlagsType
VmbFeatureFlagsType
Definition: VimbaC.h:193
AVT::VmbAPI::BaseFeature::GetEntry
virtual IMEXPORT VmbErrorType GetEntry(EnumEntry &entry, const char *pStrEntryName) const
Definition: BaseFeature.cpp:379
AVT::VmbAPI::BaseFeature::GetDescription
IMEXPORT VmbErrorType GetDescription(char *const pDescription, VmbUint32_t &length) const
Definition: BaseFeature.cpp:623
AVT::VmbAPI::LockableVector::Vector
std::vector< T > Vector
Definition: Helper.h:41
AVT::VmbAPI::BaseFeature::FeatureInfo::unit
std::string unit
Definition: BaseFeature.h:97
AVT::VmbAPI::BaseFeature::FeatureInfo::name
std::string name
Definition: BaseFeature.h:89
ConditionHelper.h
AVT::VmbAPI::ConditionHelper::EnterReadLock
bool EnterReadLock(BasicLockable &rLockable)
Definition: ConditionHelper.cpp:43
AVT::VmbAPI::BaseFeature::Impl::m_observersConditionHelper
ConditionHelper m_observersConditionHelper
Definition: BaseFeature.cpp:49
AVT::VmbAPI::BaseFeature::Impl::m_affectedFeatures
FeaturePtrVector m_affectedFeatures
Definition: BaseFeature.cpp:44
AVT::VmbAPI::BaseFeature
Definition: BaseFeature.h:39
VmbError_t
VmbInt32_t VmbError_t
Definition: VmbCommonTypes.h:130
BaseFeature.h
AVT::VmbAPI::BaseFeature::GetToolTip
IMEXPORT VmbErrorType GetToolTip(char *const pToolTip, VmbUint32_t &length) const
Definition: BaseFeature.cpp:600
AVT::VmbAPI::BaseFeature::FeatureInfo::sfncNamespace
std::string sfncNamespace
Definition: BaseFeature.h:102
AVT::VmbAPI::BaseFeature::BaseFeature
BaseFeature()
Definition: BaseFeature.cpp:93
AVT::VmbAPI::BaseFeature::IsCommandDone
virtual IMEXPORT VmbErrorType IsCommandDone(bool &isDone) const
Definition: BaseFeature.cpp:440
AVT::VmbAPI::BaseFeature::GetValue
virtual IMEXPORT VmbErrorType GetValue(VmbInt64_t &value) const
Definition: BaseFeature.cpp:314
VmbFeatureInfo::hasAffectedFeatures
VmbBool_t hasAffectedFeatures
Definition: VimbaC.h:222
SP_ISNULL
#define SP_ISNULL(sp)
Definition: SharedPointerDefines.h:48
VmbFeatureListAffected
IMEXPORTC VmbError_t VMB_CALL VmbFeatureListAffected(const VmbHandle_t handle, const char *name, VmbFeatureInfo_t *pFeatureInfoList, VmbUint32_t listLength, VmbUint32_t *pNumFound, VmbUint32_t sizeofFeatureInfo)
AVT::VmbAPI::BaseFeature::GetValues
virtual IMEXPORT VmbErrorType GetValues(const char **pValues, VmbUint32_t &size)
Definition: BaseFeature.cpp:391
AVT::VmbAPI::FeatureContainer::GetFeatureByName
IMEXPORT VmbErrorType GetFeatureByName(const char *pName, FeaturePtr &pFeature)
Definition: FeatureContainer.cpp:72
AVT::VmbAPI::BaseFeature::FeatureInfo::featureFlags
VmbFeatureFlags_t featureFlags
Definition: BaseFeature.h:91
VmbFeatureVisibilityType
VmbFeatureVisibilityType
Definition: VimbaC.h:180
VmbHandle_t
void * VmbHandle_t
Definition: VmbCommonTypes.h:82
AVT::VmbAPI::BaseFeature::m_pImpl
Impl * m_pImpl
Definition: BaseFeature.h:117
AVT::VmbAPI::BaseFeature::UnregisterObserver
IMEXPORT VmbErrorType UnregisterObserver(const IFeatureObserverPtr &observer)
Definition: BaseFeature.cpp:260
VmbUint32_t
unsigned int VmbUint32_t
Definition: VmbCommonTypes.h:73
AVT::VmbAPI::BaseFeature::GetRange
virtual IMEXPORT VmbErrorType GetRange(VmbInt64_t &minimum, VmbInt64_t &maximum) const
Definition: BaseFeature.cpp:332
VmbErrorSuccess
@ VmbErrorSuccess
Definition: VmbCommonTypes.h:108
AVT::VmbAPI::BaseFeature::RunCommand
virtual IMEXPORT VmbErrorType RunCommand()
Definition: BaseFeature.cpp:434
AVT::VmbAPI::BaseFeature::m_pFeatureContainer
FeatureContainer * m_pFeatureContainer
Definition: BaseFeature.h:108
VmbInt64_t
long long VmbInt64_t
Definition: VmbCommonTypes.h:75
AVT::VmbAPI::BaseFeature::SetValue
virtual IMEXPORT VmbErrorType SetValue(const VmbInt32_t &value)
Definition: BaseFeature.cpp:326
VmbErrorInvalidCall
@ VmbErrorInvalidCall
Definition: VmbCommonTypes.h:123
AVT::VmbAPI::BaseFeature::IsValueAvailable
virtual IMEXPORT VmbErrorType IsValueAvailable(const char *pValue, bool &available) const
Definition: BaseFeature.cpp:403
AVT::VmbAPI::BaseFeature::GetPollingTime
IMEXPORT VmbErrorType GetPollingTime(VmbUint32_t &pollingTime) const
Definition: BaseFeature.cpp:540
AVT::VmbAPI::BaseFeature::Impl::InvalidationCallback
static void VMB_CALL InvalidationCallback(const VmbHandle_t handle, const char *name, void *context)
Definition: BaseFeature.cpp:147
VmbFeatureDataType
VmbFeatureDataType
Definition: VimbaC.h:163
AVT::VmbAPI::BaseFeature::Impl::m_observers
LockableVector< IFeatureObserverPtr > m_observers
Definition: BaseFeature.cpp:42
VmbFeatureInfo::hasSelectedFeatures
VmbBool_t hasSelectedFeatures
Definition: VimbaC.h:223
AVT::VmbAPI::ConditionHelper::ExitReadLock
void ExitReadLock(BasicLockable &rLockable)
Definition: ConditionHelper.cpp:65
AVT::VmbAPI::BaseFeature::FeatureInfo::isStreamable
bool isStreamable
Definition: BaseFeature.h:103
VmbErrorInternalFault
@ VmbErrorInternalFault
Definition: VmbCommonTypes.h:109
AVT::VmbAPI::BaseFeature::FeatureInfo::description
std::string description
Definition: BaseFeature.h:101
AVT::VmbAPI::BaseFeature::Impl::m_bAffectedFeaturesFetched
bool m_bAffectedFeaturesFetched
Definition: BaseFeature.cpp:46
VmbFeatureInfo::pollingTime
VmbUint32_t pollingTime
Definition: VimbaC.h:214
AVT::VmbAPI::BaseFeature::IsReadable
IMEXPORT VmbErrorType IsReadable(bool &isReadable)
Definition: BaseFeature.cpp:845
AVT::VmbAPI::BaseFeature::Impl::m_selectedFeatures
FeaturePtrVector m_selectedFeatures
Definition: BaseFeature.cpp:45
AVT::VmbAPI::BaseFeature::FeatureInfo::pollingTime
VmbUint32_t pollingTime
Definition: BaseFeature.h:96
AVT::VmbAPI::BaseFeature::FeatureInfo::displayName
std::string displayName
Definition: BaseFeature.h:95
VmbFeatureInfo::sfncNamespace
const char * sfncNamespace
Definition: VimbaC.h:220
AVT::VmbAPI::BaseFeature::GetCategory
IMEXPORT VmbErrorType GetCategory(char *const pCategory, VmbUint32_t &length) const
Definition: BaseFeature.cpp:517
AVT::VmbAPI::BaseFeature::GetSFNCNamespace
IMEXPORT VmbErrorType GetSFNCNamespace(char *const pSFNCNamespace, VmbUint32_t &length) const
Definition: BaseFeature.cpp:646
VmbErrorWrongType
@ VmbErrorWrongType
Definition: VmbCommonTypes.h:118
VmbFeatureAccessQuery
IMEXPORTC VmbError_t VMB_CALL VmbFeatureAccessQuery(const VmbHandle_t handle, const char *name, VmbBool_t *pIsReadable, VmbBool_t *pIsWriteable)
VmbFeatureInvalidationRegister
IMEXPORTC VmbError_t VMB_CALL VmbFeatureInvalidationRegister(const VmbHandle_t handle, const char *name, VmbInvalidationCallback callback, void *pUserContext)
VmbFeatureInfo::representation
const char * representation
Definition: VimbaC.h:216
AVT::VmbAPI::BaseFeature::ResetFeatureContainer
void ResetFeatureContainer()
Definition: BaseFeature.cpp:112
AVT::VmbAPI::FeatureContainer
Definition: FeatureContainer.h:40
AVT::VmbAPI::BaseFeature::FeatureInfo::tooltip
std::string tooltip
Definition: BaseFeature.h:100
Helper.h
AVT::VmbAPI::BaseFeature::GetVisibility
IMEXPORT VmbErrorType GetVisibility(VmbFeatureVisibilityType &visibility) const
Definition: BaseFeature.cpp:593
VmbUchar_t
unsigned char VmbUchar_t
Definition: VmbCommonTypes.h:101
AVT::VmbAPI::ConditionHelper::EnterWriteLock
bool EnterWriteLock(BasicLockable &rLockable, bool bExclusive=false)
Definition: ConditionHelper.cpp:79
AVT::VmbAPI::BaseFeature::GetName
virtual IMEXPORT VmbErrorType GetName(char *const pName, VmbUint32_t &length) const
Definition: BaseFeature.cpp:457
AVT::VmbAPI::BaseFeature::IsWritable
IMEXPORT VmbErrorType IsWritable(bool &isWritable)
Definition: BaseFeature.cpp:857
AVT::VmbAPI::BaseFeature::FeatureInfo::hasAffectedFeatures
bool hasAffectedFeatures
Definition: BaseFeature.h:92
AVT::VmbAPI::BaseFeature::FeatureInfo::visibility
VmbFeatureVisibility_t visibility
Definition: BaseFeature.h:99
VmbErrorBadParameter
@ VmbErrorBadParameter
Definition: VmbCommonTypes.h:115
AVT::VmbAPI::BaseFeature::GetDataType
IMEXPORT VmbErrorType GetDataType(VmbFeatureDataType &dataType) const
Definition: BaseFeature.cpp:503
VmbBool_t
char VmbBool_t
Definition: VmbCommonTypes.h:89
VmbFeatureInfo::description
const char * description
Definition: VimbaC.h:219
SP_ISEQUAL
#define SP_ISEQUAL(sp1, sp2)
Definition: SharedPointerDefines.h:47
AVT::VmbAPI::BaseFeature::Impl
Definition: BaseFeature.cpp:40
VmbErrorNotFound
@ VmbErrorNotFound
Definition: VmbCommonTypes.h:111
VmbFeatureInfo::isStreamable
VmbBool_t isStreamable
Definition: VimbaC.h:221
AVT::VmbAPI::FeaturePtrVector
std::vector< FeaturePtr > FeaturePtrVector
Definition: Feature.h:46
AVT::VmbAPI::BaseFeature::~BaseFeature
virtual ~BaseFeature()
Definition: BaseFeature.cpp:103
VmbInt32_t
int VmbInt32_t
Definition: VmbCommonTypes.h:71
VmbFeatureInfo
Definition: VimbaC.h:207
AVT::VmbAPI::BaseFeature::GetRepresentation
IMEXPORT VmbErrorType GetRepresentation(char *const pRepresentation, VmbUint32_t &length) const
Definition: BaseFeature.cpp:570


avt_vimba_camera
Author(s): Allied Vision Technologies, Miquel Massot
autogenerated on Sat Jun 3 2023 02:14:12