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

#include <DataObject.hh>

Inheritance diagram for NullDataObject:
Inheritance graph
Collaboration diagram for NullDataObject:
Collaboration graph

Public Member Functions

virtual int integerValue () const override
 
virtual SLongWord longValue () const override
 
virtual void setInteger (int value) override
 
virtual void setLong (SLongWord value) override
 
virtual std::string stringValue () const
 
virtual void setString (std::string value) override
 
virtual double doubleValue () const
 
virtual void setDouble (double value) override
 
virtual float floatValue () const
 
virtual void setFloat (float value) override
 
virtual bool isNull () const
 
virtual void setNull () override
 
- Public Member Functions inherited from DataObject
 DataObject ()
 
 DataObject (int value)
 
 DataObject (SLongWord value)
 
 DataObject (double value)
 
 DataObject (const std::string value)
 
virtual ~DataObject ()
 
virtual bool boolValue () const
 
virtual void setBool (bool value)
 
virtual bool operator!= (const DataObject &object) const
 

Static Public Member Functions

static NullDataObjectinstance ()
 

Private Member Functions

 NullDataObject ()
 
virtual ~NullDataObject ()
 
 NullDataObject (const DataObject &obj)
 

Static Private Attributes

static NullDataObjectinstance_ = NULL
 

Additional Inherited Members

- Public Types inherited from DataObject
enum  OrigType {
  TYPE_INT, TYPE_STRING, TYPE_DOUBLE, TYPE_FLOAT,
  TYPE_NULL, TYPE_NOTYPE
}
 
- Protected Member Functions inherited from DataObject
OrigType type () const
 
bool intFresh () const
 
bool stringFresh () const
 
bool doubleFresh () const
 
bool floatFresh () const
 

Detailed Description

Singleton class that represents a null DataObject.

All methods write to error log and abort the program.

Definition at line 128 of file DataObject.hh.

Constructor & Destructor Documentation

◆ NullDataObject() [1/2]

NullDataObject::NullDataObject ( )
private

Constructor.

Definition at line 526 of file DataObject.cc.

526  {
527 }

Referenced by instance().

◆ ~NullDataObject()

NullDataObject::~NullDataObject ( )
privatevirtual

Destructor.

Definition at line 532 of file DataObject.cc.

532  {
533 }

◆ NullDataObject() [2/2]

NullDataObject::NullDataObject ( const DataObject obj)
private

Member Function Documentation

◆ doubleValue()

double NullDataObject::doubleValue ( ) const
virtual

Returns the double value of DataObject.

If double value is not available, the conversion is done from the original data type. Note that a NULL DataObject is converted to 0.0.

Returns
The double value of DataObject.
Exceptions
NumberFormatExceptionIf conversion fails or if DataObject is not initialized.

Reimplemented from DataObject.

Definition at line 603 of file DataObject.cc.

603  {
604  abortWithError("doubleValue()");
605  return 0.0;
606 }

References abortWithError.

◆ floatValue()

float NullDataObject::floatValue ( ) const
virtual

Returns the float value of DataObject.

If float value is not available, the conversion is done from the original data type. Note that a NULL DataObject is converted to 0.0.

Returns
The float value of DataObject.
Exceptions
NumberFormatExceptionIf conversion fails or if DataObject is not initialized.

Reimplemented from DataObject.

Definition at line 609 of file DataObject.cc.

609  {
610  abortWithError("floatValue()");
611  return 0.0;
612 }

References abortWithError.

◆ instance()

NullDataObject & NullDataObject::instance ( )
static

Returns an instance of NullDataObject (singleton)

Returns
NullDataObject singleton instance.

Definition at line 542 of file DataObject.cc.

542  {
543  if (instance_ == NULL) {
544  instance_ = new NullDataObject();
545  }
546  return *instance_;
547 }

References instance_, and NullDataObject().

Referenced by InstructionExecution::address(), InstructionExecution::cycle(), RelationalDBQueryResult::data(), and SQLiteQueryResult::data().

Here is the call graph for this function:

◆ integerValue()

int NullDataObject::integerValue ( ) const
overridevirtual

Returns the integer value of DataObject.

If integer value is not available, the conversion is done from the original value type. Note that a NULL DataObject is converted to 0.

Returns
The integer value of DataObject.
Exceptions
NumberFormatExceptionIf conversion fails or if DataObject is not initialized.

Reimplemented from DataObject.

Definition at line 585 of file DataObject.cc.

585  {
586  abortWithError("integerValue()");
587  return 0;
588 }

References abortWithError.

◆ isNull()

bool NullDataObject::isNull ( ) const
virtual

Returns true in case the object represents a NULL value.

Returns
True in case the object's value is NULL.

Reimplemented from DataObject.

Definition at line 615 of file DataObject.cc.

615  {
616  abortWithError("isNull()");
617  return false;
618 }

References abortWithError.

◆ longValue()

SLongWord NullDataObject::longValue ( ) const
overridevirtual

Returns the (long) integer value of DataObject.

If integer value is not available, the conversion is done from the original value type. Note that a NULL DataObject is converted to 0.

Returns
The integer value of DataObject.
Exceptions
NumberFormatExceptionIf conversion fails or if DataObject is not initialized.

Reimplemented from DataObject.

Definition at line 591 of file DataObject.cc.

591  {
592  abortWithError("longValue()");
593  return 0;
594 }

References abortWithError.

◆ setDouble()

void NullDataObject::setDouble ( double  value)
overridevirtual

Sets the double value of DataObject.

Parameters
valueThe double value of DataObject.

Reimplemented from DataObject.

Definition at line 570 of file DataObject.cc.

570  {
571  abortWithError("setDouble()");
572 }

References abortWithError.

◆ setFloat()

void NullDataObject::setFloat ( float  value)
overridevirtual

Sets the float value of DataObject.

Parameters
valueThe float value of DataObject.

Reimplemented from DataObject.

Definition at line 575 of file DataObject.cc.

575  {
576  abortWithError("setFloat()");
577 }

References abortWithError.

◆ setInteger()

void NullDataObject::setInteger ( int  value)
overridevirtual

All method implementations of NullDataObject write a message to error log and abort the program.

Reimplemented from DataObject.

Definition at line 555 of file DataObject.cc.

555  {
556  abortWithError("setInteger()");
557 }

References abortWithError.

◆ setLong()

void NullDataObject::setLong ( SLongWord  value)
overridevirtual

Sets the integer value of DataObject.

Parameters
valueThe integer value.

Reimplemented from DataObject.

Definition at line 560 of file DataObject.cc.

560  {
561  abortWithError("setLong()");
562 }

References abortWithError.

◆ setNull()

void NullDataObject::setNull ( )
overridevirtual

Sets the DataObject to null.

Reimplemented from DataObject.

Definition at line 580 of file DataObject.cc.

580  {
581  abortWithError("setNull()");
582 }

References abortWithError.

◆ setString()

void NullDataObject::setString ( std::string  value)
overridevirtual

Sets the string value of DataObject.

Parameters
valueThe string value.

Reimplemented from DataObject.

Definition at line 565 of file DataObject.cc.

565  {
566  abortWithError("setString()");
567 }

References abortWithError.

◆ stringValue()

string NullDataObject::stringValue ( ) const
virtual

Returns the string value of DataObject.

If string value is not available, the conversion is done from the original data type. Note that a NULL DataObject is converted to an empty string.

Returns
The string value of DataObject.
Exceptions
NumberFormatExceptionIf conversion fails or if DataObject is not initialized.

Reimplemented from DataObject.

Definition at line 597 of file DataObject.cc.

597  {
598  abortWithError("stringValue()");
599  return "";
600 }

References abortWithError.

Member Data Documentation

◆ instance_

NullDataObject * NullDataObject::instance_ = NULL
staticprivate

Definition at line 156 of file DataObject.hh.

Referenced by instance().


The documentation for this class was generated from the following files:
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
NullDataObject::NullDataObject
NullDataObject()
Definition: DataObject.cc:526
NullDataObject::instance_
static NullDataObject * instance_
Definition: DataObject.hh:156