31 #ifndef GENAPI_POLYREFERENCE_H 32 #define GENAPI_POLYREFERENCE_H 53 return (
int64_t)(x > 0.0 ? x + 0.5 : x - 0.5);
61 inline double abs(
double x)
63 return (x >= 0.0 ? x : -x);
88 operator=( dynamic_cast<IBase*>(pValue) );
113 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::operator(IBase*) : pointer is neither IInteger*, nor IEnumeration*, nor IBoolean*, nor IFloat*");
152 # pragma BullseyeCoverage off 156 # pragma BullseyeCoverage on 178 return round(ptrEnumEntry->GetNumericValue());
181 return m_Value.pBoolean->GetValue(
Verify, IgnoreCache) ? 1 : 0;
184 double Result =
m_Value.pFloat->GetValue(
Verify, IgnoreCache);
186 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetValue(): Float value %f out of integer range", Result);
187 return round(Result);
190 #pragma BullseyeCoverage off 193 #pragma BullseyeCoverage on 211 double OldDistance = -1;
213 m_Value.pEnumeration->GetEntries(EnumEntries);
214 for( NodeList_t::iterator it=EnumEntries.begin(); it!=EnumEntries.end(); ++it )
218 if( !ptrOldEnumEntry.
IsValid() )
220 ptrOldEnumEntry = *it;
221 OldDistance =
abs( (
double)Value - ptrOldEnumEntry->GetNumericValue() );
226 double NewDistance =
abs( (
double)Value - ptrNewEnumEntry->GetNumericValue() ) ;
227 if(NewDistance < OldDistance)
229 ptrOldEnumEntry = *it;
230 OldDistance = NewDistance;
235 if( ptrOldEnumEntry.
IsValid() )
236 m_Value.pEnumeration->SetIntValue(ptrOldEnumEntry->GetValue(),
Verify);
238 throw ACCESS_EXCEPTION(
"Failed to write enumeration. None of the entries is writable");
248 #pragma BullseyeCoverage off 251 #pragma BullseyeCoverage on 261 return m_Value.pInteger->GetMin();
268 double Min =
m_Value.pFloat->GetMin();
270 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetMin(): Float value %f out of integer range", Min);
274 #pragma BullseyeCoverage off 277 #pragma BullseyeCoverage on 287 return m_Value.pInteger->GetMax();
294 double Max =
m_Value.pFloat->GetMax();
296 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetMin(): Float value %f out of integer range", Max);
300 #pragma BullseyeCoverage off 303 #pragma BullseyeCoverage on 313 return m_Value.pInteger->GetInc();
324 #pragma BullseyeCoverage off 327 #pragma BullseyeCoverage on 337 return m_Value.pInteger->GetRepresentation();
344 #pragma BullseyeCoverage off 346 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetRepresentation(): uninitialized pointer");
347 #pragma BullseyeCoverage on 357 return m_Value.pInteger->GetUnit();
359 return m_Value.pFloat->GetUnit();
365 #pragma BullseyeCoverage off 369 #pragma BullseyeCoverage on 378 return m_Value.pInteger->IsValueCacheValid();
380 return m_Value.pEnumeration->IsValueCacheValid();
382 return m_Value.pBoolean->IsValueCacheValid();
384 return m_Value.pFloat->IsValueCacheValid();
388 # pragma BullseyeCoverage off 390 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::IsValueCacheValid(): uninitialized pointer");
392 # pragma BullseyeCoverage on 400 return m_Value.pInteger->GetNode()->GetCachingMode();
402 return m_Value.pEnumeration->GetNode()->GetCachingMode();
404 return m_Value.pBoolean->GetNode()->GetCachingMode();
406 return m_Value.pFloat->GetNode()->GetCachingMode();
410 #pragma BullseyeCoverage off 412 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetCachingMode(): uninitialized pointer");
413 #pragma BullseyeCoverage on 456 #pragma BullseyeCoverage off 461 return ptrNode->GetName();
465 #pragma BullseyeCoverage on 491 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::operator(IBase*) : pointer is neither IInteger*, IEnumeration*, nor IBoolean*");
521 #pragma BullseyeCoverage off 526 #pragma BullseyeCoverage on 546 return m_Value.pEnumeration->GetIntValue(
Verify, IgnoreCache) != 0;
550 #pragma BullseyeCoverage off 553 #pragma BullseyeCoverage on 575 #pragma BullseyeCoverage off 578 #pragma BullseyeCoverage on 587 return m_Value.pInteger->GetNode()->GetCachingMode();
589 return m_Value.pEnumeration->GetNode()->GetCachingMode();
591 return m_Value.pBoolean->GetNode()->GetCachingMode();
595 #pragma BullseyeCoverage off 597 throw RUNTIME_EXCEPTION(
"CBooleanPolyRef::GetCachingMode(): uninitialized pointer");
598 #pragma BullseyeCoverage on 648 operator=( dynamic_cast<IBase*>(pValue) );
668 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::operator(IBase*) : pointer is neither IFloat*, IInteger*, nor IEnumeration*");
704 #pragma BullseyeCoverage off 709 #pragma BullseyeCoverage on 729 return (
double)
m_Value.pInteger->GetValue(
Verify, IgnoreCache);
733 return ptrEnumEntry->GetNumericValue();
736 #pragma BullseyeCoverage off 739 #pragma BullseyeCoverage on 761 TargetValue -= Residuum;
762 if( 2 * Residuum >
m_Value.pInteger->GetInc())
763 TargetValue +=
m_Value.pInteger->GetInc();
770 double OldDistance = -1;
772 m_Value.pEnumeration->GetEntries(EnumEntries);
773 for( NodeList_t::iterator it=EnumEntries.begin(); it!=EnumEntries.end(); ++it )
777 if( !ptrOldEnumEntry.
IsValid() )
779 ptrOldEnumEntry = *it;
780 OldDistance =
abs( Value - ptrOldEnumEntry->GetNumericValue() );
785 double NewDistance =
abs( Value - ptrNewEnumEntry->GetNumericValue() ) ;
786 if(NewDistance < OldDistance)
788 ptrOldEnumEntry = *it;
789 OldDistance = NewDistance;
794 if( ptrOldEnumEntry.
IsValid() )
795 m_Value.pEnumeration->SetIntValue(ptrOldEnumEntry->GetValue(),
Verify);
797 throw ACCESS_EXCEPTION(
"Failed to write enumeration. None of the entries is writable");
801 #pragma BullseyeCoverage off 804 #pragma BullseyeCoverage on 814 return m_Value.pFloat->GetMin();
816 return (
double)
m_Value.pInteger->GetMin();
819 return -std::numeric_limits<double>::max();
821 #pragma BullseyeCoverage off 824 #pragma BullseyeCoverage on 834 return m_Value.pFloat->GetMax();
836 return (
double)
m_Value.pInteger->GetMax();
839 return std::numeric_limits<double>::max();
841 #pragma BullseyeCoverage off 844 #pragma BullseyeCoverage on 854 return m_Value.pFloat->HasInc();
860 #pragma BullseyeCoverage off 863 #pragma BullseyeCoverage on 873 return m_Value.pFloat->GetInc();
875 return (
double)
m_Value.pInteger->GetInc();
879 #pragma BullseyeCoverage off 882 #pragma BullseyeCoverage on 887 #pragma BullseyeCoverage off 893 return (
double)
m_Value.pInteger->GetInc();
899 #pragma BullseyeCoverage off 902 #pragma BullseyeCoverage on 905 #pragma BullseyeCoverage on 913 return m_Value.pFloat->GetRepresentation();
915 return m_Value.pInteger->GetRepresentation();
920 #pragma BullseyeCoverage off 922 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetRepresentation(): uninitialized pointer");
923 #pragma BullseyeCoverage on 933 return m_Value.pFloat->GetUnit();
935 return m_Value.pInteger->GetUnit();
940 #pragma BullseyeCoverage off 943 #pragma BullseyeCoverage on 955 return m_Value.pFloat->IsValueCacheValid();
957 return m_Value.pInteger->IsValueCacheValid();
959 return m_Value.pEnumeration->IsValueCacheValid();
963 #pragma BullseyeCoverage off 965 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::IsValueCacheValid(): uninitialized pointer");
966 #pragma BullseyeCoverage on 977 return m_Value.pFloat->GetDisplayNotation();
983 #pragma BullseyeCoverage off 985 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetDisplayNotation(): uninitialized pointer");
986 #pragma BullseyeCoverage on 996 return m_Value.pFloat->GetDisplayPrecision();
1002 #pragma BullseyeCoverage off 1004 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetDisplayPrecision(): uninitialized pointer");
1005 #pragma BullseyeCoverage on 1024 return m_Value.pInteger->GetNode()->GetCachingMode();
1026 return m_Value.pEnumeration->GetNode()->GetCachingMode();
1028 return m_Value.pFloat->GetNode()->GetCachingMode();
1032 #pragma BullseyeCoverage off 1034 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetCachingMode(): uninitialized pointer");
1035 #pragma BullseyeCoverage on 1066 #pragma BullseyeCoverage off 1071 return ptrNode->GetName();
1075 #pragma BullseyeCoverage on 1091 throw RUNTIME_EXCEPTION(
"CStringPolyRef::operator(IBase*) : pointer is not IString*");
1122 # pragma BullseyeCoverage off 1127 # pragma BullseyeCoverage on 1147 #pragma BullseyeCoverage off 1150 #pragma BullseyeCoverage on 1166 #pragma BullseyeCoverage off 1169 #pragma BullseyeCoverage on 1179 return m_Value.Value.max_size();
1185 #pragma BullseyeCoverage off 1187 throw RUNTIME_EXCEPTION(
"CStringPolyRef::GetMaxLength(): uninitialized pointer");
1188 #pragma BullseyeCoverage on 1199 return m_Value.pString->IsValueCacheValid();
1203 # pragma BullseyeCoverage off 1205 throw RUNTIME_EXCEPTION(
"CStringPolyRef::IsValueCacheValid(): uninitialized pointer");
1207 # pragma BullseyeCoverage on 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)
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IBase
Base interface common to all nodes.
IString * pString
fixed value
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IBoolean
Interface for Boolean properties.
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
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.
GENICAM_INTERFACE IInteger
Interface for integer properties.
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
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
EType m_Type
the type of the internally held pointer
ERepresentation GetRepresentation() const
see IInteger interface
GENICAM_INTERFACE INodePrivate
Interface including the methods for node construction common to all nodes.
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.
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)
bool IsInitialized() const
True if the object is initialized.
CIntegerOffsetPolyRef(INode *_pIndex, INode *_pOffset)
CBooleanPolyRef()
Constructor.
Common GenICam base include file.
int64_t GetMaxLength(bool Verify=false)
see IString interface
void operator=(INode *pValue)
set pointer
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
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
void SetValue(int64_t Value, bool Verify=true)
see IInteger interface
bool IsAvailable(EAccessMode AccessMode)
Tests if available.
Write to cache and register.
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
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.
#define ACCESS_EXCEPTION
Fires a access exception, e.g. throw ACCESS_EXCEPTION("Not everybody")
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
GENICAM_NAMESPACE::gcstring GetName() const
double GetMin() const
see IFloat interface
int64_t GetDisplayPrecision() const
see IFloat
IInteger * pInteger
Float node
ECachingMode GetCachingMode() const
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
CFloatPolyRef()
Constructor.
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.
IFloat * pFloat
Boolean node
bool IsValid() const
true if the pointer is valid
void operator=(IBase *pValue)
set pointer
the notation if either scientific or fixed depending on what is shorter
CIntegerPolyRef()
Constructor.
void operator=(INode *pValue)
set pointer
bool IsInitialized() const
True if the object is initilaized.
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IString
Interface for string properties.
ERepresentation GetRepresentation() const
see IFloat interface
Definition of interface IString.
A reference to an int64 which can bei either an int64 variable, or a pointer to an IInteger...
void SetValue(const GENICAM_NAMESPACE::gcstring &Value, bool Verify=true)
see IString interface
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IFloat
Interface for float properties.
Definition of interface IEnumeration.
bool HasInc()
True if the float has a constant increment.
GENICAM_INTERFACE INode
Interface common to all nodes.
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
#define OUT_OF_RANGE_EXCEPTION
Fires an out of range exception, e.g. throw OUT_OF_RANGE_EXCEPTION("%ld too large", Value);.
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
IInteger * pInteger
fixed value
INodePrivate * GetPointer() const
returns the pointer referenced
Lexical analyzer for CIntSwissKnife.
void operator=(IBase *pValue)
set pointer
Definition of interface INodePrivate.
IFloat * pFloat
fixed value
CStringPolyRef()
Contructor.
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