openDAQ
Open data acquisition platform
IRatio Struct Referenceabstract
+ Inheritance diagram for IRatio:
+ Collaboration diagram for IRatio:

Detailed Description

Represents rational number as IRatio interface. Use this interface to wrap rational number when you need to add the number to lists, dictionaries and other containers which accept IBaseObject and derived interfaces.

Rational numbers are defined as numerator / denominator.

Available factories:

// Creates a new Ratio object. Throws exception if not successful.
IRatio* Ratio_Create(Int numerator, Int denominator)
// Creates a new Ratio object. Returns error code if not successful.
ErrCode createRatio(IRatio** obj, Int numerator, Int denominator)

Public Member Functions

virtual ErrCode INTERFACE_FUNC getNumerator (Int *numerator)=0
 Gets numerator part. More...
 
virtual ErrCode INTERFACE_FUNC getDenominator (Int *denominator)=0
 Gets denominator part. More...
 
virtual ErrCode INTERFACE_FUNC simplify (IRatio **simplifiedRatio)=0
 Simplifies rational number if possible and returns the simplified ratio as a new object. More...
 
- Public Member Functions inherited from IBaseObject
virtual ErrCode INTERFACE_FUNC borrowInterface (const IntfID &intfID, void **obj) const =0
 Returns another interface which is supported by the object without incrementing the reference count. More...
 
virtual ErrCode INTERFACE_FUNC dispose ()=0
 Disposes all references held by the object. More...
 
virtual ErrCode INTERFACE_FUNC getHashCode (SizeT *hashCode)=0
 Returns hash code of the object. More...
 
virtual ErrCode INTERFACE_FUNC equals (IBaseObject *other, Bool *equal) const =0
 Compares object to another object for equality. More...
 
virtual ErrCode INTERFACE_FUNC toString (CharPtr *str)=0
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from IUnknown
virtual ErrCode INTERFACE_FUNC queryInterface (const IntfID &intfID, void **obj)=0
 Returns another interface which is supported by the object and increments the reference count. More...
 
virtual int INTERFACE_FUNC addRef ()=0
 Increments the reference count for an interface on an object. More...
 
virtual int INTERFACE_FUNC releaseRef ()=0
 Decrements the reference count for an interface on an object. More...
 

Member Function Documentation

◆ getDenominator()

virtual ErrCode INTERFACE_FUNC getDenominator ( Int *  denominator)
pure virtual

Gets denominator part.

Parameters
[out]denominatorDenominator value.

◆ getNumerator()

virtual ErrCode INTERFACE_FUNC getNumerator ( Int *  numerator)
pure virtual

Gets numerator part.

Parameters
[out]numeratorNumerator value.

◆ simplify()

virtual ErrCode INTERFACE_FUNC simplify ( IRatio **  simplifiedRatio)
pure virtual

Simplifies rational number if possible and returns the simplified ratio as a new object.

Parameters
[out]simplifiedRatiothe simplified ratio.

Call this method to reduce stored rational number to the lowest terms possible. Example: 10/100 is reduced to 1/10.

IRatio
Definition: ratio.h:45
ErrCode
BEGIN_NAMESPACE_OPENDAQ typedef uint32_t ErrCode
Definition: common.h:60