libzypp  15.28.6
zypp::base::ProvideNumericId< TDerived, TNumericIdType > Struct Template Reference

Base class for objects providing a numeric Id. More...

#include <ProvideNumericId.h>

Public Member Functions

TNumericIdType numericId () const
 

Protected Member Functions

 ProvideNumericId ()
 Default ctor. More...
 
 ProvideNumericId (const ProvideNumericId &)
 Copy ctor. More...
 
ProvideNumericIdoperator= (const ProvideNumericId &)
 Assign. More...
 
 ~ProvideNumericId ()
 Dtor. More...
 
 ProvideNumericId (const void *const )
 No-Id ctor (0). More...
 

Static Private Member Functions

static TNumericIdType nextId ()
 Provide the next Id to use. More...
 

Private Attributes

const TNumericIdType _numericId
 

Detailed Description

template<class TDerived, class TNumericIdType>
struct zypp::base::ProvideNumericId< TDerived, TNumericIdType >

Base class for objects providing a numeric Id.

The ctor creates a NumericId from some static counter.

The only assertion is that 0 is not used as an Id, unless the derived class explicitly requests this by using ProvideNumericId( const void *const ).

Why should you want to use 0 as an Id? E.g if your class provides some (singleton) No-object. Might be desirable to make the No-object have No-Id.

struct Foo : public base::ProvideNumericId<Foo,unsigned>
{};
Foo foo;
foo.numericId(); // returns foo's NumericId.

Definition at line 45 of file ProvideNumericId.h.

Constructor & Destructor Documentation

template<class TDerived, class TNumericIdType>
zypp::base::ProvideNumericId< TDerived, TNumericIdType >::ProvideNumericId ( )
inlineprotected

Default ctor.

Definition at line 54 of file ProvideNumericId.h.

template<class TDerived, class TNumericIdType>
zypp::base::ProvideNumericId< TDerived, TNumericIdType >::ProvideNumericId ( const ProvideNumericId< TDerived, TNumericIdType > &  )
inlineprotected

Copy ctor.

Definition at line 58 of file ProvideNumericId.h.

template<class TDerived, class TNumericIdType>
zypp::base::ProvideNumericId< TDerived, TNumericIdType >::~ProvideNumericId ( )
inlineprotected

Dtor.

Definition at line 65 of file ProvideNumericId.h.

template<class TDerived, class TNumericIdType>
zypp::base::ProvideNumericId< TDerived, TNumericIdType >::ProvideNumericId ( const void *  const)
inlineprotected

No-Id ctor (0).

Explicitly request Id 0. Use it with care!

Definition at line 71 of file ProvideNumericId.h.

Member Function Documentation

template<class TDerived, class TNumericIdType>
TNumericIdType zypp::base::ProvideNumericId< TDerived, TNumericIdType >::numericId ( ) const
inline
Returns
The objects numeric Id.

Definition at line 49 of file ProvideNumericId.h.

template<class TDerived, class TNumericIdType>
ProvideNumericId& zypp::base::ProvideNumericId< TDerived, TNumericIdType >::operator= ( const ProvideNumericId< TDerived, TNumericIdType > &  )
inlineprotected

Assign.

Definition at line 62 of file ProvideNumericId.h.

template<class TDerived, class TNumericIdType>
static TNumericIdType zypp::base::ProvideNumericId< TDerived, TNumericIdType >::nextId ( )
inlinestaticprivate

Provide the next Id to use.

Definition at line 76 of file ProvideNumericId.h.

Member Data Documentation

template<class TDerived, class TNumericIdType>
const TNumericIdType zypp::base::ProvideNumericId< TDerived, TNumericIdType >::_numericId
private

Definition at line 83 of file ProvideNumericId.h.


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