OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EntryKeyDataDouble Class Reference

#include <EntryKeyData.hh>

Inheritance diagram for EntryKeyDataDouble:
Inheritance graph
Collaboration diagram for EntryKeyDataDouble:
Collaboration graph

Public Member Functions

 EntryKeyDataDouble ()
 
 EntryKeyDataDouble (double fieldData)
 
virtual ~EntryKeyDataDouble ()
 
EntryKeyDatacopy () const
 
bool isEqual (const EntryKeyData *fieldData) const
 
bool isGreater (const EntryKeyData *fieldData) const
 
bool isSmaller (const EntryKeyData *fieldData) const
 
double coefficient (const EntryKeyData *data1, const EntryKeyData *data2) const
 
std::string toString () const
 
- Public Member Functions inherited from EntryKeyData
 EntryKeyData ()
 
virtual ~EntryKeyData ()
 

Private Member Functions

 EntryKeyDataDouble (const EntryKeyDataDouble &)
 Copying not allowed. More...
 
EntryKeyDataDoubleoperator= (const EntryKeyDataDouble &)
 Assignment not allowed. More...
 

Private Attributes

double data_
 Double data. More...
 

Detailed Description

Implementation for double type of data.

Definition at line 111 of file EntryKeyData.hh.

Constructor & Destructor Documentation

◆ EntryKeyDataDouble() [1/3]

EntryKeyDataDouble::EntryKeyDataDouble ( )

Default constructor.

Definition at line 216 of file EntryKeyData.cc.

216  : data_(0) {
217 }

Referenced by copy().

◆ EntryKeyDataDouble() [2/3]

EntryKeyDataDouble::EntryKeyDataDouble ( double  fieldData)

Constructor.

Parameters
fieldDataA double.

Definition at line 224 of file EntryKeyData.cc.

224  : data_(fieldData) {
225 }

◆ ~EntryKeyDataDouble()

EntryKeyDataDouble::~EntryKeyDataDouble ( )
virtual

Destructor.

Definition at line 230 of file EntryKeyData.cc.

230  {
231 }

◆ EntryKeyDataDouble() [3/3]

EntryKeyDataDouble::EntryKeyDataDouble ( const EntryKeyDataDouble )
private

Copying not allowed.

Member Function Documentation

◆ coefficient()

double EntryKeyDataDouble::coefficient ( const EntryKeyData data1,
const EntryKeyData data2 
) const
virtual

Returns the relative position between two doubles.

Returns the double's relative position to the first double compared to the second. For example, if this double is 14, the first double is 10 and the second 20, relative position would be 0.4.

Parameters
data1First double.
data2Second double.
Returns
The relative position between two doubles.
Exceptions
WrongSubclassGiven data type was illegal.

Implements EntryKeyData.

Definition at line 322 of file EntryKeyData.cc.

323  {
324  EntryKeyDataDouble* double1 = dynamic_cast<EntryKeyDataDouble*>(
325  const_cast<EntryKeyData*>(data1));
326  EntryKeyDataDouble* double2 = dynamic_cast<EntryKeyDataDouble*>(
327  const_cast<EntryKeyData*>(data2));
328  if (double1 == NULL) {
329  throw WrongSubclass(__FILE__, __LINE__,
330  "EntryKeyDataDouble::coefficient param1");
331  }
332  if(double2 == NULL) {
333  throw WrongSubclass(__FILE__, __LINE__,
334  "EntryKeyDataDouble::coefficient param2");
335  }
336 
337  return (data_ - double1->data_) / (double2->data_ - double1->data_);
338 }

References data_.

◆ copy()

EntryKeyData * EntryKeyDataDouble::copy ( ) const
virtual

Copies the double.

Client is responsible of deallocating the memory reserved for the returned object.

Returns
A copy of the double.

Implements EntryKeyData.

Definition at line 242 of file EntryKeyData.cc.

242  {
243  return new EntryKeyDataDouble(data_);
244 }

References data_, and EntryKeyDataDouble().

Here is the call graph for this function:

◆ isEqual()

bool EntryKeyDataDouble::isEqual ( const EntryKeyData fieldData) const
virtual

Checks if two doubles are equal.

Cannot compare double to other data types.

Parameters
fieldDataA double.
Returns
True if two doubles are equal.
Exceptions
WrongSubclassGiven data type was illegal.

Implements EntryKeyData.

Definition at line 256 of file EntryKeyData.cc.

256  {
257  EntryKeyDataDouble* data = dynamic_cast<EntryKeyDataDouble*>(
258  const_cast<EntryKeyData*>(fieldData));
259  if (data == NULL) {
260  throw WrongSubclass(__FILE__, __LINE__,
261  "EntryKeyDataDouble::isEqual");
262  }
263  return data_ == data->data_;
264 }

References data_.

◆ isGreater()

bool EntryKeyDataDouble::isGreater ( const EntryKeyData fieldData) const
virtual

Checks if another double is greater.

Cannot compare double to other data types.

Parameters
fieldDataA double.
Returns
True if this double is greater than another double, otherwise false.
Exceptions
WrongSubclassGiven data type was illegal.

Implements EntryKeyData.

Definition at line 277 of file EntryKeyData.cc.

277  {
278  EntryKeyDataDouble* data = dynamic_cast<EntryKeyDataDouble*>(
279  const_cast<EntryKeyData*>(fieldData));
280  if (data == NULL) {
281  throw WrongSubclass(__FILE__, __LINE__,
282  "EntryKeyDataDouble::isGreater");
283  }
284  return data_ > data->data_;
285 }

References data_.

◆ isSmaller()

bool EntryKeyDataDouble::isSmaller ( const EntryKeyData fieldData) const
virtual

Checks if this double is smaller than another double.

Cannot compare double to other data types.

Parameters
fieldDataA double.
Returns
True if this double is smaller than another double, otherwise false.
Exceptions
WrongSubclassGiven data type was illegal.

Implements EntryKeyData.

Definition at line 298 of file EntryKeyData.cc.

298  {
299  EntryKeyDataDouble* data = dynamic_cast<EntryKeyDataDouble*>(
300  const_cast<EntryKeyData*>(fieldData));
301  if (data == NULL) {
302  throw WrongSubclass(__FILE__, __LINE__,
303  "EntryKeyDataDouble::isSmaller");
304  }
305  return data_ < data->data_;
306 }

References data_.

◆ operator=()

EntryKeyDataDouble& EntryKeyDataDouble::operator= ( const EntryKeyDataDouble )
private

Assignment not allowed.

◆ toString()

std::string EntryKeyDataDouble::toString ( ) const
virtual

Converts the double into a string.

Returns
Double as a string.

Implements EntryKeyData.

Definition at line 346 of file EntryKeyData.cc.

346  {
347  return Conversion::toString(data_);
348 }

References data_, and Conversion::toString().

Here is the call graph for this function:

Member Data Documentation

◆ data_

double EntryKeyDataDouble::data_
private

Double data.

Definition at line 127 of file EntryKeyData.hh.

Referenced by coefficient(), copy(), isEqual(), isGreater(), isSmaller(), and toString().


The documentation for this class was generated from the following files:
EntryKeyDataDouble
Definition: EntryKeyData.hh:111
Conversion::toString
static std::string toString(const T &source)
EntryKeyData
Definition: EntryKeyData.hh:53
WrongSubclass
Definition: Exception.hh:336
EntryKeyDataDouble::data_
double data_
Double data.
Definition: EntryKeyData.hh:127
EntryKeyDataDouble::EntryKeyDataDouble
EntryKeyDataDouble()
Definition: EntryKeyData.cc:216