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 Member Functions

static UniqueId const & nullid ()
 Get an ID that is less than the ID of any object (similar to nullptr).
 

Static Public Attributes

static constexpr Value_t nullval = 0UL
 The value of the nullid.
 

Private Member Functions

 UniqueId (Value_t val)
 

Private Attributes

Value_t _val
 Numerical value of the ID.
 

Static Private Attributes

static std::atomic< Value_tcounter {UniqueId<Class>::nullval}
 The static object counter to get the next ID value.
 

#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/4]

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/4]

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

◆ UniqueId() [3/4]

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

◆ UniqueId() [4/4]

template<class Class >
RooFit::UniqueId< Class >::UniqueId ( Value_t  val)
inlineprivate

Definition at line 74 of file UniqueId.h.

Member Function Documentation

◆ nullid()

template<class Class >
static UniqueId const & RooFit::UniqueId< Class >::nullid ( )
inlinestatic

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

Definition at line 65 of file UniqueId.h.

◆ 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

Numerical value of the ID.

Definition at line 76 of file UniqueId.h.

◆ counter

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

The static object counter to get the next ID value.

Definition at line 78 of file UniqueId.h.

◆ nullval

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

The value of the nullid.

Definition at line 71 of file UniqueId.h.

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

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