E57 Foundation API v1.1.312
Aug. 10, 2011
|
An E57 element encoding a fixed point number. More...
Public Member Functions | |
ScaledIntegerNode (ImageFile destImageFile, int64_t value, int64_t minimum, int64_t maximum, double scale=1.0, double offset=0.0) | |
Create an E57 element for storing a fixed point number. | |
ScaledIntegerNode (ImageFile destImageFile, int value, int64_t minimum, int64_t maximum, double scale=1.0, double offset=0.0) | |
ScaledIntegerNode (ImageFile destImageFile, int value, int minimum, int maximum, double scale=1.0, double offset=0.0) | |
ScaledIntegerNode (ImageFile destImageFile, double scaledValue, double scaledMinimum, double scaledMaximum, double scale=1.0, double offset=0.0) | |
This second constructor create an E57 element for storing a fixed point number but does the scaling for you. | |
int64_t | rawValue () const |
Get raw unscaled integer value of element. | |
double | scaledValue () const |
Get scaled value of element. | |
int64_t | minimum () const |
Get the declared minimum that the raw value may take. | |
double | scaledMinimum () const |
Get the declared scaled minimum that the scaled value may take. | |
int64_t | maximum () const |
Get the declared maximum that the raw value may take. | |
double | scaledMaximum () const |
Get the declared scaled maximum that the scaled value may take. | |
double | scale () const |
Get declared scaling factor. | |
double | offset () const |
Get declared offset. | |
operator Node () const | |
Upcast a ScaledIntegerNode handle to a generic Node handle. | |
ScaledIntegerNode (const Node &n) | |
Downcast a generic Node handle to an ScaledIntegerNode handle. | |
bool | isRoot () const |
Is this a root node. | |
Node | parent () const |
Return parent of node, or self if a root node. | |
ustring | pathName () const |
Get absolute pathname of node. | |
ustring | elementName () const |
Get elementName string, that identifies the node in its parent.. | |
ImageFile | destImageFile () const |
Get the ImageFile that was declared as the destination for the node when it was created. | |
bool | isAttached () const |
Has node been attached into the tree of an ImageFile. | |
void | dump (int indent=0, std::ostream &os=std::cout) const |
Diagnostic function to print internal state of object to output stream in an indented format. | |
void | checkInvariant (bool doRecurse=true, bool doUpcast=true) |
Check whether ScaledIntegerNode class invariant is true. |
An E57 element encoding a fixed point number.
An ScaledIntegerNode is a terminal node (i.e. having no children) that holds a fixed point number encoded by an integer rawValue
, a double precision floating point scale
, an double precision floating point offset
, and integer minimum/maximum bounds.
The minimum
attribute may be a number in the interval [-2^63, 2^63). The maximum
attribute may be a number in the interval [minimum, 2^63). The rawValue
may be a number in the interval [minimum, maximum]. The scaledValue
is a calculated double precision floating point number derived from: scaledValue = rawValue*scale + offset.
See Node class discussion for discussion of the common functions that StructureNode supports.
A class invariant is a list of statements about an object that are always true before and after any operation on the object. An invariant is useful for testing correct operation of an implementation. Statements in an invariant can involve only externally visible state, or can refer to internal implementation-specific state that is not visible to the API user. The following C++ code checks externally visible state for consistancy and throws an exception if the invariant is violated:
void ScaledIntegerNode::checkInvariant(bool /*doRecurse*/, bool doUpcast) { // If destImageFile not open, can't test invariant (almost every call would throw) if (!destImageFile().isOpen()) return; // If requested, call Node::checkInvariant if (doUpcast) static_cast<Node>(*this).checkInvariant(false, false); // If value is out of bounds if (rawValue() < minimum() || rawValue() > maximum()) throw E57_EXCEPTION1(E57_ERROR_INVARIANCE_VIOLATION); // If scale is zero if (scale() == 0) throw E57_EXCEPTION1(E57_ERROR_INVARIANCE_VIOLATION); // If scaled value is not calculated correctly if (scaledValue() != rawValue() * scale() + offset()) throw E57_EXCEPTION1(E57_ERROR_INVARIANCE_VIOLATION); } // end ScaledIntegerNode::checkInvariant