PolyReference.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2008 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenApi
5 // Author: Fritz Dierks
6 // $Header$
7 //
8 // License: This file is published under the license of the EMVA GenICam Standard Group.
9 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
10 // If for some reason you are missing this file please contact the EMVA or visit the website
11 // (http://www.genicam.org) for a full copy.
12 //
13 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
14 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
17 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 // POSSIBILITY OF SUCH DAMAGE.
24 //-----------------------------------------------------------------------------
31 #ifndef GENAPI_POLYREFERENCE_H
32 #define GENAPI_POLYREFERENCE_H
33 
34 #include "Base/GCBase.h"
35 #include "GenApi/IBase.h"
36 #include "GenApi/IValue.h"
37 #include "GenApi/IFloat.h"
38 #include "GenApi/IInteger.h"
39 #include "GenApi/IEnumeration.h"
40 #include "GenApi/IBoolean.h"
41 #include "GenApi/IString.h"
43 #include "GenApi/Pointer.h"
44 #include <limits>
45 
46 #undef min
47 #undef max
48 
49 namespace GENAPI_NAMESPACE
50 {
51  inline int64_t round(double x)
52  {
53  return (int64_t)(x > 0.0 ? x + 0.5 : x - 0.5);
54  }
55 
56  //inline int64_t abs(int64_t x)
57  //{
58  // return (x >= 0 ? x : -x);
59  //}
60 
61  inline double abs(double x)
62  {
63  return (x >= 0.0 ? x : -x);
64  }
65 
69  {
70  public:
74  {
75  m_Value.Value = 0;
76  }
77 
80  {
81  m_Type = typeValue;
82  m_Value.Value = Value;
83  }
84 
86  void operator=(INode *pValue)
87  {
88  operator=( dynamic_cast<IBase*>(pValue) );
89  }
90 
92  void operator=(IBase *pValue)
93  {
94  m_Value.pInteger = dynamic_cast<IInteger*>(pValue);
95  if( m_Value.pInteger )
97  else
98  {
99  m_Value.pEnumeration = dynamic_cast<IEnumeration*>(pValue);
100  if( m_Value.pEnumeration )
102  else
103  {
104  m_Value.pBoolean = dynamic_cast<IBoolean*>(pValue);
105  if( m_Value.pBoolean )
107  else
108  {
109  m_Value.pFloat = dynamic_cast<IFloat*>(pValue);
110  if( m_Value.pFloat )
111  m_Type = typeIFloat;
112  else
113  throw RUNTIME_EXCEPTION("CIntegerPolyRef::operator(IBase*) : pointer is neither IInteger*, nor IEnumeration*, nor IBoolean*, nor IFloat*");
114  }
115  }
116  }
117  }
118 
120  inline bool IsPointer() const
121  {
122  return (m_Type != typeValue) && (m_Type != typeUninitialized);
123  }
124 
126  inline bool IsValue() const
127  {
128  return (m_Type == typeValue) && (m_Type != typeUninitialized);
129  }
130 
132  inline bool IsInitialized() const
133  {
134  return (m_Type != typeUninitialized);
135  }
136 
138  inline INodePrivate *GetPointer() const
139  {
140  switch(m_Type)
141  {
142  case typeIInteger:
143  return dynamic_cast<INodePrivate*>(m_Value.pInteger);
144  case typeIEnumeration:
145  return dynamic_cast<INodePrivate*>(m_Value.pEnumeration);
146  case typeIBoolean:
147  return dynamic_cast<INodePrivate*>(m_Value.pBoolean);
148  case typeIFloat:
149  return dynamic_cast<INodePrivate*>(m_Value.pFloat);
150  case typeValue:
151  return NULL;
152 # pragma BullseyeCoverage off
153  case typeUninitialized:
154  default:
155  return NULL;
156 # pragma BullseyeCoverage on
157  }
158  }
159 
161  inline operator INode*(void) const
162  {
163  return GetPointer();
164  }
165 
167  inline int64_t GetValue( bool Verify = false, bool IgnoreCache = false) const
168  {
169  switch(m_Type)
170  {
171  case typeValue:
172  return m_Value.Value;
173  case typeIInteger:
174  return m_Value.pInteger->GetValue(Verify, IgnoreCache);
175  case typeIEnumeration:
176  {
177  CEnumEntryPtr ptrEnumEntry = m_Value.pEnumeration->GetCurrentEntry(Verify, IgnoreCache);
178  return round(ptrEnumEntry->GetNumericValue());
179  }
180  case typeIBoolean:
181  return m_Value.pBoolean->GetValue(Verify, IgnoreCache) ? 1 : 0;
182  case typeIFloat:
183  {
184  double Result = m_Value.pFloat->GetValue(Verify, IgnoreCache);
185  if (Result > (int64_t)GC_INT64_MAX || Result < (int64_t)GC_INT64_MIN)
186  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetValue(): Float value %f out of integer range", Result);
187  return round(Result);
188  }
189  case typeUninitialized:
190 #pragma BullseyeCoverage off
191  default:
192  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetValue(): uninitialized pointer");
193 #pragma BullseyeCoverage on
194  }
195  }
196 
198  inline void SetValue( int64_t Value, bool Verify = true)
199  {
200  switch(m_Type)
201  {
202  case typeValue:
203  m_Value.Value = Value;
204  break;
205  case typeIInteger:
206  m_Value.pInteger->SetValue(Value, Verify);
207  break;
208  case typeIEnumeration:
209  {
210  CEnumEntryPtr ptrOldEnumEntry;
211  double OldDistance = -1;
212  NodeList_t EnumEntries;
213  m_Value.pEnumeration->GetEntries(EnumEntries);
214  for( NodeList_t::iterator it=EnumEntries.begin(); it!=EnumEntries.end(); ++it )
215  {
216  if( IsAvailable(*it) )
217  {
218  if( !ptrOldEnumEntry.IsValid() )
219  {
220  ptrOldEnumEntry = *it;
221  OldDistance = abs( (double)Value - ptrOldEnumEntry->GetNumericValue() );
222  }
223  else
224  {
225  CEnumEntryPtr ptrNewEnumEntry( *it );
226  double NewDistance = abs( (double)Value - ptrNewEnumEntry->GetNumericValue() ) ;
227  if(NewDistance < OldDistance)
228  {
229  ptrOldEnumEntry = *it;
230  OldDistance = NewDistance;
231  }
232  }
233  }
234  }
235  if( ptrOldEnumEntry.IsValid() )
236  m_Value.pEnumeration->SetIntValue(ptrOldEnumEntry->GetValue(), Verify);
237  else
238  throw ACCESS_EXCEPTION("Failed to write enumeration. None of the entries is writable");
239  }
240  break;
241  case typeIBoolean:
242  return m_Value.pBoolean->SetValue( (Value != 0), Verify);
243  break;
244  case typeIFloat:
245  return m_Value.pFloat->SetValue( (double)Value, Verify);
246  break;
247  case typeUninitialized:
248 #pragma BullseyeCoverage off
249  default:
250  throw RUNTIME_EXCEPTION("CIntegerPolyRef::SetValue(): uninitialized pointer");
251 #pragma BullseyeCoverage on
252  }
253  }
254 
256  inline int64_t GetMin() const
257  {
258  switch(m_Type)
259  {
260  case typeIInteger:
261  return m_Value.pInteger->GetMin();
262  case typeIEnumeration:
263  case typeIBoolean:
264  case typeValue:
265  return GC_INT64_MIN;
266  case typeIFloat:
267  {
268  double Min = m_Value.pFloat->GetMin();
269  if(Min > (int64_t)GC_INT64_MAX || Min < (int64_t)GC_INT64_MIN)
270  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetMin(): Float value %f out of integer range", Min);
271  return round(Min);
272  }
273  case typeUninitialized:
274 #pragma BullseyeCoverage off
275  default:
276  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetMin(): uninitialized pointer");
277 #pragma BullseyeCoverage on
278  }
279  }
280 
282  inline int64_t GetMax() const
283  {
284  switch(m_Type)
285  {
286  case typeIInteger:
287  return m_Value.pInteger->GetMax();
288  case typeIEnumeration:
289  case typeIBoolean:
290  case typeValue:
291  return GC_INT64_MAX;
292  case typeIFloat:
293  {
294  double Max = m_Value.pFloat->GetMax();
295  if(Max > (int64_t)GC_INT64_MAX || Max < (int64_t)GC_INT64_MIN)
296  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetMin(): Float value %f out of integer range", Max);
297  return round(Max);
298  }
299  case typeUninitialized:
300 #pragma BullseyeCoverage off
301  default:
302  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetMax(): uninitialized pointer");
303 #pragma BullseyeCoverage on
304  }
305  }
306 
308  inline int64_t GetInc() const
309  {
310  switch(m_Type)
311  {
312  case typeIInteger:
313  return m_Value.pInteger->GetInc();
314  case typeIEnumeration:
315  case typeIBoolean:
316  case typeValue:
317  return 1;
318  case typeIFloat:
319  if( m_Value.pFloat->HasInc() )
320  return round(m_Value.pFloat->GetInc());
321  else
322  return 1;
323  case typeUninitialized:
324 #pragma BullseyeCoverage off
325  default:
326  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetInc(): uninitialized pointer");
327 #pragma BullseyeCoverage on
328  }
329  }
330 
333  {
334  switch(m_Type)
335  {
336  case typeIInteger:
337  return m_Value.pInteger->GetRepresentation();
338  case typeValue:
339  case typeIEnumeration:
340  case typeIBoolean:
341  case typeIFloat:
342  return PureNumber;
343  case typeUninitialized:
344 #pragma BullseyeCoverage off
345  default:
346  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetRepresentation(): uninitialized pointer");
347 #pragma BullseyeCoverage on
348  }
349  }
350 
353  {
354  switch(m_Type)
355  {
356  case typeIInteger:
357  return m_Value.pInteger->GetUnit();
358  case typeIFloat:
359  return m_Value.pFloat->GetUnit();
360  case typeValue:
361  case typeIEnumeration:
362  case typeIBoolean:
364  case typeUninitialized:
365 #pragma BullseyeCoverage off
366  default:
367  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetUnit(): uninitialized pointer");
368  }
369 #pragma BullseyeCoverage on
370  }
371 
373  bool IsValueCacheValid() const
374  {
375  switch(m_Type)
376  {
377  case typeIInteger:
378  return m_Value.pInteger->IsValueCacheValid();
379  case typeIEnumeration:
380  return m_Value.pEnumeration->IsValueCacheValid();
381  case typeIBoolean:
382  return m_Value.pBoolean->IsValueCacheValid();
383  case typeIFloat:
384  return m_Value.pFloat->IsValueCacheValid();
385  case typeValue:
386  return true;
387  case typeUninitialized:
388 # pragma BullseyeCoverage off
389  default:
390  throw RUNTIME_EXCEPTION("CIntegerPolyRef::IsValueCacheValid(): uninitialized pointer");
391  }
392 # pragma BullseyeCoverage on
393  }
394 
396  {
397  switch(m_Type)
398  {
399  case typeIInteger:
400  return m_Value.pInteger->GetNode()->GetCachingMode();
401  case typeIEnumeration:
402  return m_Value.pEnumeration->GetNode()->GetCachingMode();
403  case typeIBoolean:
404  return m_Value.pBoolean->GetNode()->GetCachingMode();
405  case typeIFloat:
406  return m_Value.pFloat->GetNode()->GetCachingMode();
407  case typeValue:
408  return WriteThrough;
409  case typeUninitialized:
410  #pragma BullseyeCoverage off
411  default:
412  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetCachingMode(): uninitialized pointer");
413  #pragma BullseyeCoverage on
414  }
415  }
416 
417  protected:
419  typedef enum _EType
420  {
427  } EType;
428 
430  EType m_Type;
431 
433  union
434  {
440  } m_Value;
441  };
442 
443 
447  {
448  public:
452  {
453  m_Value.Value = false;
454  }
455 
456  #pragma BullseyeCoverage off
458  {
459  CNodePtr ptrNode = GetPointer();
460  if( ptrNode.IsValid() )
461  return ptrNode->GetName();
462  else
463  return GENICAM_NAMESPACE::gcstring(".Value.");
464  }
465  #pragma BullseyeCoverage on
466 
468  void operator=(bool Value)
469  {
470  m_Type = typeValue;
471  m_Value.Value = Value;
472  }
473 
475  void operator=(IBase *pValue)
476  {
477  m_Value.pInteger = dynamic_cast<IInteger*>(pValue);
478  if( m_Value.pInteger )
480  else
481  {
482  m_Value.pEnumeration = dynamic_cast<IEnumeration*>(pValue);
483  if( m_Value.pEnumeration )
485  else
486  {
487  m_Value.pBoolean = dynamic_cast<IBoolean*>(pValue);
488  if( m_Value.pBoolean )
490  else
491  throw RUNTIME_EXCEPTION("CIntegerPolyRef::operator(IBase*) : pointer is neither IInteger*, IEnumeration*, nor IBoolean*");
492  }
493  }
494  }
495 
497  inline bool IsPointer() const
498  {
499  return (m_Type != typeValue) && (m_Type != typeUninitialized);
500  }
501 
503  inline bool IsInitialized() const
504  {
505  return (m_Type != typeUninitialized);
506  }
507 
509  inline INodePrivate *GetPointer() const
510  {
511  switch(m_Type)
512  {
513  case typeIInteger:
514  return dynamic_cast<INodePrivate*>(m_Value.pInteger);
515  case typeIEnumeration:
516  return dynamic_cast<INodePrivate*>(m_Value.pEnumeration);
517  case typeIBoolean:
518  return dynamic_cast<INodePrivate*>(m_Value.pBoolean);
519  case typeValue:
520  return NULL;
521 #pragma BullseyeCoverage off
522  case typeUninitialized:
523  default:
524  assert(false);
525  return NULL;
526 #pragma BullseyeCoverage on
527  }
528  }
529 
531  inline operator INode*(void) const
532  {
533  return GetPointer();
534  }
535 
537  inline bool GetValue( bool Verify = false, bool IgnoreCache = false) const
538  {
539  switch(m_Type)
540  {
541  case typeValue:
542  return m_Value.Value;
543  case typeIInteger:
544  return m_Value.pInteger->GetValue(Verify, IgnoreCache) != 0;
545  case typeIEnumeration:
546  return m_Value.pEnumeration->GetIntValue(Verify, IgnoreCache) != 0;
547  case typeIBoolean:
548  return m_Value.pBoolean->GetValue(Verify, IgnoreCache);
549  case typeUninitialized:
550 #pragma BullseyeCoverage off
551  default:
552  throw RUNTIME_EXCEPTION("CIntegerPolyRef::GetValue(): uninitialized pointer");
553 #pragma BullseyeCoverage on
554  }
555  }
556 
558  inline void SetValue( bool Value, bool Verify = true)
559  {
560  switch(m_Type)
561  {
562  case typeValue:
563  m_Value.Value = Value;
564  break;
565  case typeIInteger:
566  m_Value.pInteger->SetValue(Value ? 1 : 0, Verify);
567  break;
568  case typeIEnumeration:
569  return m_Value.pEnumeration->SetIntValue(Value, Verify);
570  break;
571  case typeIBoolean:
572  return m_Value.pBoolean->SetValue(Value, Verify);
573  break;
574  case typeUninitialized:
575 #pragma BullseyeCoverage off
576  default:
577  throw RUNTIME_EXCEPTION("CIntegerPolyRef::SetValue(): uninitialized pointer");
578 #pragma BullseyeCoverage on
579  }
580  }
581 
583  {
584  switch(m_Type)
585  {
586  case typeIInteger:
587  return m_Value.pInteger->GetNode()->GetCachingMode();
588  case typeIEnumeration:
589  return m_Value.pEnumeration->GetNode()->GetCachingMode();
590  case typeIBoolean:
591  return m_Value.pBoolean->GetNode()->GetCachingMode();
592  case typeValue:
593  return WriteThrough;
594  case typeUninitialized:
595  #pragma BullseyeCoverage off
596  default:
597  throw RUNTIME_EXCEPTION("CBooleanPolyRef::GetCachingMode(): uninitialized pointer");
598  #pragma BullseyeCoverage on
599  }
600  }
601  protected:
603  typedef enum _EType
604  {
610  } EType;
611 
613  EType m_Type;
614 
616  union
617  {
618  bool Value;
622  } m_Value;
623 
624  };
625 
629  {
630  public:
634  {
635  m_Value.Value = 0.0;
636  }
637 
639  void operator=(double Value)
640  {
641  m_Type = typeValue;
642  m_Value.Value = Value;
643  }
644 
646  void operator=(INode *pValue)
647  {
648  operator=( dynamic_cast<IBase*>(pValue) );
649  }
650 
652  void operator=(IBase *pValue)
653  {
654  m_Value.pFloat = dynamic_cast<IFloat*>(pValue);
655  if( m_Value.pFloat)
656  m_Type = typeIFloat;
657  else
658  {
659  m_Value.pEnumeration = dynamic_cast<IEnumeration*>(pValue);
660  if( m_Value.pEnumeration )
662  else
663  {
664  m_Value.pInteger= dynamic_cast<IInteger*>(pValue);
665  if( m_Value.pInteger)
667  else
668  throw RUNTIME_EXCEPTION("CFloatPolyRef::operator(IBase*) : pointer is neither IFloat*, IInteger*, nor IEnumeration*");
669  }
670  }
671  }
672 
674  inline bool IsValue() const
675  {
676  return (m_Type == typeValue) && (m_Type != typeUninitialized);
677  }
678 
680  inline bool IsPointer() const
681  {
682  return (m_Type != typeValue) && (m_Type != typeUninitialized);
683  }
684 
686  inline bool IsInitialized() const
687  {
688  return (m_Type != typeUninitialized);
689  }
690 
692  inline INodePrivate *GetPointer() const
693  {
694  switch(m_Type)
695  {
696  case typeIFloat:
697  return dynamic_cast<INodePrivate*>(m_Value.pFloat);
698  case typeIInteger:
699  return dynamic_cast<INodePrivate*>(m_Value.pInteger);
700  case typeIEnumeration:
701  return dynamic_cast<INodePrivate*>(m_Value.pEnumeration);
702  case typeValue:
703  return NULL;
704  #pragma BullseyeCoverage off
705  case typeUninitialized:
706  default:
707  assert(false);
708  return NULL;
709  #pragma BullseyeCoverage on
710  }
711  }
712 
714  inline operator INode*(void) const
715  {
716  return GetPointer();
717  }
718 
720  inline double GetValue( bool Verify = false, bool IgnoreCache = false) const
721  {
722  switch(m_Type)
723  {
724  case typeValue:
725  return m_Value.Value;
726  case typeIFloat:
727  return m_Value.pFloat->GetValue(Verify, IgnoreCache);
728  case typeIInteger:
729  return (double)m_Value.pInteger->GetValue(Verify, IgnoreCache);
730  case typeIEnumeration:
731  {
732  CEnumEntryPtr ptrEnumEntry = m_Value.pEnumeration->GetCurrentEntry(Verify, IgnoreCache);
733  return ptrEnumEntry->GetNumericValue();
734  }
735  case typeUninitialized:
736  #pragma BullseyeCoverage off
737  default:
738  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetValue(): uninitialized pointer");
739  #pragma BullseyeCoverage on
740  }
741  }
742 
744  inline void SetValue( double Value, bool Verify = true)
745  {
746  switch(m_Type)
747  {
748  case typeValue:
749  m_Value.Value = Value;
750  break;
751  case typeIFloat:
752  m_Value.pFloat->SetValue(Value, Verify);
753  break;
754  case typeIInteger:
755  {
756  if( Value > (int64_t)GC_INT64_MAX || Value < (int64_t)GC_INT64_MIN )
757  throw OUT_OF_RANGE_EXCEPTION("CIntegerPolyRef::SetValue(): double value outside int64 range");
758 
759  int64_t TargetValue = round(Value);
760  int64_t Residuum = (TargetValue - m_Value.pInteger->GetMin()) % m_Value.pInteger->GetInc();
761  TargetValue -= Residuum;
762  if( 2 * Residuum > m_Value.pInteger->GetInc())
763  TargetValue += m_Value.pInteger->GetInc();
764  m_Value.pInteger->SetValue(TargetValue, Verify);
765  }
766  break;
767  case typeIEnumeration:
768  {
769  CEnumEntryPtr ptrOldEnumEntry;
770  double OldDistance = -1;
771  NodeList_t EnumEntries;
772  m_Value.pEnumeration->GetEntries(EnumEntries);
773  for( NodeList_t::iterator it=EnumEntries.begin(); it!=EnumEntries.end(); ++it )
774  {
775  if( IsAvailable(*it) )
776  {
777  if( !ptrOldEnumEntry.IsValid() )
778  {
779  ptrOldEnumEntry = *it;
780  OldDistance = abs( Value - ptrOldEnumEntry->GetNumericValue() );
781  }
782  else
783  {
784  CEnumEntryPtr ptrNewEnumEntry( *it );
785  double NewDistance = abs( Value - ptrNewEnumEntry->GetNumericValue() ) ;
786  if(NewDistance < OldDistance)
787  {
788  ptrOldEnumEntry = *it;
789  OldDistance = NewDistance;
790  }
791  }
792  }
793  }
794  if( ptrOldEnumEntry.IsValid() )
795  m_Value.pEnumeration->SetIntValue(ptrOldEnumEntry->GetValue(), Verify);
796  else
797  throw ACCESS_EXCEPTION("Failed to write enumeration. None of the entries is writable");
798  }
799  break;
800  case typeUninitialized:
801  #pragma BullseyeCoverage off
802  default:
803  throw RUNTIME_EXCEPTION("CIntegerPolyRef::SetValue(): uninitialized pointer");
804  #pragma BullseyeCoverage on
805  }
806  }
807 
809  inline double GetMin() const
810  {
811  switch(m_Type)
812  {
813  case typeIFloat:
814  return m_Value.pFloat->GetMin();
815  case typeIInteger:
816  return (double) m_Value.pInteger->GetMin();
817  case typeIEnumeration:
818  case typeValue:
819  return -std::numeric_limits<double>::max();
820  case typeUninitialized:
821  #pragma BullseyeCoverage off
822  default:
823  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetMin(): uninitialized pointer");
824  #pragma BullseyeCoverage on
825  }
826  }
827 
829  inline double GetMax() const
830  {
831  switch(m_Type)
832  {
833  case typeIFloat:
834  return m_Value.pFloat->GetMax();
835  case typeIInteger:
836  return (double) m_Value.pInteger->GetMax();
837  case typeIEnumeration:
838  case typeValue:
839  return std::numeric_limits<double>::max();
840  case typeUninitialized:
841  #pragma BullseyeCoverage off
842  default:
843  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetMax(): uninitialized pointer");
844  #pragma BullseyeCoverage on
845  }
846  }
847 
849  inline bool HasInc()
850  {
851  switch(m_Type)
852  {
853  case typeIFloat:
854  return m_Value.pFloat->HasInc();
855  case typeIInteger:
856  return true;
857  case typeIEnumeration:
858  case typeValue:
859  case typeUninitialized:
860  #pragma BullseyeCoverage off
861  default:
862  return false;
863  #pragma BullseyeCoverage on
864  }
865  }
866 
868  virtual double GetInc()
869  {
870  switch(m_Type)
871  {
872  case typeIFloat:
873  return m_Value.pFloat->GetInc();
874  case typeIInteger:
875  return (double) m_Value.pInteger->GetInc();
876  case typeIEnumeration:
877  case typeValue:
878  case typeUninitialized:
879  #pragma BullseyeCoverage off
880  default:
881  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetInc(): uninitialized pointer");
882  #pragma BullseyeCoverage on
883  }
884  }
885 
887  #pragma BullseyeCoverage off
888  inline double GetInc() const
889  {
890  switch(m_Type)
891  {
892  case typeIInteger:
893  return (double) m_Value.pInteger->GetInc();
894  case typeIFloat:
895  case typeIEnumeration:
896  case typeValue:
897  return 1.0;
898  case typeUninitialized:
899  #pragma BullseyeCoverage off
900  default:
901  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetMax(): uninitialized pointer");
902  #pragma BullseyeCoverage on
903  }
904  }
905  #pragma BullseyeCoverage on
906 
909  {
910  switch(m_Type)
911  {
912  case typeIFloat:
913  return m_Value.pFloat->GetRepresentation();
914  case typeIInteger:
915  return m_Value.pInteger->GetRepresentation();
916  case typeValue:
917  case typeIEnumeration:
918  return PureNumber;
919  case typeUninitialized:
920  #pragma BullseyeCoverage off
921  default:
922  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetRepresentation(): uninitialized pointer");
923  #pragma BullseyeCoverage on
924  }
925  }
926 
929  {
930  switch(m_Type)
931  {
932  case typeIFloat:
933  return m_Value.pFloat->GetUnit();
934  case typeIInteger:
935  return m_Value.pInteger->GetUnit();
936  case typeValue:
937  case typeIEnumeration:
939  case typeUninitialized:
940  #pragma BullseyeCoverage off
941  default:
942  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetUnit(): uninitialized pointer");
943  #pragma BullseyeCoverage on
944  }
945  }
946 
947 // this is currently not needed but may be in future so we keep the code
948 #if 0
949  bool IsValueCacheValid() const
951  {
952  switch(m_Type)
953  {
954  case typeIFloat:
955  return m_Value.pFloat->IsValueCacheValid();
956  case typeIInteger:
957  return m_Value.pInteger->IsValueCacheValid();
958  case typeIEnumeration:
959  return m_Value.pEnumeration->IsValueCacheValid();
960  case typeValue:
961  return true;
962  case typeUninitialized:
963  #pragma BullseyeCoverage off
964  default:
965  throw RUNTIME_EXCEPTION("CFloatPolyRef::IsValueCacheValid(): uninitialized pointer");
966  #pragma BullseyeCoverage on
967  }
968  }
969 #endif
970 
973  {
974  switch(m_Type)
975  {
976  case typeIFloat:
977  return m_Value.pFloat->GetDisplayNotation();
978  case typeIInteger:
979  case typeIEnumeration:
980  case typeValue:
981  return fnAutomatic;
982  case typeUninitialized:
983  #pragma BullseyeCoverage off
984  default:
985  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetDisplayNotation(): uninitialized pointer");
986  #pragma BullseyeCoverage on
987  }
988  }
989 
992  {
993  switch(m_Type)
994  {
995  case typeIFloat:
996  return m_Value.pFloat->GetDisplayPrecision();
997  case typeIInteger:
998  case typeIEnumeration:
999  case typeValue:
1000  return -1;
1001  case typeUninitialized:
1002  #pragma BullseyeCoverage off
1003  default:
1004  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetDisplayPrecision(): uninitialized pointer");
1005  #pragma BullseyeCoverage on
1006  }
1007  }
1008 
1010  typedef enum _EType
1011  {
1017  } EType;
1018 
1020  {
1021  switch(m_Type)
1022  {
1023  case typeIInteger:
1024  return m_Value.pInteger->GetNode()->GetCachingMode();
1025  case typeIEnumeration:
1026  return m_Value.pEnumeration->GetNode()->GetCachingMode();
1027  case typeIFloat:
1028  return m_Value.pFloat->GetNode()->GetCachingMode();
1029  case typeValue:
1030  return WriteThrough;
1031  case typeUninitialized:
1032  #pragma BullseyeCoverage off
1033  default:
1034  throw RUNTIME_EXCEPTION("CFloatPolyRef::GetCachingMode(): uninitialized pointer");
1035  #pragma BullseyeCoverage on
1036  }
1037  }
1038  protected:
1040  EType m_Type;
1041 
1043  union
1044  {
1045  double Value;
1049  } m_Value;
1050 
1051  };
1052 
1053 
1057  {
1058  public:
1062  {
1063  m_Value.pString = NULL;
1064  }
1065 
1066  #pragma BullseyeCoverage off
1068  {
1069  CNodePtr ptrNode = GetPointer();
1070  if( ptrNode.IsValid() )
1071  return ptrNode->GetName();
1072  else
1073  return GENICAM_NAMESPACE::gcstring(".Value.");
1074  }
1075  #pragma BullseyeCoverage on
1076 
1079  {
1080  m_Type = typeValue;
1081  m_Value.Value = Value;
1082  }
1083 
1085  void operator=(IBase *pValue)
1086  {
1087  m_Value.pString = dynamic_cast<IString*>(pValue);
1088  if( m_Value.pString )
1089  m_Type = typeIString;
1090  else
1091  throw RUNTIME_EXCEPTION("CStringPolyRef::operator(IBase*) : pointer is not IString*");
1092  }
1093 
1095  inline bool IsValue() const
1096  {
1097  return (m_Type == typeValue);
1098  }
1099 
1100 
1102  inline bool IsPointer() const
1103  {
1104  return (m_Type != typeValue) && (m_Type != typeUninitialized);
1105  }
1106 
1108  inline bool IsInitialized() const
1109  {
1110  return (m_Type != typeUninitialized);
1111  }
1112 
1114  inline INodePrivate *GetPointer() const
1115  {
1116  switch(m_Type)
1117  {
1118  case typeIString:
1119  return dynamic_cast<INodePrivate*>(m_Value.pString);
1120  case typeValue:
1121  return NULL;
1122 # pragma BullseyeCoverage off
1123  case typeUninitialized:
1124  default:
1125  assert(false);
1126  return NULL;
1127 # pragma BullseyeCoverage on
1128  }
1129  }
1130 
1132  inline operator INode*(void) const
1133  {
1134  return GetPointer();
1135  }
1136 
1138  inline GENICAM_NAMESPACE::gcstring GetValue( bool Verify = false, bool IgnoreCache = false) const
1139  {
1140  switch(m_Type)
1141  {
1142  case typeValue:
1143  return m_Value.Value;
1144  case typeIString:
1145  return m_Value.pString->GetValue(Verify, IgnoreCache);
1146  case typeUninitialized:
1147 #pragma BullseyeCoverage off
1148  default:
1149  throw RUNTIME_EXCEPTION("CStringPolyRef::GetValue(): uninitialized pointer");
1150 #pragma BullseyeCoverage on
1151  }
1152  }
1153 
1155  inline void SetValue( const GENICAM_NAMESPACE::gcstring& Value, bool Verify = true)
1156  {
1157  switch(m_Type)
1158  {
1159  case typeValue:
1160  m_Value.Value = Value;
1161  break;
1162  case typeIString:
1163  m_Value.pString->SetValue(Value, Verify);
1164  break;
1165  case typeUninitialized:
1166 #pragma BullseyeCoverage off
1167  default:
1168  throw RUNTIME_EXCEPTION("CStringPolyRef::SetValue(): uninitialized pointer");
1169 #pragma BullseyeCoverage on
1170  }
1171  }
1172 
1175  {
1176  switch(m_Type)
1177  {
1178  case typeValue:
1179  return m_Value.Value.max_size();
1180  break;
1181  case typeIString:
1182  return m_Value.pString->GetMaxLength();
1183  break;
1184  case typeUninitialized:
1185 #pragma BullseyeCoverage off
1186  default:
1187  throw RUNTIME_EXCEPTION("CStringPolyRef::GetMaxLength(): uninitialized pointer");
1188 #pragma BullseyeCoverage on
1189  }
1190  }
1191 
1192 
1194  bool IsValueCacheValid() const
1195  {
1196  switch(m_Type)
1197  {
1198  case typeIString:
1199  return m_Value.pString->IsValueCacheValid();
1200  case typeValue:
1201  return true;
1202  case typeUninitialized:
1203 # pragma BullseyeCoverage off
1204  default:
1205  throw RUNTIME_EXCEPTION("CStringPolyRef::IsValueCacheValid(): uninitialized pointer");
1206  }
1207 # pragma BullseyeCoverage on
1208  }
1209 
1210 
1211  protected:
1213  typedef enum _EType
1214  {
1217  typeIString
1218  } EType;
1219 
1221  EType m_Type;
1222 
1224  struct
1225  {
1228  } m_Value;
1229  };
1230 
1232  {
1233  public:
1235  {
1236  };
1237  CIntegerOffsetPolyRef( INode *_pIndex, int64_t _Offset )
1238  {
1239  pIndex = _pIndex;
1240  Offset = _Offset;
1241  };
1242 
1243  CIntegerOffsetPolyRef( INode *_pIndex, INode *_pOffset )
1244  {
1245  pIndex = _pIndex;
1246  Offset = _pOffset;
1247  };
1248 
1250  {
1251  pIndex = Copy.pIndex;
1252  Offset = Copy.Offset;
1253  };
1254 
1257  };
1258 
1259 
1260 }
1261 
1262 #endif // ifndef GENAPI_POLYREFERENCE_H
Definition of interface IBase.
EType m_Type
the type of the internally held pointer
ECachingMode GetCachingMode() const
double GetValue(bool Verify=false, bool IgnoreCache=false) const
see IFloat interface
bool IsPointer() const
True if the object references a pointer.
virtual double GetInc()
Get the constant increment if there is any.
CIntegerOffsetPolyRef(const CIntegerOffsetPolyRef &Copy)
IString * pString
fixed value
interface GENAPI_DECL_ABSTRACT IBoolean
Interface for Boolean properties.
Definition: IBoolean.h:61
int64_t GetMax() const
see IInteger interface
IBoolean * pBoolean
Enumeration node
bool IsPointer() const
True if the object references a pointer.
void operator=(const GENICAM_NAMESPACE::gcstring &Value)
set string value
double GetMax() const
see IFloat interface
interface GENAPI_DECL_ABSTRACT INodePrivate
Interface including the methods for node construction common to all nodes.
Definition: INodePrivate.h:69
EType m_Type
the type of the internally held pointer
bool IsInitialized() const
True if the object is initilaized.
double GetInc() const
extension required for swiss knifes
Definition of IBoolean interface.
A reference to a bool which can bei either an bool variable, or a pointer to an IInteger, an IEnumeration, or an IBoolean.
_EType
possible types of the internally held pointer
int64_t round(double x)
Definition: PolyReference.h:51
EType m_Type
the type of the internally held pointer
ERepresentation GetRepresentation() const
see IInteger interface
enum GENAPI_NAMESPACE::CIntegerPolyRef::_EType EType
possible types of the internally held pointer
void operator=(IBase *pValue)
set pointer
Decimal number in an edit control.
Definition: Types.h:94
bool IsValueCacheValid() const
see IValue interface
INodePrivate * GetPointer() const
returns the pointer referenced
GENICAM_NAMESPACE::gcstring GetUnit() const
see IFloat interface
ECachingMode GetCachingMode() const
bool IsPointer() const
True if the object references a pointer.
CIntegerOffsetPolyRef(INode *_pIndex, int64_t _Offset)
__int64 int64_t
Definition: config-win32.h:21
bool IsInitialized() const
True if the object is initialized.
CIntegerOffsetPolyRef(INode *_pIndex, INode *_pOffset)
#define GC_INT64_MIN
Definition: GCTypes.h:162
interface GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
Definition: IEnumeration.h:60
interface GENAPI_DECL_ABSTRACT IInteger
Interface for integer properties.
Definition: IInteger.h:61
interface GENAPI_DECL_ABSTRACT IFloat
Interface for float properties.
Definition: IFloat.h:60
Common GenICam base include file.
void operator=(INode *pValue)
set pointer
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition: GCException.h:246
IInteger * pInteger
fixed value
Definition of the IFloat interface.
union GENAPI_NAMESPACE::CIntegerPolyRef::@2 m_Value
the place to store the value or the pointers to the nodes to get the value from
_EType
possible types of the internally held pointer
bool GetValue(bool Verify=false, bool IgnoreCache=false) const
see IBoolean interface
interface GENAPI_DECL_ABSTRACT IBase
Base interface common to all nodes.
Definition: IBase.h:55
void SetValue(int64_t Value, bool Verify=true)
see IInteger interface
bool IsAvailable(EAccessMode AccessMode)
Tests if available.
Definition: INode.h:232
Write to cache and register.
Definition: Types.h:82
bool IsInitialized() const
True if the object is initialized.
EType m_Type
the type of the internally held pointer
IBoolean * pBoolean
Enumeration node
GENICAM_NAMESPACE::gcstring GetUnit() const
see IInteger interface
INodePrivate * GetPointer() const
returns the pointer referenced
enum GENAPI_NAMESPACE::_ERepresentation ERepresentation
recommended representation of a node value
node_vector NodeList_t
a list of node references
Definition: INode.h:55
enum GENAPI_NAMESPACE::_ECachingMode ECachingMode
caching mode of a register
int64_t GetMin() const
see IInteger interface
enum GENAPI_NAMESPACE::_EDisplayNotation EDisplayNotation
typedef for float notation
_EType
possible types of the internally held pointer
void SetValue(double Value, bool Verify=true)
see IFloat interface
Encapsulates a GenApi pointer dealing with the dynamic_cast automatically.
Definition: Pointer.h:51
#define ACCESS_EXCEPTION
Fires a access exception, e.g. throw ACCESS_EXCEPTION("Not everybody")
Definition: GCException.h:252
double abs(double x)
Definition: PolyReference.h:61
GENICAM_NAMESPACE::gcstring GetName() const
double GetMin() const
see IFloat interface
int64_t GetDisplayPrecision() const
see IFloat
IInteger * pInteger
Float node
interface GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
ECachingMode GetCachingMode() const
#define GC_INT64_MAX
Definition: GCTypes.h:154
int64_t GetMaxLength()
see IString interface
void operator=(IBase *pValue)
set pointer
EDisplayNotation GetDisplayNotation() const
see IFloat
IEnumeration * pEnumeration
Integer node
int64_t GetValue(bool Verify=false, bool IgnoreCache=false) const
see IInteger interface
Definition of the interface IInteger.
bool IsValueCacheValid() const
see IValue interface
GENICAM_NAMESPACE::gcstring Value
IEnumeration * pEnumeration
Integer node
_EType
possible types of the internally held pointer
int64_t GetInc() const
see IInteger interface
void operator=(double Value)
set integer value
bool IsValue() const
True if the object references a pointer.
Definition of template CPointer.
A reference to a float which can be either a double variable, or a pointer to an IFloat, IInteger, or an IEnumeration interface.
A string class which is a clone of std::string.
Definition: GCString.h:52
IFloat * pFloat
Boolean node
bool IsValid() const
true if the pointer is valid
Definition: Pointer.h:110
void operator=(IBase *pValue)
set pointer
Definition: PolyReference.h:92
the notation if either scientific or fixed depending on what is shorter
Definition: Types.h:181
void operator=(INode *pValue)
set pointer
Definition: PolyReference.h:86
bool IsInitialized() const
True if the object is initilaized.
ERepresentation GetRepresentation() const
see IFloat interface
interface GENAPI_DECL_ABSTRACT IString
Interface for string properties.
Definition: IString.h:61
Definition of interface IString.
A reference to an int64 which can bei either an int64 variable, or a pointer to an IInteger...
Definition: PolyReference.h:68
void SetValue(const GENICAM_NAMESPACE::gcstring &Value, bool Verify=true)
see IString interface
Definition of interface IEnumeration.
bool HasInc()
True if the float has a constant increment.
bool IsValue() const
True if the object references a pointer.
void SetValue(bool Value, bool Verify=true)
see IBoolean interface
void operator=(bool Value)
set integer value
interface GENAPI_DECL_ABSTRACT INode
Interface common to all nodes.
Definition: INode.h:60
#define OUT_OF_RANGE_EXCEPTION
Fires an out of range exception, e.g. throw OUT_OF_RANGE_EXCEPTION("%ld too large", Value);.
Definition: GCException.h:240
GENICAM_NAMESPACE::gcstring GetName() const
INodePrivate * GetPointer() const
returns the pointer referenced
Definition of the interface IValue.
bool IsPointer() const
True if the object references a pointer.
void operator=(int64_t Value)
set integer value
Definition: PolyReference.h:79
IInteger * pInteger
fixed value
INodePrivate * GetPointer() const
returns the pointer referenced
Part of the generic device API.
Definition: Autovector.h:48
void operator=(IBase *pValue)
set pointer
Definition of interface INodePrivate.
A reference to a gcstring which can be either a gcstring variable, or a pointer to an IString...
bool IsValue() const
True if the object references a pointer.
IEnumeration * pEnumeration
Integer node
GENICAM_NAMESPACE::gcstring GetValue(bool Verify=false, bool IgnoreCache=false) const
see IString interface


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 19:10:54