FTValueClass Module

A not completely F2003/2008 version of an immutable class to store primitive values: integer, real, double precision, logical, character. (To Add: complex)

This version does not use CLASS(*) or deferred length strings so that it can be used with gfortran 4.7/4.8

Usage:

  • Initialization

       TYPE(FTValue) :: r, i, s, l, d
    
       CALL r % initValue(3.14)
       CALL i % initValue(6)
       CALL d % initValue(3.14d0)
       CALL l % initValue(.true.)
       CALL s % initValue("A string")
    
  • Destruction

       call releaseFTValue(r) [Pointers]
    
  • Accessors

       real = r % realValue()
       int  = i % integerValue()
       doub = d % doublePrecisionValue()
       logc = l % logicalValue()
       str  = s % stringValue(nChars)
    
  • Description

       str = v % description()
       call v % printDescription(unit)
    
  • Casting

       CLASS(FTVALUE) , POINTER :: v
       CLASS(FTObject), POINTER :: obj
       call cast(obj,v)
    

The class will attempt to convert between the different types:

       CALL r % initWithReal(3.14)
       print *, r % stringValue(8)

       Logical variables rules:

       real, doublePrecision, integer values
          logicalValue = .FALSE. if input = 0
          logicalValue = .TRUE.  if input /= 0

String values can be converted to numeric types. If the string is not a numeric, Huge(1) will be returned, for integers and NaN for reals.

@author David Kopriva


Uses

  • module~~ftvalueclass~~UsesGraph module~ftvalueclass FTValueClass ieee_arithmetic ieee_arithmetic module~ftvalueclass->ieee_arithmetic iso_fortran_env iso_fortran_env module~ftvalueclass->iso_fortran_env module~ftobjectclass FTObjectClass module~ftvalueclass->module~ftobjectclass module~ftolconstants FTOLConstants module~ftvalueclass->module~ftolconstants

Used by

  • module~~ftvalueclass~~UsedByGraph module~ftvalueclass FTValueClass module~ftobjectlibrary FTObjectLibrary module~ftobjectlibrary->module~ftvalueclass module~ftvaluedictionaryclass FTValueDictionaryClass module~ftobjectlibrary->module~ftvaluedictionaryclass module~ftexceptionclass FTExceptionClass module~ftobjectlibrary->module~ftexceptionclass module~ftvaluedictionaryclass->module~ftvalueclass module~ftexceptionclass->module~ftvaluedictionaryclass module~sharedexceptionmanagermodule SharedExceptionManagerModule module~sharedexceptionmanagermodule->module~ftexceptionclass

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: FTVALUE_NOT_INTEGER = HUGE(1)
real, public, parameter :: FTVALUE_NOT_REAL = HUGE(1.0)
double precision, public, parameter :: FTVALUE_NOT_DOUBLEPRECISION = HUGE(1.0D0)
integer, public, parameter :: FTVALUE_STRING_LENGTH = 512
integer, public, parameter :: FT_REAL_KIND = SELECTED_REAL_KIND(6)
integer, public, parameter :: FT_DOUBLE_PRECISION_KIND = SELECTED_REAL_KIND(15)

Interfaces

public interface cast

  • public subroutine castToValue(obj, cast)

    Generic Name: cast

    Cast a pointer to the base class to an FTValue pointer

    Arguments

    Type IntentOptional Attributes Name
    class(FTObject), POINTER :: obj
    class(FTValue), POINTER :: cast

Derived Types

type, public, extends(FTObject) ::  FTValue

Finalizations Procedures

final :: destructValue

Type-Bound Procedures

procedure, public :: init => initFTObject
procedure, public, non_overridable :: copy => copyFTObject
procedure, public, non_overridable :: retain => retainFTObject
procedure, public, non_overridable :: isUnreferenced
procedure, public, non_overridable :: refCount
generic, public :: initWithValue => initWithReal, initWithDoublePrecision, initWithString, initWithLogical, initWithInteger
generic, public :: initWithValue => initWithQuad
procedure, public :: realValue
procedure, public :: doublePrecisionValue
procedure, public :: quadValue
procedure, public :: stringValue
procedure, public :: logicalValue
procedure, public :: integerValue
procedure, public :: description => FTValueDescription
procedure, public :: printDescription => printValueDescription
procedure, public :: className => valueClassName

Functions

public function realValue(self)

Get the real value stored in the object, or convert the value in the object to a real if it is of a different type.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self

Return Value real

public function doublePrecisionValue(self)

Get the double precision value stored in the object, or convert the value in the object to a double precision if it is of a different type.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self

Return Value doubleprecision

public function quadValue(self)

Get the double precision value stored in the object, or convert the value in the object to a double precision if it is of a different type.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self

Return Value doubleprecision

public function integerValue(self)

Get the integer value stored in the object, or convert the value in the object to an integer if it is of a different type.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self

Return Value integer

public function logicalValue(self)

Get the logical value stored in the object, or convert the value in the object to a logical if it is of a different type.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self

Return Value logical

public function stringValue(self, requestedLength) result(s)

Get the string value of length requestedLength stored in the object, or convert the value in the object to a string of that length if it is of a different type.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
integer :: requestedLength

Return Value character(len=requestedLength)

public function FTValueDescription(self)

Returns the description of the value. In this case, it returns the stringValue() of the object.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self

Return Value character(len=DESCRIPTION_CHARACTER_LENGTH)

public function valueFromObject(obj) result(cast)

Arguments

Type IntentOptional Attributes Name
class(FTObject), POINTER :: obj

Return Value class(FTValue), POINTER

public function valueClassName(self) result(s)

Class name returns a string with the name of the type of the object

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self

Return Value character(len=CLASS_NAME_CHARACTER_LENGTH)


Subroutines

public subroutine initWithReal(self, v)

Public, generic name: initwithValue()

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
real :: v

public subroutine initWithDoublePrecision(self, v)

Public, generic name: initwithValue()

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
doubleprecision :: v

public subroutine initWithQuad(self, v)

Public, generic name: initwithValue()

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)) :: v

public subroutine initWithInteger(self, v)

Public, generic name: initwithValue()

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
integer :: v

public subroutine initWithLogical(self, v)

Public, generic name: initwithValue()

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
logical :: v

public subroutine initWithString(self, v)

Public, generic name: initwithValue()

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
character(len=*) :: v

public subroutine releaseFTValue(self)

Arguments

Type IntentOptional Attributes Name
type(FTValue), POINTER :: self

public subroutine destructValue(self)

Public, generic name: destruct()

Read more…

Arguments

Type IntentOptional Attributes Name
type(FTValue) :: self

public subroutine printValueDescription(self, iUnit)

Prints the description of the value to unit iUnit. In this case, it prints
the stringValue() of the object.

Arguments

Type IntentOptional Attributes Name
class(FTValue) :: self
integer :: iUnit

public subroutine castToValue(obj, cast)

Generic Name: cast

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTObject), POINTER :: obj
class(FTValue), POINTER :: cast