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