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

#include <EntryKeyData.hh>

Inheritance diagram for EntryKeyDataInt:
Inheritance graph
Collaboration diagram for EntryKeyDataInt:
Collaboration graph

Public Member Functions

 EntryKeyDataInt ()
 
 EntryKeyDataInt (int fieldData)
 
virtual ~EntryKeyDataInt ()
 
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

 EntryKeyDataInt (const EntryKeyDataInt &)
 Copying not allowed. More...
 
EntryKeyDataIntoperator= (const EntryKeyDataInt &)
 Assignment not allowed. More...
 

Private Attributes

int data_
 Integer data. More...
 

Detailed Description

Implementation for integer type of data.

Definition at line 83 of file EntryKeyData.hh.

Constructor & Destructor Documentation

◆ EntryKeyDataInt() [1/3]

EntryKeyDataInt::EntryKeyDataInt ( )

Default constructor.

Definition at line 73 of file EntryKeyData.cc.

73  : data_(0) {
74 }

Referenced by copy().

◆ EntryKeyDataInt() [2/3]

EntryKeyDataInt::EntryKeyDataInt ( int  fieldData)

Constructor.

Parameters
fieldDataAn integer.

Definition at line 81 of file EntryKeyData.cc.

81  : data_(fieldData) {
82 }

◆ ~EntryKeyDataInt()

EntryKeyDataInt::~EntryKeyDataInt ( )
virtual

Destructor.

Definition at line 87 of file EntryKeyData.cc.

87  {
88 }

◆ EntryKeyDataInt() [3/3]

EntryKeyDataInt::EntryKeyDataInt ( const EntryKeyDataInt )
private

Copying not allowed.

Member Function Documentation

◆ coefficient()

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

Returns the relative position between two integers.

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

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

Implements EntryKeyData.

Definition at line 179 of file EntryKeyData.cc.

180  {
181  EntryKeyDataInt* int1 = dynamic_cast<EntryKeyDataInt*>(
182  const_cast<EntryKeyData*>(data1));
183  EntryKeyDataInt* int2 = dynamic_cast<EntryKeyDataInt*>(
184  const_cast<EntryKeyData*>(data2));
185  if (int1 == NULL) {
186  throw WrongSubclass(__FILE__, __LINE__,
187  "EntryKeyDataInt::coefficient param1");
188  }
189  if (int2 == NULL) {
190  throw WrongSubclass(__FILE__, __LINE__,
191  "EntryKeyDataInt::coefficient param2");
192  }
193 
194  return static_cast<double>(data_ - int1->data_) /
195  static_cast<double>(int2->data_ - int1->data_);
196 }

References data_.

◆ copy()

EntryKeyData * EntryKeyDataInt::copy ( ) const
virtual

Copies integer.

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

Returns
A copy of the integer.

Implements EntryKeyData.

Definition at line 99 of file EntryKeyData.cc.

99  {
100  return new EntryKeyDataInt(data_);
101 }

References data_, and EntryKeyDataInt().

Here is the call graph for this function:

◆ isEqual()

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

Checks if two integers are equal.

Cannot compare integers to other data types.

Parameters
fieldDataAn integer.
Returns
True if two integers are equal.
Exceptions
WrongSubclassGiven data type was illegal.

Implements EntryKeyData.

Definition at line 113 of file EntryKeyData.cc.

113  {
114  EntryKeyDataInt* integer = dynamic_cast<EntryKeyDataInt*>(
115  const_cast<EntryKeyData*>(fieldData));
116  if (integer == NULL) {
117  throw WrongSubclass(__FILE__, __LINE__,
118  "EntryKeyDataInt::isEqual");
119  }
120  return data_ == integer->data_;
121 }

References data_.

◆ isGreater()

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

Checks if this integer is greater than another integer.

Cannot compare integers to other data types.

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

Implements EntryKeyData.

Definition at line 134 of file EntryKeyData.cc.

134  {
135  EntryKeyDataInt* integer = dynamic_cast<EntryKeyDataInt*>(
136  const_cast<EntryKeyData*>(fieldData));
137  if (integer == NULL) {
138  throw WrongSubclass(__FILE__, __LINE__,
139  "EntryKeyDataInt::isGreater");
140  }
141  return data_ > integer->data_;
142 }

References data_.

◆ isSmaller()

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

Checks if this integer is smaller than another integer.

Cannot compare integers to other data types.

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

Implements EntryKeyData.

Definition at line 155 of file EntryKeyData.cc.

155  {
156  EntryKeyDataInt* integer = dynamic_cast<EntryKeyDataInt*>(
157  const_cast<EntryKeyData*>(fieldData));
158  if (integer == NULL) {
159  throw WrongSubclass(__FILE__, __LINE__,
160  "EntryKeyDataInt::isSmaller");
161  }
162  return data_ < integer->data_;
163 }

References data_.

◆ operator=()

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

Assignment not allowed.

◆ toString()

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

Converts the integer into a string.

Returns
integer as a string

Implements EntryKeyData.

Definition at line 204 of file EntryKeyData.cc.

204  {
205  return Conversion::toString(data_);
206 }

References data_, and Conversion::toString().

Here is the call graph for this function:

Member Data Documentation

◆ data_

int EntryKeyDataInt::data_
private

Integer data.

Definition at line 99 of file EntryKeyData.hh.

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


The documentation for this class was generated from the following files:
Conversion::toString
static std::string toString(const T &source)
EntryKeyDataInt::EntryKeyDataInt
EntryKeyDataInt()
Definition: EntryKeyData.cc:73
EntryKeyData
Definition: EntryKeyData.hh:53
WrongSubclass
Definition: Exception.hh:336
EntryKeyDataInt::data_
int data_
Integer data.
Definition: EntryKeyData.hh:99
EntryKeyDataInt
Definition: EntryKeyData.hh:83