Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFit::UniqueId< Class > Struct Template Reference

template<class Class>
struct RooFit::UniqueId< Class >

A UniqueId can be added as a class member to enhance any class with a unique identifier for each instantiated object.

Example:

class MyClass {
public:
/// Return unique ID by reference.
/// Please always use the name `uniqueId` for the getter.
UniqueId<MyClass> const& uniqueId() const { return _uniqueId; }
private:
const UniqueId<MyClass> _uniqueId; //! should be non-persistent
};
A UniqueId can be added as a class member to enhance any class with a unique identifier for each inst...
Definition UniqueId.h:39

Definition at line 39 of file UniqueId.h.

Public Types

using Value_t = unsigned long
 

Public Member Functions

 UniqueId ()
 Create a new UniqueId with the next value from the static counter.
 
 UniqueId (const UniqueId &)=delete
 
 UniqueId (UniqueId &&)=delete
 
 operator Value_t () const
 
bool operator< (UniqueId const &other) const
 
UniqueIdoperator= (const UniqueId &)=delete
 
UniqueIdoperator= (UniqueId &&)=delete
 
bool operator== (UniqueId const &other) const
 
constexpr Value_t value () const
 Return numerical value of ID.
 

Static Public Attributes

static const UniqueId nullid {UniqueId<Class>::nullval}
 
static constexpr Value_t nullval = 0UL
 An ID that is less than the ID of any object (similar to nullptr).
 

Private Attributes

Value_t _val
 The value of the nullid.
 

Static Private Attributes

static std::atomic< Value_tcounter {UniqueId<Class>::nullval}
 Numerical value of the ID.
 

#include <RooFit/UniqueId.h>

Member Typedef Documentation

◆ Value_t

template<class Class >
using RooFit::UniqueId< Class >::Value_t = unsigned long

Definition at line 41 of file UniqueId.h.

Constructor & Destructor Documentation

◆ UniqueId() [1/3]

template<class Class >
RooFit::UniqueId< Class >::UniqueId ( )
inline

Create a new UniqueId with the next value from the static counter.

Definition at line 44 of file UniqueId.h.

◆ UniqueId() [2/3]

template<class Class >
RooFit::UniqueId< Class >::UniqueId ( const UniqueId< Class > &  )
delete

◆ UniqueId() [3/3]

template<class Class >
RooFit::UniqueId< Class >::UniqueId ( UniqueId< Class > &&  )
delete

Member Function Documentation

◆ operator Value_t()

template<class Class >
RooFit::UniqueId< Class >::operator Value_t ( ) const
inline

Definition at line 52 of file UniqueId.h.

◆ operator<()

template<class Class >
bool RooFit::UniqueId< Class >::operator< ( UniqueId< Class > const &  other) const
inline

Definition at line 62 of file UniqueId.h.

◆ operator=() [1/2]

template<class Class >
UniqueId & RooFit::UniqueId< Class >::operator= ( const UniqueId< Class > &  )
delete

◆ operator=() [2/2]

template<class Class >
UniqueId & RooFit::UniqueId< Class >::operator= ( UniqueId< Class > &&  )
delete

◆ operator==()

template<class Class >
bool RooFit::UniqueId< Class >::operator== ( UniqueId< Class > const &  other) const
inline

Definition at line 61 of file UniqueId.h.

◆ value()

template<class Class >
constexpr Value_t RooFit::UniqueId< Class >::value ( ) const
inlineconstexpr

Return numerical value of ID.

Use only if necessary, as the UniqueId type information is lost and copying/moving is not prohibited for the value type. Please don't turn this into a cast operator, as a function with an explicit name is easier to track in the codebase.

Definition at line 59 of file UniqueId.h.

Member Data Documentation

◆ _val

template<class Class >
Value_t RooFit::UniqueId< Class >::_val
private

The value of the nullid.

Definition at line 68 of file UniqueId.h.

◆ counter

template<class Class >
std::atomic< typename UniqueId< Class >::Value_t > RooFit::UniqueId< Class >::counter {UniqueId<Class>::nullval}
staticprivate

Numerical value of the ID.

Definition at line 70 of file UniqueId.h.

◆ nullid

template<class Class >
const UniqueId< Class > RooFit::UniqueId< Class >::nullid {UniqueId<Class>::nullval}
static

Definition at line 64 of file UniqueId.h.

◆ nullval

template<class Class >
constexpr Value_t RooFit::UniqueId< Class >::nullval = 0UL
staticconstexpr

An ID that is less than the ID of any object (similar to nullptr).

Definition at line 65 of file UniqueId.h.

Collaboration diagram for RooFit::UniqueId< Class >:
[legend]

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