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);
89 operator=( dynamic_cast<IBase*>(pValue) );
115 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::operator(IBase*) : pointer is neither IInteger*, nor IEnumeration*, nor IBoolean*, nor IFloat*");
155 # pragma BullseyeCoverage off 159 # pragma BullseyeCoverage on 181 return round(ptrEnumEntry->GetNumericValue());
184 return m_Value.pBoolean->GetValue(
Verify, IgnoreCache) ? 1 : 0;
187 double Result =
m_Value.pFloat->GetValue(
Verify, IgnoreCache);
189 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetValue(): Float value %f out of integer range", Result);
190 return round(Result);
193 #pragma BullseyeCoverage off 196 #pragma BullseyeCoverage on 214 double OldDistance = -1;
216 m_Value.pEnumeration->GetEntries(EnumEntries);
217 for( NodeList_t::iterator it=EnumEntries.begin(); it!=EnumEntries.end(); ++it )
221 if( !ptrOldEnumEntry.
IsValid() )
223 ptrOldEnumEntry = *it;
224 OldDistance =
abs( (
double)Value - ptrOldEnumEntry->GetNumericValue() );
229 double NewDistance =
abs( (
double)Value - ptrNewEnumEntry->GetNumericValue() ) ;
230 if(NewDistance < OldDistance)
232 ptrOldEnumEntry = *it;
233 OldDistance = NewDistance;
238 if( ptrOldEnumEntry.
IsValid() )
239 m_Value.pEnumeration->SetIntValue(ptrOldEnumEntry->GetValue(),
Verify);
241 throw ACCESS_EXCEPTION(
"Failed to write enumeration. None of the entries is writable");
251 #pragma BullseyeCoverage off 254 #pragma BullseyeCoverage on 264 return m_Value.pInteger->GetMin();
271 double Min =
m_Value.pFloat->GetMin();
273 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetMin(): Float value %f out of integer range", Min);
277 #pragma BullseyeCoverage off 280 #pragma BullseyeCoverage on 290 return m_Value.pInteger->GetMax();
297 double Max =
m_Value.pFloat->GetMax();
299 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetMin(): Float value %f out of integer range", Max);
303 #pragma BullseyeCoverage off 306 #pragma BullseyeCoverage on 316 return m_Value.pInteger->GetInc();
327 #pragma BullseyeCoverage off 330 #pragma BullseyeCoverage on 340 return m_Value.pInteger->GetRepresentation();
347 #pragma BullseyeCoverage off 349 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetRepresentation(): uninitialized pointer");
350 #pragma BullseyeCoverage on 360 return m_Value.pInteger->GetUnit();
362 return m_Value.pFloat->GetUnit();
368 #pragma BullseyeCoverage off 372 #pragma BullseyeCoverage on 381 return m_Value.pInteger->IsValueCacheValid();
383 return m_Value.pEnumeration->IsValueCacheValid();
385 return m_Value.pBoolean->IsValueCacheValid();
387 return m_Value.pFloat->IsValueCacheValid();
391 # pragma BullseyeCoverage off 393 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::IsValueCacheValid(): uninitialized pointer");
395 # pragma BullseyeCoverage on 403 return m_Value.pInteger->GetNode()->GetCachingMode();
405 return m_Value.pEnumeration->GetNode()->GetCachingMode();
407 return m_Value.pBoolean->GetNode()->GetCachingMode();
409 return m_Value.pFloat->GetNode()->GetCachingMode();
413 #pragma BullseyeCoverage off 415 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::GetCachingMode(): uninitialized pointer");
416 #pragma BullseyeCoverage on 459 #pragma BullseyeCoverage off 464 return ptrNode->GetName();
468 #pragma BullseyeCoverage on 495 throw RUNTIME_EXCEPTION(
"CIntegerPolyRef::operator(IBase*) : pointer is neither IInteger*, IEnumeration*, nor IBoolean*");
526 #pragma BullseyeCoverage off 531 #pragma BullseyeCoverage on 551 return m_Value.pEnumeration->GetIntValue(
Verify, IgnoreCache) != 0;
555 #pragma BullseyeCoverage off 558 #pragma BullseyeCoverage on 580 #pragma BullseyeCoverage off 583 #pragma BullseyeCoverage on 592 return m_Value.pInteger->GetNode()->GetCachingMode();
594 return m_Value.pEnumeration->GetNode()->GetCachingMode();
596 return m_Value.pBoolean->GetNode()->GetCachingMode();
600 #pragma BullseyeCoverage off 602 throw RUNTIME_EXCEPTION(
"CBooleanPolyRef::GetCachingMode(): uninitialized pointer");
603 #pragma BullseyeCoverage on 675 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::operator(IBase*) : pointer is neither IFloat*, IInteger*, nor IEnumeration*");
712 #pragma BullseyeCoverage off 717 #pragma BullseyeCoverage on 737 return (
double)
m_Value.pInteger->GetValue(
Verify, IgnoreCache);
741 return ptrEnumEntry->GetNumericValue();
744 #pragma BullseyeCoverage off 747 #pragma BullseyeCoverage on 769 TargetValue -= Residuum;
770 if( 2 * Residuum >
m_Value.pInteger->GetInc())
771 TargetValue +=
m_Value.pInteger->GetInc();
778 double OldDistance = -1;
780 m_Value.pEnumeration->GetEntries(EnumEntries);
781 for( NodeList_t::iterator it=EnumEntries.begin(); it!=EnumEntries.end(); ++it )
785 if (!ptrOldEnumEntry.
IsValid())
787 ptrOldEnumEntry = *it;
788 OldDistance =
abs( Value - ptrOldEnumEntry->GetNumericValue() );
793 double NewDistance =
abs( Value - ptrNewEnumEntry->GetNumericValue() ) ;
794 if (NewDistance < OldDistance)
796 ptrOldEnumEntry = *it;
797 OldDistance = NewDistance;
803 m_Value.pEnumeration->SetIntValue(ptrOldEnumEntry->GetValue(),
Verify);
805 throw ACCESS_EXCEPTION(
"Failed to write enumeration. None of the entries is writable");
809 #pragma BullseyeCoverage off 812 #pragma BullseyeCoverage on 822 return m_Value.pFloat->GetMin();
824 return (
double)
m_Value.pInteger->GetMin();
827 return -std::numeric_limits<double>::max();
829 #pragma BullseyeCoverage off 832 #pragma BullseyeCoverage on 842 return m_Value.pFloat->GetMax();
844 return (
double)
m_Value.pInteger->GetMax();
847 return std::numeric_limits<double>::max();
849 #pragma BullseyeCoverage off 852 #pragma BullseyeCoverage on 862 return m_Value.pFloat->HasInc();
868 #pragma BullseyeCoverage off 871 #pragma BullseyeCoverage on 881 return m_Value.pFloat->GetInc();
883 return (
double)
m_Value.pInteger->GetInc();
887 #pragma BullseyeCoverage off 890 #pragma BullseyeCoverage on 895 #pragma BullseyeCoverage off 901 return (
double)
m_Value.pInteger->GetInc();
907 #pragma BullseyeCoverage off 910 #pragma BullseyeCoverage on 913 #pragma BullseyeCoverage on 921 return m_Value.pFloat->GetRepresentation();
923 return m_Value.pInteger->GetRepresentation();
928 #pragma BullseyeCoverage off 930 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetRepresentation(): uninitialized pointer");
931 #pragma BullseyeCoverage on 941 return m_Value.pFloat->GetUnit();
943 return m_Value.pInteger->GetUnit();
948 #pragma BullseyeCoverage off 951 #pragma BullseyeCoverage on 963 return m_Value.pFloat->IsValueCacheValid();
965 return m_Value.pInteger->IsValueCacheValid();
967 return m_Value.pEnumeration->IsValueCacheValid();
971 #pragma BullseyeCoverage off 973 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::IsValueCacheValid(): uninitialized pointer");
974 #pragma BullseyeCoverage on 985 return m_Value.pFloat->GetDisplayNotation();
991 #pragma BullseyeCoverage off 993 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetDisplayNotation(): uninitialized pointer");
994 #pragma BullseyeCoverage on 1004 return m_Value.pFloat->GetDisplayPrecision();
1010 #pragma BullseyeCoverage off 1012 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetDisplayPrecision(): uninitialized pointer");
1013 #pragma BullseyeCoverage on 1032 return m_Value.pInteger->GetNode()->GetCachingMode();
1034 return m_Value.pEnumeration->GetNode()->GetCachingMode();
1036 return m_Value.pFloat->GetNode()->GetCachingMode();
1040 #pragma BullseyeCoverage off 1042 throw RUNTIME_EXCEPTION(
"CFloatPolyRef::GetCachingMode(): uninitialized pointer");
1043 #pragma BullseyeCoverage on 1074 #pragma BullseyeCoverage off 1079 return ptrNode->GetName();
1083 #pragma BullseyeCoverage on 1098 throw RUNTIME_EXCEPTION(
"CStringPolyRef::operator(IBase*) : pointer is not IString*");
1131 # pragma BullseyeCoverage off 1136 # pragma BullseyeCoverage on 1156 #pragma BullseyeCoverage off 1159 #pragma BullseyeCoverage on 1175 #pragma BullseyeCoverage off 1178 #pragma BullseyeCoverage on 1188 return m_Value.Value.max_size();
1194 #pragma BullseyeCoverage off 1196 throw RUNTIME_EXCEPTION(
"CStringPolyRef::GetMaxLength(): uninitialized pointer");
1197 #pragma BullseyeCoverage on 1208 return m_Value.pString->IsValueCacheValid();
1212 # pragma BullseyeCoverage off 1214 throw RUNTIME_EXCEPTION(
"CStringPolyRef::IsValueCacheValid(): uninitialized pointer");
1216 # pragma BullseyeCoverage on 1271 #endif // ifndef GENAPI_POLYREFERENCE_H Definition of interface IBase.
bool IsInitialized() const
True if the object is initilaized.
EType m_Type
the type of the internally held pointer
virtual double GetInc()
Get the constant increment if there is any.
bool IsInitialized() const
True if the object is initialized.
CIntegerOffsetPolyRef(const CIntegerOffsetPolyRef &Copy)
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IBase
Base interface common to all nodes.
IString * pString
fixed value
double GetInc() const
extension required for swiss knifes
EDisplayNotation GetDisplayNotation() const
see IFloat
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IBoolean
Interface for Boolean properties.
IBoolean * pBoolean
Enumeration node
CFloatPolyRef & operator=(INode *pValue)
set pointer
INodePrivate * GetPointer() const
returns the pointer referenced
EType m_Type
the type of the internally held pointer
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_NAMESPACE::gcstring GetUnit() const
see IInteger interface
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
EType m_Type
the type of the internally held pointer
GENICAM_INTERFACE INodePrivate
Interface including the methods for node construction common to all nodes.
GENICAM_NAMESPACE::gcstring GetValue(bool Verify=false, bool IgnoreCache=false) const
see IString interface
enum GENAPI_NAMESPACE::CIntegerPolyRef::_EType EType
possible types of the internally held pointer
Decimal number in an edit control.
CIntegerPolyRef & operator=(int64_t Value)
set integer value
bool IsPointer() const
True if the object references a pointer.
bool IsInitialized() const
True if the object is initilaized.
CIntegerOffsetPolyRef(INode *_pIndex, int64_t _Offset)
CFloatPolyRef & operator=(IBase *pValue)
set pointer
ECachingMode GetCachingMode() const
CIntegerOffsetPolyRef(INode *_pIndex, INode *_pOffset)
int64_t GetMax() const
see IInteger interface
CBooleanPolyRef()
Constructor.
CBooleanPolyRef & operator=(bool Value)
set integer value
bool IsValid() const
true if the pointer is valid
Common GenICam base include file.
int64_t GetMaxLength(bool Verify=false)
see IString interface
#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 IsPointer() const
True if the object references a pointer.
void SetValue(int64_t Value, bool Verify=true)
see IInteger interface
bool IsAvailable(EAccessMode AccessMode)
Tests if available.
Write to cache and register.
bool GetValue(bool Verify=false, bool IgnoreCache=false) const
see IBoolean interface
EType m_Type
the type of the internally held pointer
IBoolean * pBoolean
Enumeration node
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
enum GENAPI_NAMESPACE::_EDisplayNotation EDisplayNotation
typedef for float notation
_EType
possible types of the internally held pointer
INodePrivate * GetPointer() const
returns the pointer referenced
void SetValue(double Value, bool Verify=true)
see IFloat interface
Encapsulates a GenApi pointer dealing with the dynamic_cast automatically.
GENICAM_NAMESPACE::gcstring GetName() const
#define ACCESS_EXCEPTION
Fires a access exception, e.g. throw ACCESS_EXCEPTION("Not everybody")
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
int64_t GetInc() const
see IInteger interface
double GetMin() const
see IFloat interface
CStringPolyRef & operator=(IBase *pValue)
set pointer
CStringPolyRef & operator=(const GENICAM_NAMESPACE::gcstring &Value)
set string value
IInteger * pInteger
Float node
int64_t GetDisplayPrecision() const
see IFloat
CIntegerPolyRef & operator=(IBase *pValue)
set pointer
CBooleanPolyRef & operator=(IBase *pValue)
set pointer
bool IsValueCacheValid() const
see IValue interface
ERepresentation GetRepresentation() const
see IFloat interface
IEnumeration * pEnumeration
Integer node
Definition of the interface IInteger.
CFloatPolyRef()
Constructor.
GENICAM_NAMESPACE::gcstring Value
IEnumeration * pEnumeration
Integer node
_EType
possible types of the internally held 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.
ECachingMode GetCachingMode() const
IFloat * pFloat
Boolean node
double GetValue(bool Verify=false, bool IgnoreCache=false) const
see IFloat interface
the notation if either scientific or fixed depending on what is shorter
CIntegerPolyRef()
Constructor.
GENICAM_NAMESPACE::gcstring GetName() const
bool IsPointer() const
True if the object references a pointer.
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IString
Interface for string properties.
CIntegerPolyRef & operator=(INode *pValue)
set pointer
INodePrivate * GetPointer() const
returns the pointer referenced
Definition of interface IString.
int64_t GetValue(bool Verify=false, bool IgnoreCache=false) const
see IInteger interface
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
int64_t GetMin() const
see IInteger 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
ECachingMode GetCachingMode() const
CFloatPolyRef & operator=(double Value)
set integer value
double GetMax() const
see IFloat interface
#define OUT_OF_RANGE_EXCEPTION
Fires an out of range exception, e.g. throw OUT_OF_RANGE_EXCEPTION("%ld too large", Value);.
bool IsValueCacheValid() const
see IValue interface
Definition of the interface IValue.
bool IsValue() const
True if the object references a pointer.
ERepresentation GetRepresentation() const
see IInteger interface
bool IsValue() const
True if the object references a pointer.
bool IsPointer() const
True if the object references a pointer.
IInteger * pInteger
fixed value
Lexical analyzer for CIntSwissKnife.
Definition of interface INodePrivate.
IFloat * pFloat
fixed value
CStringPolyRef()
Constructor.
INodePrivate * GetPointer() const
returns the pointer referenced
bool IsInitialized() const
True if the object is initialized.
A reference to a gcstring which can be either a gcstring variable, or a pointer to an IString...
IEnumeration * pEnumeration
Integer node
GENICAM_NAMESPACE::gcstring GetUnit() const
see IFloat interface