Logo ROOT  
Reference Guide
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 
23 class RooCatType : public TObject, public RooPrintable {
24 public:
25  inline RooCatType() : TObject(), RooPrintable() {
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  virtual ~RooCatType() {
41  // Destructor
42  } ;
43  virtual TObject* Clone(const char*) const { return new RooCatType(*this); }
44 
45  virtual const Text_t* GetName() const {
46  // Return state name
47  return _label[0] ? _label : 0 ;
48  }
49  void SetName(const Text_t* name) ;
50 
51  inline RooCatType& operator=(const RooCatType& other) {
52  // Assignment operator from other RooCatType
53  if (&other==this) return *this ;
54  SetName(other.GetName()) ;
55  _value = other._value ;
56  return *this ;
57  }
58 
59  inline void assignFast(const RooCatType& other) {
60  // Fast assignment operator from other RooCatType
61  _label[0] = 0 ;
62  _value = other._value ;
63  }
64 
65  inline Bool_t operator==(const RooCatType& other) const {
66  // Equality operator with other RooCatType
67  return (_value==other._value) ;
68  }
69 
70  inline Bool_t operator==(Int_t index) const {
71  // Return true if index value matches integer
72  return (_value==index) ;
73  }
74 
75  Bool_t operator==(const char* label) const {
76  // Return true if state name matchins string
77  return label && !strcmp(_label,label) ;
78  }
79 
80  inline Int_t getVal() const {
81  // Return index value
82  return _value ;
83  }
84  void setVal(Int_t newValue) {
85  // Set index value
86  _value = newValue ;
87  }
88 
89  virtual void printName(std::ostream& os) const ;
90  virtual void printTitle(std::ostream& os) const ;
91  virtual void printClassName(std::ostream& os) const ;
92  virtual void printValue(std::ostream& os) const ;
93 
94  inline virtual void Print(Option_t *options= 0) const {
95  // Printing interface
97  }
98 
99 protected:
100 
101  friend class RooAbsCategoryLValue ;
102  friend class RooAbsCategory ;
103  Int_t _value ; // Index value
104  char _label[256] ; // State name
105 
106  ClassDef(RooCatType,1) // Category state, (name,index) pair
107 } R__SUGGEST_ALTERNATIVE("Instead of RooCatType, directly use the category number returned by RooAbsCategory::getIndex().\n"
108  "Convert it into a name using RooAbsCategory::lookupName(index).");
109 
110 
111 #endif
112 
RooCatType::Clone
virtual TObject * Clone(const char *) const
Make a clone of an object using the Streamer facility.
Definition: RooCatTypeLegacy.h:43
Option_t
const char Option_t
Definition: RtypesCore.h:66
RooCatType::GetName
virtual const Text_t * GetName() const
Returns name of object.
Definition: RooCatTypeLegacy.h:45
RooCatType::getVal
Int_t getVal() const
Definition: RooCatTypeLegacy.h:80
RooCatType::printName
virtual void printName(std::ostream &os) const
Print the name of the state.
Definition: RooCatTypeLegacy.cxx:60
RooPrintable.h
RooCatType::printClassName
virtual void printClassName(std::ostream &os) const
Print the class name of the state.
Definition: RooCatTypeLegacy.cxx:80
R__SUGGEST_ALTERNATIVE
#define R__SUGGEST_ALTERNATIVE(ALTERNATIVE)
Definition: RConfig.hxx:530
RooCatType::_value
Int_t _value
Definition: RooCatTypeLegacy.h:103
RooCatType::RooCatType
RooCatType(const RooCatType &other)
Definition: RooCatTypeLegacy.h:34
RooPrintable
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
Definition: RooPrintable.h:25
bool
RooCatType::printTitle
virtual void printTitle(std::ostream &os) const
Print the title of the state.
Definition: RooCatTypeLegacy.cxx:70
RooAbsCategory
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
Definition: RooAbsCategory.h:38
RooCatType::SetName
void SetName(const Text_t *name)
Constructor with name argument.
Definition: RooCatTypeLegacy.cxx:46
RooPrintable::defaultPrintContents
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
Definition: RooPrintable.cxx:233
RooCatType::operator=
RooCatType & operator=(const RooCatType &other)
Definition: RooCatTypeLegacy.h:51
RooPrintable::defaultPrintStream
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
Definition: RooPrintable.cxx:272
RooCatType::assignFast
void assignFast(const RooCatType &other)
Definition: RooCatTypeLegacy.h:59
RooCatType::setVal
void setVal(Int_t newValue)
Definition: RooCatTypeLegacy.h:84
RooCatType::operator==
Bool_t operator==(const char *label) const
Definition: RooCatTypeLegacy.h:75
RooCatType::operator==
Bool_t operator==(Int_t index) const
Definition: RooCatTypeLegacy.h:70
RooCatType::printValue
virtual void printValue(std::ostream &os) const
Print the value (index integer) of the state.
Definition: RooCatTypeLegacy.cxx:90
TObject.h
RooCatType::RooCatType
RooCatType(const char *name, Int_t value)
Definition: RooCatTypeLegacy.h:30
RooCatType::_label
char _label[256]
Definition: RooCatTypeLegacy.h:104
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
RooCatType::RooCatType
RooCatType()
Definition: RooCatTypeLegacy.h:25
RooCatType
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
Definition: RooCatTypeLegacy.h:23
RooPrintable::printStream
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,...
Definition: RooPrintable.cxx:75
RooCatType::operator==
Bool_t operator==(const RooCatType &other) const
Definition: RooCatTypeLegacy.h:65
RooCatType::~RooCatType
virtual ~RooCatType()
Definition: RooCatTypeLegacy.h:40
Text_t
char Text_t
Definition: RtypesCore.h:62
RooAbsCategoryLValue
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Definition: RooAbsCategoryLValue.h:25
RooPrintable::defaultPrintStyle
virtual StyleOption defaultPrintStyle(Option_t *opt) const
Definition: RooPrintable.cxx:241
RooCatType::Print
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
Definition: RooCatTypeLegacy.h:94
int