Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNameReg.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooNameReg.h,v 1.3 2007/05/11 09:11:30 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_NAME_REG
17#define ROO_NAME_REG
18
19#include "TNamed.h"
20
21#include <memory>
22#include <unordered_map>
23#include <string>
24
25// String name registry
26class RooNameReg : public TNamed {
27public:
28
29 RooNameReg(const RooNameReg& other) = delete;
30
31 static RooNameReg& instance() ;
32 const TNamed* constPtr(const char* stringPtr) ;
33 /// Return C++ string corresponding to given TNamed pointer.
34 inline static const char* constStr(const TNamed* ptr) {
35 return ptr ? ptr->GetName() : nullptr;
36 }
37 static const TNamed* ptr(const char* stringPtr) ;
38 /// Return C++ string corresponding to given TNamed pointer.
39 inline static const char* str(const TNamed* ptr) {
40 return ptr ? ptr->GetName() : nullptr;
41 }
42 static const TNamed* known(const char* stringPtr) ;
43 static const std::size_t& renameCounter() ;
44
45 enum {
46 kRenamedArg = BIT(19) ///< TNamed flag to indicate that some RooAbsArg has been renamed (flag set in new name)
47 };
48
49protected:
50 RooNameReg();
51
52 friend class RooAbsArg;
53 friend class RooAbsData;
54 static void incrementRenameCounter() ;
55
56 std::unordered_map<std::string,std::unique_ptr<TNamed>> _map;
57 std::size_t _renameCounter = 0;
58};
59
60#endif
61
62
#define BIT(n)
Definition Rtypes.h:85
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Registry for const char* names.
Definition RooNameReg.h:26
RooNameReg(const RooNameReg &other)=delete
std::unordered_map< std::string, std::unique_ptr< TNamed > > _map
Definition RooNameReg.h:56
static const char * constStr(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
Definition RooNameReg.h:34
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
Definition RooNameReg.h:39
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
std::size_t _renameCounter
Definition RooNameReg.h:57
const TNamed * constPtr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
static RooNameReg & instance()
Return reference to singleton instance.
@ kRenamedArg
TNamed flag to indicate that some RooAbsArg has been renamed (flag set in new name)
Definition RooNameReg.h:46
static const TNamed * known(const char *stringPtr)
If the name is already known, return its TNamed pointer. Otherwise return 0 (don't register the name)...
static void incrementRenameCounter()
The renaming counter has to be incremented every time a RooAbsArg is renamed.
static const std::size_t & renameCounter()
renamed in this RooFit process.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47