OpendTect  7.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
IntegerID< IntType > Class Template Reference

Single integer ID with comparison but no automatic conversion. Making a subclass is optional, but recommended when using multiple IntegerID objects at the same time. Subclassing is mandatory when you want a customized undefined value or a different condition for valid values. More...

Inheritance diagram for IntegerID< IntType >:
[legend]

Public Member Functions

 IntegerID ()
 
 IntegerID (IntType nr)
 
virtual ~IntegerID ()
 
IntType asInt () const
 
void fromString (const char *s, IntType defval=Values::Undef< IntType >::val())
 
bool isUdf () const
 
virtual bool isValid () const
 
virtual bool operator!= (const IntegerID &oth) const
 
virtual bool operator== (const IntegerID &oth) const
 
void set (IntType i)
 
void setUdf ()
 
BufferString toString () const
 

Static Public Member Functions

static IntegerID get (IntType nr)
 
static IntegerID udf ()
 

Protected Member Functions

virtual IntType udfVal () const
 

Private Attributes

IntType nr_
 

Detailed Description

template<class IntType = std::uint16_t>
class IntegerID< IntType >

Single integer ID with comparison but no automatic conversion. Making a subclass is optional, but recommended when using multiple IntegerID objects at the same time. Subclassing is mandatory when you want a customized undefined value or a different condition for valid values.

Example:

using ID = IntegerID<od_uint16>;

void dummy( ID id ) { id.set( 666 ); // good id = 666; // error id += 666; // error id.set( id.asInt() + 666 ); // good }

void dummy2() { dummy( ID::get(555) ); // good dummy( 555 ); // error }

class X { X(); ID id_; };

X::X() : id_(ID::get(444)) {} // good X::X() : id_(444) {} // not recommended, but will compile.

<>

Constructor & Destructor Documentation

◆ IntegerID() [1/2]

template<class IntType = std::uint16_t>
IntegerID< IntType >::IntegerID ( )
inline

◆ IntegerID() [2/2]

template<class IntType = std::uint16_t>
IntegerID< IntType >::IntegerID ( IntType  nr)
inlineexplicit

◆ ~IntegerID()

template<class IntType = std::uint16_t>
virtual IntegerID< IntType >::~IntegerID ( )
inlinevirtual

Member Function Documentation

◆ asInt()

template<class IntType = std::uint16_t>
IntType IntegerID< IntType >::asInt ( ) const
inline

◆ fromString()

template<class IntType = std::uint16_t>
void IntegerID< IntType >::fromString ( const char *  s,
IntType  defval = Values::Undef< IntType >::val() 
)
inline

◆ get()

template<class IntType = std::uint16_t>
static IntegerID IntegerID< IntType >::get ( IntType  nr)
inlinestatic

◆ isUdf()

template<class IntType = std::uint16_t>
bool IntegerID< IntType >::isUdf ( ) const
inline

◆ isValid()

template<class IntType = std::uint16_t>
virtual bool IntegerID< IntType >::isValid ( ) const
inlinevirtual

Reimplemented in Pos::GeomID, SynthID, and DataPackMgrID.

◆ operator!=()

template<class IntType = std::uint16_t>
virtual bool IntegerID< IntType >::operator!= ( const IntegerID< IntType > &  oth) const
inlinevirtual

◆ operator==()

template<class IntType = std::uint16_t>
virtual bool IntegerID< IntType >::operator== ( const IntegerID< IntType > &  oth) const
inlinevirtual

◆ set()

template<class IntType = std::uint16_t>
void IntegerID< IntType >::set ( IntType  i)
inline

◆ setUdf()

template<class IntType = std::uint16_t>
void IntegerID< IntType >::setUdf ( )
inline

◆ toString()

template<class IntType = std::uint16_t>
BufferString IntegerID< IntType >::toString ( ) const
inline

◆ udf()

template<class IntType = std::uint16_t>
static IntegerID IntegerID< IntType >::udf ( )
inlinestatic

◆ udfVal()

template<class IntType = std::uint16_t>
virtual IntType IntegerID< IntType >::udfVal ( ) const
inlineprotectedvirtual

Member Data Documentation

◆ nr_

template<class IntType = std::uint16_t>
IntType IntegerID< IntType >::nr_
private

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2024