Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooCatTypeLegacy.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooCatType.h,v 1.20 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_CAT_TYPE
17#define ROO_CAT_TYPE
18
19#include "TObject.h"
20#include "RooPrintable.h"
21#include "strlcpy.h"
22
23class RooCatType : public TObject, public RooPrintable {
24public:
26 // Default constructor
27 _value = 0 ; _label[0] = 0 ;
28 }
29
30 inline RooCatType(const char* name, Int_t value) : TObject(), RooPrintable(), _value(value) {
31 // Constructor with state name and index value
32 SetName(name) ;
33 }
34 inline RooCatType(const RooCatType& other) :
35 TObject(other), RooPrintable(other), _value(other._value) {
36 // Copy constructor
37 strlcpy(_label,other._label,256) ;
38 } ;
39
40 TObject* Clone(const char*) const override { return new RooCatType(*this); }
41
42 const Text_t* GetName() const override {
43 // Return state name
44 return _label[0] ? _label : nullptr ;
45 }
46 void SetName(const Text_t* name) ;
47
48 inline RooCatType& operator=(const RooCatType& other) {
49 // Assignment operator from other RooCatType
50 if (&other==this) return *this ;
51 SetName(other.GetName()) ;
52 _value = other._value ;
53 return *this ;
54 }
55
56 inline void assignFast(const RooCatType& other) {
57 // Fast assignment operator from other RooCatType
58 _label[0] = 0 ;
59 _value = other._value ;
60 }
61
62 inline bool operator==(const RooCatType& other) const {
63 // Equality operator with other RooCatType
64 return (_value==other._value) ;
65 }
66
67 inline bool operator==(Int_t index) const {
68 // Return true if index value matches integer
69 return (_value==index) ;
70 }
71
72 bool operator==(const char* label) const {
73 // Return true if state name matchins string
74 return label && !strcmp(_label,label) ;
75 }
76
77 inline Int_t getVal() const {
78 // Return index value
79 return _value ;
80 }
81 void setVal(Int_t newValue) {
82 // Set index value
83 _value = newValue ;
84 }
85
86 void printName(std::ostream& os) const override ;
87 void printTitle(std::ostream& os) const override ;
88 void printClassName(std::ostream& os) const override ;
89 void printValue(std::ostream& os) const override ;
90
91 inline void Print(Option_t *options= nullptr) const override {
92 // Printing interface
94 }
95
96protected:
97
98 friend class RooAbsCategoryLValue ;
99 friend class RooAbsCategory ;
100 Int_t _value ; ///< Index value
101 char _label[256] ; ///< State name
102
103 ClassDefOverride(RooCatType,1) // Category state, (name,index) pair
104} R__SUGGEST_ALTERNATIVE("Instead of RooCatType, directly use the category number returned by RooAbsCategory::getIndex().\n"
105 "Convert it into a name using RooAbsCategory::lookupName(index).");
106
107
108#endif
109
#define R__SUGGEST_ALTERNATIVE(ALTERNATIVE)
Definition RConfig.hxx:512
char Text_t
Definition RtypesCore.h:62
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
Abstract base class for objects that represent a discrete value that can be set from the outside,...
A space to attach TBranches.
RooCatType is an auxiliary class for RooAbsCategory and defines a a single category state.
RooCatType(const RooCatType &other)
bool operator==(Int_t index) const
void printName(std::ostream &os) const override
Print the name of the state.
void printValue(std::ostream &os) const override
Print the value (index integer) of the state.
RooCatType(const char *name, Int_t value)
void printClassName(std::ostream &os) const override
Print the class name of the state.
char _label[256]
State name.
bool operator==(const RooCatType &other) const
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
void assignFast(const RooCatType &other)
void setVal(Int_t newValue)
void SetName(const Text_t *name)
Constructor with name argument.
TObject * Clone(const char *) const override
Make a clone of an object using the Streamer facility.
void printTitle(std::ostream &os) const override
Print the title of the state.
Int_t getVal() const
bool operator==(const char *label) const
const Text_t * GetName() const override
Returns name of object.
Int_t _value
Index value.
RooCatType & operator=(const RooCatType &other)
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
virtual StyleOption defaultPrintStyle(Option_t *opt) const
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
static std::ostream & defaultPrintStream(std::ostream *os=nullptr)
Return a reference to the current default stream to use in Print().
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Mother of all ROOT objects.
Definition TObject.h:41