fw4spl
fwAtoms::Numeric Class Reference

Storing a numeric value. More...

#include <Numeric.hpp>

+ Inheritance diagram for fwAtoms::Numeric:
+ Collaboration diagram for fwAtoms::Numeric:

Public Types

enum  NumericType {
  EMPTY = 0, INT, UINT, FLOAT,
  DOUBLE
}
 
typedef ::boost::variant< ::boost::blank, std::int64_t, std::uint64_t, float, double > ValueType
 
- Public Types inherited from fwAtoms::Base
enum  AtomType {
  BOOLEAN = 1, NUMERIC, STRING, OBJECT,
  SEQUENCE, MAP, BLOB
}
 
typedef ::fwAtoms::factory::Key Key
 

Public Member Functions

virtual bool isA (const std::string &type) const override
 
 Numeric (::fwAtoms::Base::Key key)
 Constructor. More...
 
virtual ~Numeric ()
 Destructor.
 
virtual FWATOMS_API Base::sptr clone () const override
 Returns a clone object.
 
::fwAtoms::Base::AtomType type () const override
 returns Atom type
 
NumericType variantType () const
 Returns currently held numeric type.
 
const ValueType & getVariant () const
 Returns const reference to numeric's variant. More...
 
virtual FWATOMS_API std::string getString () const override
 Returns a string representing the currently held numeric value.
 
FWATOMS_API void setFromString (const std::string &s, NumericType type=EMPTY)
 Sets Numeric's value from given string, using Numeric::valueFromString.
 
template<typename T >
getValue () const
 Returns the held value static_casted to T. More...
 
- Public Member Functions inherited from fwAtoms::Base
bool isValue () const
 Test if the current base is a value or not (Value = {string;numeric;boolean}) More...
 
bool isBoolean () const
 Test if the current base is a boolean. More...
 
bool isNumeric () const
 Test if the current base is a Numeric (real or integer) More...
 
bool isString () const
 Test if the current base is a string. More...
 
bool isSequence () const
 Test if the current base is a sequence. More...
 
bool isMapping () const
 Test if the current base is a mapping. More...
 
bool isBlob () const
 Test if the current base is a blob (a object with a buffer) More...
 
bool isObject () const
 Test if the current base is an object (representation of fwData) More...
 
- Public Member Functions inherited from fwCore::BaseObject

Static Public Member Functions

static bool isTypeOf (const std::string &type)
 
template<typename T >
static Numeric::sptr New (T value)
 Build a new numeric type. More...
 
static FWATOMS_API ValueType valueFromString (const std::string &s, NumericType type=EMPTY)
 Retuns a ValueType from a std::string. More...
 
- Static Public Member Functions inherited from fwAtoms::Base
static bool isTypeOf (const std::string &type)
 
static const std::string & classname ()
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 
- Static Public Member Functions inherited from fwCore::BaseObject
static bool isTypeOf (const std::string &type)
 
static const std::string & leafClassname ()
 return object's classname without its namespace, i.e. BaseObject
 
static const std::string & classname ()
 return object's classname without its namespace, i.e. BaseObject
 

Protected Attributes

ValueType m_value
 

Friends

template<class , class , class >
class ::fwTools::ClassFactory
 
class ::fwTools::Factory
 

Demangling methods

virtual const std::string & getLeafClassname () const override
 return object's classname without its namespace, i.e. BaseObject
 
virtual const std::string & getClassname () const override
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 
static const std::string & leafClassname ()
 return object's classname without its namespace, i.e. BaseObject
 
static const std::string & classname ()
 return object's classname without its namespace, i.e. BaseObject
 

Additional Inherited Members

- Static Public Attributes inherited from fwAtoms::Base
static FWATOMS_API const std::string s_VERSION = "1"
 Defines fwAtoms version.
 
- Protected Member Functions inherited from fwAtoms::Base
 Base ()
 Constructor.
 

Detailed Description

Storing a numeric value.

Definition at line 25 of file Numeric.hpp.

Constructor & Destructor Documentation

fwAtoms::Numeric::Numeric ( ::fwAtoms::Base::Key  key)
inline

Constructor.

Parameters
keyPrivate construction key

Definition at line 46 of file Numeric.hpp.

Member Function Documentation

template<typename T >
T fwAtoms::Numeric::getValue ( ) const

Returns the held value static_casted to T.

Template Parameters
Twanted type
Exceptions
boost::positive_overflow
boost::negative_overflow

Definition at line 119 of file Numeric.hxx.

const ValueType& fwAtoms::Numeric::getVariant ( ) const
inline

Returns const reference to numeric's variant.

Returns

Definition at line 91 of file Numeric.hpp.

template<typename T >
Numeric::sptr fwAtoms::Numeric::New ( value)
static

Build a new numeric type.

Parameters
valuereference of all numeric type Supported tested type are (int8/16/32/64, uint8/16/32/64, float, double)

Definition at line 77 of file Numeric.hxx.

Referenced by fwMDSemanticPatch::V09ALA::V10::fwData::Image::apply(), fwMDSemanticPatch::V10::V09ALA::fwData::Image::apply(), fwStructuralPatch::fwData::Image::V1ToV2::apply(), clone(), fwAtomsPatch::patcher::DefaultPatcher::processBase(), and fwAtomConversion::DataVisitor::visit().

+ Here is the caller graph for this function:

Numeric::ValueType fwAtoms::Numeric::valueFromString ( const std::string &  s,
Numeric::NumericType  type = EMPTY 
)
static

Retuns a ValueType from a std::string.

Parameters
ssource string
typetype hint

If hint is EMPTY (default), this method tries to find a fitting type ( in order : int64, uint64, double)

Exceptions
fwAtoms::Exceptionif unable to cast givent string
Returns
a ValueType containing the numeric value

Definition at line 61 of file Numeric.cpp.

References SLM_ASSERT.

Referenced by setFromString().

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: