DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Static Public Member Functions | Static Public Attributes
DGtal::NumberTraits< T > Struct Template Reference

#include <NumberTraits.h>

Inheritance diagram for DGtal::NumberTraits< T >:
Inheritance graph
[legend]
Collaboration diagram for DGtal::NumberTraits< T >:
Collaboration graph
[legend]

Public Types

typedef TagUnknown IsBounded
typedef TagUnknown IsUnsigned
typedef TagUnknown IsSigned
typedef TagFalse IsSpecialized
typedef T SignedVersion
typedef T UnsignedVersion
typedef T ReturnType
typedef boost::call_traits< T >
::param_type 
ParamType

Static Public Member Functions

static ReturnType zero ()
static ReturnType one ()
static ReturnType min ()
static ReturnType max ()
static unsigned int digits ()
static BoundEnum isBounded ()
static SignEnum isSigned ()
static DGtal::int64_t castToInt64_t (const T &aT)
static double castToDouble (const T &aT)
static bool even (ParamType aT)
static bool odd (ParamType aT)

Static Public Attributes

static const T ZERO = T(0)
static const T ONE = T(1)

Detailed Description

template<typename T>
struct DGtal::NumberTraits< T >

Aim: The traits class for all models of Cinteger.

Description of template class 'NumberTraits'

Since CInteger describes the concept Integer, this class is used by models of CIinteger to specialize some definitions related to Integer. For instance it defines whether a given Integer is signed or not and what is signed/unsigned version.

Examples:
arithmetic/approximation.cpp.

Definition at line 71 of file NumberTraits.h.


Member Typedef Documentation

template<typename T>
typedef TagUnknown DGtal::NumberTraits< T >::IsBounded

Definition at line 74 of file NumberTraits.h.

template<typename T>
typedef TagUnknown DGtal::NumberTraits< T >::IsSigned

Definition at line 76 of file NumberTraits.h.

template<typename T>
typedef TagFalse DGtal::NumberTraits< T >::IsSpecialized

Definition at line 77 of file NumberTraits.h.

template<typename T>
typedef TagUnknown DGtal::NumberTraits< T >::IsUnsigned

Definition at line 75 of file NumberTraits.h.

template<typename T>
typedef boost::call_traits<T>::param_type DGtal::NumberTraits< T >::ParamType

Definition at line 84 of file NumberTraits.h.

template<typename T>
typedef T DGtal::NumberTraits< T >::ReturnType

Definition at line 80 of file NumberTraits.h.

template<typename T>
typedef T DGtal::NumberTraits< T >::SignedVersion

Definition at line 78 of file NumberTraits.h.

template<typename T>
typedef T DGtal::NumberTraits< T >::UnsignedVersion

Definition at line 79 of file NumberTraits.h.


Member Function Documentation

template<typename T>
static double DGtal::NumberTraits< T >::castToDouble ( const T &  aT)
inlinestatic
template<typename T>
static DGtal::int64_t DGtal::NumberTraits< T >::castToInt64_t ( const T &  aT)
inlinestatic

Cast method to DGtal::int64_t (for I/O or board export uses only).

Examples:
arithmetic/approximation.cpp.

Definition at line 147 of file NumberTraits.h.

Referenced by DGtal::Display3DFactory::draw(), DGtal::Pattern< TFraction >::getGreatestIncludedSubpattern(), and DGtal::Pattern< TFraction >::getSmallestCoveringSubpattern().

{
return static_cast<DGtal::int64_t>(aT);
}
template<typename T >
unsigned int DGtal::NumberTraits< T >::digits ( )
inlinestatic
Returns:
the number of significant digits for this integer type, or 0 if unbounded or unknown.

Definition at line 104 of file NumberTraits.ih.

{
return 0;
}
template<typename T>
static bool DGtal::NumberTraits< T >::even ( ParamType  aT)
inlinestatic
Parameters:
aTany number.
Returns:
'true' iff the number is even.

Definition at line 163 of file NumberTraits.h.

{
return ( aT & ONE ) == ZERO;
}
template<typename T >
DGtal::BoundEnum DGtal::NumberTraits< T >::isBounded ( )
inlinestatic
Returns:
BOUNDED, UNBOUNDED, or BOUND_UNKNOWN.
1 if bounded, 0, if not bounded, 2 if unknown.

Definition at line 115 of file NumberTraits.ih.

References DGtal::BOUND_UNKNOWN.

{
return BOUND_UNKNOWN;
}
template<typename T >
DGtal::SignEnum DGtal::NumberTraits< T >::isSigned ( )
inlinestatic
Returns:
SIGNED, UNSIGNED or SIGN_UNKNOWN.
1 if unsigned, 0, if signed, 2 if unknown.

Definition at line 126 of file NumberTraits.ih.

References DGtal::SIGN_UNKNOWN.

{
return SIGN_UNKNOWN;
}
template<typename T >
DGtal::NumberTraits< T >::ReturnType DGtal::NumberTraits< T >::max ( )
inlinestatic
Returns:
the maximum possible value for this type of integer or ZERO if not bounded or unknown.

Definition at line 92 of file NumberTraits.ih.

Referenced by DGtal::KhalimskySpaceND< dim, TInteger >::KhalimskySpaceND().

{
return ZERO;
}
template<typename T >
DGtal::NumberTraits< T >::ReturnType DGtal::NumberTraits< T >::min ( )
inlinestatic
Returns:
the minimum possible value for this type of integer or ONE if not bounded or unknown.

Definition at line 80 of file NumberTraits.ih.

Referenced by DGtal::KhalimskySpaceND< dim, TInteger >::KhalimskySpaceND().

{
return ONE;
}
template<typename T>
static bool DGtal::NumberTraits< T >::odd ( ParamType  aT)
inlinestatic
Parameters:
aTany number.
Returns:
'true' iff the number is odd.

Definition at line 171 of file NumberTraits.h.

{
return ( aT & ONE ) != ZERO;
}
template<typename T >
DGtal::NumberTraits< T >::ReturnType DGtal::NumberTraits< T >::one ( )
inlinestatic
Returns:
the one of this integer.

Definition at line 64 of file NumberTraits.ih.

{
#if (defined(WIN32))
return 1;
#else
return ONE;
#endif
}
template<typename T >
DGtal::NumberTraits< T >::ReturnType DGtal::NumberTraits< T >::zero ( )
inlinestatic
Returns:
the zero of this integer.

Definition at line 49 of file NumberTraits.ih.

{
#if (defined(WIN32))
return 0;
#else
return ZERO;
#endif
}

Field Documentation

template<typename T>
const T DGtal::NumberTraits< T >::ONE = T(1)
static

Constant One.

Definition at line 103 of file NumberTraits.h.

Referenced by DGtal::NumberTraits< Integer >::even(), and DGtal::NumberTraits< Integer >::odd().

template<typename T>
const T DGtal::NumberTraits< T >::ZERO = T(0)
static

Constant Zero.

Definition at line 94 of file NumberTraits.h.

Referenced by DGtal::NumberTraits< Integer >::even(), and DGtal::NumberTraits< Integer >::odd().


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