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 
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 
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
IMEXPORT VmbErrorType GetSelectedFeatures(FeaturePtr *pSelectedFeatures, VmbUint32_t &nSize)
VmbInt32_t VmbError_t
IMEXPORT VmbErrorType GetFeatureByName(const char *pName, FeaturePtr &pFeature)
bool EnterWriteLock(BasicLockable &rLockable, bool bExclusive=false)
#define SP_ISNULL(sp)
IMEXPORT VmbErrorType GetDataType(VmbFeatureDataType &dataType) const
FeaturePtrVector m_affectedFeatures
Definition: BaseFeature.cpp:44
char VmbBool_t
std::vector< T > Vector
Definition: Helper.h:41
IMEXPORT VmbErrorType GetPollingTime(VmbUint32_t &pollingTime) const
const char * sfncNamespace
Definition: VimbaC.h:221
static void VMB_CALL InvalidationCallback(const VmbHandle_t handle, const char *name, void *context)
const char * name
Definition: VimbaC.h:210
VmbFeatureVisibilityType
Definition: VimbaC.h:181
virtual IMEXPORT VmbErrorType GetName(char *const pName, VmbUint32_t &length) const
IMEXPORT VmbErrorType IsWritable(bool &isWritable)
long long VmbInt64_t
#define SP_ACCESS(sp)
IMEXPORT VmbErrorType GetDisplayName(char *const pDisplayName, VmbUint32_t &length) const
int VmbInt32_t
VmbUint32_t pollingTime
Definition: VimbaC.h:215
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)
IMEXPORT VmbErrorType GetToolTip(char *const pToolTip, VmbUint32_t &length) const
const char * tooltip
Definition: VimbaC.h:219
VmbFeatureDataType
Definition: VimbaC.h:164
VmbFeatureFlags_t featureFlags
Definition: VimbaC.h:212
VmbFeatureVisibility_t visibility
Definition: BaseFeature.h:99
virtual IMEXPORT VmbErrorType IsValueAvailable(const char *pValue, bool &available) const
VmbBool_t hasAffectedFeatures
Definition: VimbaC.h:223
ConditionHelper m_conditionHelper
Definition: BaseFeature.cpp:50
LockableVector< IFeatureObserverPtr > m_observers
Definition: BaseFeature.cpp:42
virtual IMEXPORT VmbErrorType IsCommandDone(bool &isDone) const
void ExitWriteLock(BasicLockable &rLockable)
virtual IMEXPORT VmbErrorType GetValue(VmbInt64_t &value) const
ConditionHelper m_observersConditionHelper
Definition: BaseFeature.cpp:49
virtual IMEXPORT VmbErrorType RunCommand()
virtual IMEXPORT VmbErrorType GetRange(VmbInt64_t &minimum, VmbInt64_t &maximum) const
VmbErrorType
IMEXPORTC VmbError_t VMB_CALL VmbFeatureInvalidationRegister(const VmbHandle_t handle, const char *name, VmbInvalidationCallback callback, void *pUserContext)
virtual IMEXPORT VmbErrorType GetEntries(EnumEntry *pEntries, VmbUint32_t &size)
virtual IMEXPORT VmbErrorType SetValue(const VmbInt32_t &value)
#define LOG_FREE_TEXT(txt)
Definition: LoggerDefines.h:57
VmbBool_t isStreamable
Definition: VimbaC.h:222
unsigned char VmbUchar_t
void * VmbHandle_t
IMEXPORTC VmbError_t VMB_CALL VmbFeatureInvalidationUnregister(const VmbHandle_t handle, const char *name, VmbInvalidationCallback callback)
NetPointer< Feature, AVT::VmbAPINET::Feature > FeaturePtr
IMEXPORTC VmbError_t VMB_CALL VmbFeatureAccessQuery(const VmbHandle_t handle, const char *name, VmbBool_t *pIsReadable, VmbBool_t *pIsWriteable)
struct VmbFeatureInfo VmbFeatureInfo_t
IMEXPORT VmbErrorType GetFlags(VmbFeatureFlagsType &flags) const
IMEXPORT VmbErrorType GetCategory(char *const pCategory, VmbUint32_t &length) const
VmbBool_t hasSelectedFeatures
Definition: VimbaC.h:224
virtual IMEXPORT VmbErrorType GetEntry(EnumEntry &entry, const char *pStrEntryName) const
#define SP_ISEQUAL(sp1, sp2)
IMEXPORT VmbErrorType GetRepresentation(char *const pRepresentation, VmbUint32_t &length) const
virtual IMEXPORT VmbErrorType HasIncrement(VmbBool_t &incrementSupported) const
IMEXPORT VmbErrorType RegisterObserver(const IFeatureObserverPtr &observer)
const char * description
Definition: VimbaC.h:220
MutexPtr GetMutex() const
void ExitReadLock(BasicLockable &rLockable)
IMEXPORT VmbErrorType GetDescription(char *const pDescription, VmbUint32_t &length) const
IMEXPORT VmbErrorType GetUnit(char *const pUnit, VmbUint32_t &length) const
FeaturePtrVector m_selectedFeatures
Definition: BaseFeature.cpp:45
unsigned int VmbUint32_t
bool EnterReadLock(BasicLockable &rLockable)
VmbFeatureVisibility_t visibility
Definition: VimbaC.h:218
IMEXPORT VmbErrorType GetSFNCNamespace(char *const pSFNCNamespace, VmbUint32_t &length) const
IMEXPORT VmbErrorType IsStreamable(bool &isStreamable) const
const char * representation
Definition: VimbaC.h:217
VmbFeatureFlagsType
Definition: VimbaC.h:194
IMEXPORT VmbErrorType GetAffectedFeatures(FeaturePtr *pAffectedFeatures, VmbUint32_t &nSize)
IMEXPORT VmbErrorType UnregisterObserver(const IFeatureObserverPtr &observer)
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)
virtual IMEXPORT VmbErrorType GetValues(const char **pValues, VmbUint32_t &size)
std::vector< FeaturePtr > FeaturePtrVector
Definition: Feature.h:46
const char * category
Definition: VimbaC.h:213
virtual IMEXPORT VmbErrorType GetIncrement(VmbInt64_t &increment) const
const char * displayName
Definition: VimbaC.h:214
FeatureContainer * m_pFeatureContainer
Definition: BaseFeature.h:108
IMEXPORT VmbErrorType IsReadable(bool &isReadable)
VmbFeatureData_t featureDataType
Definition: VimbaC.h:211
const char * unit
Definition: VimbaC.h:216
IMEXPORT VmbErrorType GetVisibility(VmbFeatureVisibilityType &visibility) const


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