LRAUV  revA
Double Class Reference

Wraps a double precision (8-byte) floating point number and unit for storage in a DataElement. More...

#include <Double.h>

Inheritance diagram for Double:
Collaboration diagram for Double:

Classes

class  StaticDestructor
 Makes sure that mallocRing_s is deleted on shutdown. More...
 

Public Member Functions

 Double (const Unit &unit, double value, bool scaleValue=true)
 Constructor for non-array storage. More...
 
 Double (const Unit &unit, const void *binary)
 Constructor from binary. More...
 
virtual ~Double ()
 Destructor. More...
 
void * operator new (size_t size)
 Override new. More...
 
void operator delete (void *p)
 Override delete. More...
 
Doublecopy () const
 Return a pointer to a new copy. More...
 
virtual void minus (const DataValue *rhs, DataValue *assignTo) const
 Subtraction of another DataValue to yield another DataValue. More...
 
virtual void times (const double rhs, DataValue *assignTo) const
 Multiplication by a double to yield another DataValue. More...
 
virtual double absDiff (const DataValue *rhs) const
 Return the absolute value of this difference from another DataValue. More...
 
virtual bool copyTo (const Unit &unit, unsigned char &assignTo) const
 Copy value to unsigned char. More...
 
virtual bool copyTo (const Unit &unit, double &assignTo) const
 Copy value to double. More...
 
virtual bool copyTo (const Unit &unit, double &assignTo, unsigned int dim) const
 Copy n-dimensional value to double. More...
 
virtual bool copyTo (const Unit &unit, float &assignTo) const
 Copy value to float. More...
 
virtual bool copyTo (const Unit &unit, int &assignTo) const
 Copy value to unsigned int. More...
 
virtual int compare (const Unit &unit, const unsigned char &compareTo) const
 Comparison with unsigned char. More...
 
virtual int compare (const Unit &unit, const double &compareTo) const
 Comparison with double. More...
 
virtual int compare (const Unit &unit, const float &compareTo) const
 Comparison with float. More...
 
virtual int compare (const Unit &unit, const int &compareTo) const
 Comparison with int. More...
 
virtual int compare (const DataValue &compareTo) const
 Comparison with another DataValue. More...
 
virtual bool equals (const Unit &unit, const unsigned char &compareTo) const
 Equality test with with unsigned char. More...
 
virtual bool equals (const Unit &unit, const double &compareTo) const
 Equality test with double. More...
 
virtual bool equals (const Unit &unit, const float &compareTo) const
 Equality test with float. More...
 
virtual bool equals (const Unit &unit, const int &compareTo) const
 Equality test with int. More...
 
virtual bool equals (const DataValue &compareTo) const
 Equality test with another DataValue. More...
 
virtual bool equalsForStorage (const double &compareTo) const
 A quick equality check used to see if value has changed enough to matter in logging (useful for reduced resolution data storage. More...
 
virtual bool isNaN ()
 Returns true if the number is not a number. More...
 
virtual bool setFrom (const Unit &unit, unsigned char value)
 set from unsigned char value More...
 
virtual bool setFrom (const Unit &unit, double value)
 set from double value More...
 
virtual bool setFrom (const Unit &unit, float value)
 set from float value More...
 
virtual bool setFrom (const Unit &unit, int value)
 set from int value More...
 
virtual bool setFrom (const DataValue &value)
 set from DataValue value More...
 
virtual Str toString (const Unit &unit) const
 
virtual unsigned int toStream (OutStream &outStream) const
 Send the data value to the indicated stream. More...
 
virtual void fromBinary (const void *buffer)
 Load the data from the a binary representation in the buffer Typically just a memcopy of the variable, though endianness may come into it. More...
 
- Public Member Functions inherited from DataValue
virtual ~DataValue ()
 Destructor. More...
 
void operator delete (void *p)
 Override delete. More...
 
virtual bool copyTo (const Unit &unit, bool &assignTo) const
 Copy value to bool. More...
 
virtual bool copyTo (DataValue &assignTo) const
 Copy value to another dataValue. More...
 
virtual int compare (const Unit &unit, const bool &compareTo) const
 Comparison with bool. More...
 
virtual bool equals (const Unit &unit, const bool &compareTo) const
 Equality test with with bool. More...
 
virtual bool setFrom (const Unit &unit, bool value)
 set from bool value More...
 
virtual Str toString () const
 
virtual size_t getTypeSize () const
 Returns the size of the internal storage type (i.e. sizeof(type)) More...
 
virtual BinaryDataType getBinaryType (void) const
 Returns a constant (defined in BinaryDataType.h) representing the internal storage type. More...
 
const UnitgetUnit () const
 
const UnitgetBaseUnit () const
 
void setUnit (const Unit &unit)
 
void clearType ()
 

Static Public Member Functions

static unsigned int ToBinary (const double &value, unsigned char *buffer, unsigned int maxlen)
 Convert the specified value to a binary representation in the buffer Typically just a memcopy of the variable, though endianness may come into it. More...
 

Protected Member Functions

 Double ()
 Protected Empty constructor for use by DataEntry class. More...
 
- Protected Member Functions inherited from DataValue
 DataValue (const Unit &unit, const size_t &typeSize, const BinaryDataType &binaryType)
 Protected Constructor for abstract base class. More...
 
 DataValue (const size_t &typeSize, const BinaryDataType &binaryType)
 Protected unitless constructor for use via DataEntry class. More...
 

Protected Attributes

double value_
 
- Protected Attributes inherited from DataValue
const Unitunit_
 
size_t typeSize_
 size of the internal storage type (i.e. sizeof(type)) More...
 
BinaryDataType binaryType_
 constant (defined in BinaryDataType.h) representing the internal storage type More...
 

Static Protected Attributes

static RingBufferVoidMallocRing_
 Declared as a pointer to avoid including RingBuffer.h header here. More...
 
static Double::StaticDestructor StaticDestructor_
 Static instance of StaticDestructor. More...
 

Detailed Description

Wraps a double precision (8-byte) floating point number and unit for storage in a DataElement.

(Storage is in the most canonical form of the specified unit). Provides methods for reading and writing the value to and from other DataValues, performing unit conversions as needed.

Note: since these DataValues are created and destructed frequently, the new and delete operators have been overridden, so that objects can be re-used as needed.

Double::MallocRing_ stores deleted objects.

Constructor & Destructor Documentation

Double::Double ( const Unit unit,
double  value,
bool  scaleValue = true 
)

Constructor for non-array storage.

Double::Double ( const Unit unit,
const void *  binary 
)

Constructor from binary.

References fromBinary().

virtual Double::~Double ( )
inlinevirtual

Destructor.

Double::Double ( )
protected

Protected Empty constructor for use by DataEntry class.

Protected Empty constructor for use bya DataEntry class.

Referenced by copy().

Member Function Documentation

double Double::absDiff ( const DataValue rhs) const
virtual

Return the absolute value of this difference from another DataValue.

Implements DataValue.

References DataValue::copyTo(), DataValue::getBaseUnit(), NAN, and value_.

int Double::compare ( const Unit unit,
const unsigned char &  compareTo 
) const
virtual

Comparison with unsigned char.

Implements DataValue.

References Unit::getSI(), AuvMath::Sign(), and value_.

int Double::compare ( const Unit unit,
const double &  compareTo 
) const
virtual

Comparison with double.

Implements DataValue.

References Unit::getSI(), AuvMath::Sign(), and value_.

int Double::compare ( const Unit unit,
const float &  compareTo 
) const
virtual

Comparison with float.

Implements DataValue.

References Unit::getSI(), AuvMath::Sign(), and value_.

int Double::compare ( const Unit unit,
const int &  compareTo 
) const
virtual

Comparison with int.

Implements DataValue.

References Unit::getSI(), AuvMath::Sign(), and value_.

int Double::compare ( const DataValue compareTo) const
virtual

Comparison with another DataValue.

Implements DataValue.

References DataValue::compare(), DataValue::getBaseUnit(), and value_.

Double * Double::copy ( ) const
virtual

Return a pointer to a new copy.

Implements DataValue.

Reimplemented in Double6, and Double4.

References Double(), DataValue::unit_, and value_.

bool Double::copyTo ( const Unit unit,
unsigned char &  assignTo 
) const
virtual

Copy value to unsigned char.

Implements DataValue.

References Unit::getScaled(), and value_.

Referenced by copyTo().

bool Double::copyTo ( const Unit unit,
double &  assignTo 
) const
virtual

Copy value to double.

Implements DataValue.

References Unit::getScaled(), and value_.

virtual bool Double::copyTo ( const Unit unit,
double &  assignTo,
unsigned int  dim 
) const
inlinevirtual

Copy n-dimensional value to double.

References copyTo().

bool Double::copyTo ( const Unit unit,
float &  assignTo 
) const
virtual

Copy value to float.

Implements DataValue.

References Unit::getScaled(), and value_.

bool Double::copyTo ( const Unit unit,
int &  assignTo 
) const
virtual

Copy value to unsigned int.

Implements DataValue.

References Unit::getScaled(), and value_.

bool Double::equals ( const Unit unit,
const unsigned char &  compareTo 
) const
virtual

Equality test with with unsigned char.

Implements DataValue.

References Unit::getSI(), and value_.

Referenced by setFrom().

bool Double::equals ( const Unit unit,
const double &  compareTo 
) const
virtual

Equality test with double.

Implements DataValue.

References Unit::getSI(), and value_.

bool Double::equals ( const Unit unit,
const float &  compareTo 
) const
virtual

Equality test with float.

Implements DataValue.

References Unit::getSI(), and value_.

bool Double::equals ( const Unit unit,
const int &  compareTo 
) const
virtual

Equality test with int.

Implements DataValue.

References Unit::getSI(), and value_.

bool Double::equals ( const DataValue compareTo) const
virtual

Equality test with another DataValue.

Implements DataValue.

References DataValue::equals(), DataValue::getBaseUnit(), and value_.

bool Double::equalsForStorage ( const double &  compareTo) const
virtual

A quick equality check used to see if value has changed enough to matter in logging (useful for reduced resolution data storage.

Reimplemented in Double6, and Double4.

References value_.

Referenced by setFrom().

void Double::fromBinary ( const void *  buffer)
virtual

Load the data from the a binary representation in the buffer Typically just a memcopy of the variable, though endianness may come into it.

Implements DataValue.

Reimplemented in Double6, and Double4.

References value_.

Referenced by Double().

bool Double::isNaN ( )
virtual

Returns true if the number is not a number.

Reimplemented from DataValue.

References value_.

void Double::minus ( const DataValue rhs,
DataValue assignTo 
) const
virtual

Subtraction of another DataValue to yield another DataValue.

Implements DataValue.

References DataValue::copyTo(), DataValue::getBaseUnit(), DataValue::setFrom(), and value_.

void Double::operator delete ( void *  p)

Override delete.

void * Double::operator new ( size_t  size)

Override new.

bool Double::setFrom ( const Unit unit,
unsigned char  value 
)
virtual

set from unsigned char value

Implements DataValue.

References equals(), equalsForStorage(), Unit::getSI(), and value_.

bool Double::setFrom ( const Unit unit,
double  value 
)
virtual

set from double value

Implements DataValue.

References equals(), equalsForStorage(), Unit::getSI(), and value_.

bool Double::setFrom ( const Unit unit,
float  value 
)
virtual

set from float value

Implements DataValue.

References equals(), equalsForStorage(), Unit::getSI(), and value_.

bool Double::setFrom ( const Unit unit,
int  value 
)
virtual

set from int value

set int value

Implements DataValue.

References equals(), equalsForStorage(), Unit::getSI(), and value_.

bool Double::setFrom ( const DataValue value)
virtual
void Double::times ( const double  rhs,
DataValue assignTo 
) const
virtual

Multiplication by a double to yield another DataValue.

Implements DataValue.

References DataValue::getBaseUnit(), DataValue::setFrom(), and value_.

unsigned int Double::ToBinary ( const double &  value,
unsigned char *  buffer,
unsigned int  maxlen 
)
static

Convert the specified value to a binary representation in the buffer Typically just a memcopy of the variable, though endianness may come into it.

Convert the specified data value to a binary representation in the buffer Typically just a memcopy of the variable, though endianness may come into it.

unsigned int Double::toStream ( OutStream outStream) const
virtual

Send the data value to the indicated stream.

Return the number of bytes written. For now, assume little-endian.

Implements DataValue.

Reimplemented in Double6, and Double4.

References OutStream::bytesWritten(), DataValue::typeSize_, value_, and OutStream::write().

Str Double::toString ( const Unit unit) const
virtual

Implements DataValue.

References Unit::getScaled(), and value_.

Member Data Documentation

RingBufferVoid * Double::MallocRing_
staticprotected

Declared as a pointer to avoid including RingBuffer.h header here.

Referenced by Double::StaticDestructor::~StaticDestructor().

Double::StaticDestructor Double::StaticDestructor_
staticprotected

Static instance of StaticDestructor.


The documentation for this class was generated from the following files: