/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooCatType.h,v 1.20 2007/05/11 09:11:30 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_CAT_TYPE
#define ROO_CAT_TYPE

#include "Riosfwd.h"
#include "TObject.h"
#include "RooPrintable.h"

class RooCatType : public TObject, public RooPrintable {
public:
  inline RooCatType() : TObject(), RooPrintable() { 
    // Default constructor
    _value = 0 ; _label[0] = 0 ; 
  }
 
  inline RooCatType(const char* name, Int_t value) : TObject(), RooPrintable(), _value(value) { 
    // Constructor with state name and index value
    SetName(name) ; 
  } 
  inline RooCatType(const RooCatType& other) : 
    TObject(other), RooPrintable(other), _value(other._value) { 
    // Copy constructor
    strlcpy(_label,other._label,256) ;
  } ;

  virtual ~RooCatType() {
    // Destructor
  } ;
  virtual TObject* Clone(const char*) const { return new RooCatType(*this); }

  virtual const Text_t* GetName() const { 
    // Return state name
    return _label[0] ? _label : 0 ;
  }
  virtual void SetName(const Text_t* name) ;

  inline RooCatType& operator=(const RooCatType& other) { 
    // Assignment operator from other RooCatType
    if (&other==this) return *this ;
    //SetName(other.GetName()) ; 
    _label[0] = 0 ;
    _value = other._value ; 
    return *this ; } 

  inline void assignFast(const RooCatType& other) { 
    // Fast assignment operator from other RooCatType
    _label[0] = 0 ;
    _value = other._value ; 
  } 

  inline Bool_t operator==(const RooCatType& other) {
    // Equality operator with other RooCatType
    return (_value==other._value) ;
  }

  inline Bool_t operator==(Int_t index) { 
    // Return true if index value matches integer
    return (_value==index) ; 
  }

  Bool_t operator==(const char* label) { 
    // Return true if state name matchins string    
    return !strcmp(_label,label) ; 
  }

  inline Int_t getVal() const { 
    // Return index value
    return _value ; 
  }
  void setVal(Int_t newValue) { 
    // Set index value
  _value = newValue ; 
  }

  virtual void printName(std::ostream& os) const ;
  virtual void printTitle(std::ostream& os) const ;
  virtual void printClassName(std::ostream& os) const ;
  virtual void printValue(std::ostream& os) const ;
  
  inline virtual void Print(Option_t *options= 0) const {
    // Printing interface
    printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
  }

protected:

  friend class RooAbsCategoryLValue ;
  friend class RooAbsCategory ;
  Int_t _value ;     // Index value
  char _label[256] ; // State name
	
  ClassDef(RooCatType,1) // Category state, (name,index) pair
} ;


#endif

 RooCatType.h:1
 RooCatType.h:2
 RooCatType.h:3
 RooCatType.h:4
 RooCatType.h:5
 RooCatType.h:6
 RooCatType.h:7
 RooCatType.h:8
 RooCatType.h:9
 RooCatType.h:10
 RooCatType.h:11
 RooCatType.h:12
 RooCatType.h:13
 RooCatType.h:14
 RooCatType.h:15
 RooCatType.h:16
 RooCatType.h:17
 RooCatType.h:18
 RooCatType.h:19
 RooCatType.h:20
 RooCatType.h:21
 RooCatType.h:22
 RooCatType.h:23
 RooCatType.h:24
 RooCatType.h:25
 RooCatType.h:26
 RooCatType.h:27
 RooCatType.h:28
 RooCatType.h:29
 RooCatType.h:30
 RooCatType.h:31
 RooCatType.h:32
 RooCatType.h:33
 RooCatType.h:34
 RooCatType.h:35
 RooCatType.h:36
 RooCatType.h:37
 RooCatType.h:38
 RooCatType.h:39
 RooCatType.h:40
 RooCatType.h:41
 RooCatType.h:42
 RooCatType.h:43
 RooCatType.h:44
 RooCatType.h:45
 RooCatType.h:46
 RooCatType.h:47
 RooCatType.h:48
 RooCatType.h:49
 RooCatType.h:50
 RooCatType.h:51
 RooCatType.h:52
 RooCatType.h:53
 RooCatType.h:54
 RooCatType.h:55
 RooCatType.h:56
 RooCatType.h:57
 RooCatType.h:58
 RooCatType.h:59
 RooCatType.h:60
 RooCatType.h:61
 RooCatType.h:62
 RooCatType.h:63
 RooCatType.h:64
 RooCatType.h:65
 RooCatType.h:66
 RooCatType.h:67
 RooCatType.h:68
 RooCatType.h:69
 RooCatType.h:70
 RooCatType.h:71
 RooCatType.h:72
 RooCatType.h:73
 RooCatType.h:74
 RooCatType.h:75
 RooCatType.h:76
 RooCatType.h:77
 RooCatType.h:78
 RooCatType.h:79
 RooCatType.h:80
 RooCatType.h:81
 RooCatType.h:82
 RooCatType.h:83
 RooCatType.h:84
 RooCatType.h:85
 RooCatType.h:86
 RooCatType.h:87
 RooCatType.h:88
 RooCatType.h:89
 RooCatType.h:90
 RooCatType.h:91
 RooCatType.h:92
 RooCatType.h:93
 RooCatType.h:94
 RooCatType.h:95
 RooCatType.h:96
 RooCatType.h:97
 RooCatType.h:98
 RooCatType.h:99
 RooCatType.h:100
 RooCatType.h:101
 RooCatType.h:102
 RooCatType.h:103
 RooCatType.h:104
 RooCatType.h:105
 RooCatType.h:106
 RooCatType.h:107
 RooCatType.h:108
 RooCatType.h:109
 RooCatType.h:110
 RooCatType.h:111