// @(#)root/hist:$Id$
// Author: Marian Ivanov, 2005

/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
* All rights reserved.                                                  *
*                                                                       *
* For the licensing terms see $ROOTSYS/LICENSE.                         *
* For the list of contributors see $ROOTSYS/README/CREDITS.             *
*************************************************************************/
// ---------------------------------- TFormulaPrimitive.h

#ifndef ROOT_TFormulaPrimitive
#define ROOT_TFormulaPrimitive



//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TFormulaPrimitive                                                    //
//                                                                      //
// The formula primitive base class                                     //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TBits
#include "TBits.h"
#endif
#ifndef ROOT_TObjArray
#include "TObjArray.h"
#endif

class TFormula;

class TFormulaPrimitive : public TNamed
{
   friend class TFormula;
public:
   typedef Double_t (*GenFuncG)(const Double_t*,const Double_t*);
   typedef Double_t (*GenFunc0)();
   typedef Double_t (*GenFunc10)(Double_t);
   typedef Double_t (*GenFunc110)(Double_t,Double_t);
   typedef Double_t (*GenFunc1110)(Double_t,Double_t, Double_t);
   typedef Double_t (TObject::*TFuncG)(const Double_t*,const Double_t*) const;
   typedef Double_t (TObject::*TFunc0)() const;
   typedef Double_t (TObject::*TFunc10)(Double_t) const;
   typedef Double_t (TObject::*TFunc110)(Double_t,Double_t) const;
   typedef Double_t (TObject::*TFunc1110)(Double_t,Double_t,Double_t) const;
protected:
   static TObjArray * fgListOfFunction;                   //!list of global primitive formulas
   static Int_t       BuildBasicFormulas();               //build list of basic formulas
   union {
      GenFuncG    fFuncG;                                 //!pointer to the TFormula generic function
      GenFunc0    fFunc0;                                 //!pointer to the function
      GenFunc10   fFunc10;                                //!pointer to the function
      GenFunc110  fFunc110;                               //!pointer to the function
      GenFunc1110 fFunc1110;                              //!pointer to the function
      TFuncG      fTFuncG;                                //!pointer to the TFormula generic function
      TFunc0      fTFunc0;                                //! pointer to member function
      TFunc10     fTFunc10;                               //! pointer to member function
      TFunc110    fTFunc110;                              //! pointer to member function
      TFunc1110   fTFunc1110;                             //! pointer to member function
   };
   Int_t      fType;                                      //type of the function
   Int_t      fNArguments;                                //number of arguments
   Int_t      fNParameters;                               //number of parameters
   Bool_t     fIsStatic;                                  // indication if the function is static
private:
   TFormulaPrimitive(const TFormulaPrimitive&); // Not implemented
   TFormulaPrimitive& operator=(const TFormulaPrimitive&); // Not implemented
public:
   TFormulaPrimitive();
   TFormulaPrimitive(const char *name,const char *formula, GenFunc0 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, GenFunc10 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, GenFunc110 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, GenFunc1110 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, GenFuncG fpointer,Int_t npar);
   TFormulaPrimitive(const char *name,const char *formula, TFunc0 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, TFunc10 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, TFunc110 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, TFunc1110 fpointer);
   TFormulaPrimitive(const char *name,const char *formula, TFuncG fpointer);
   static Int_t AddFormula(TFormulaPrimitive * formula);
   static TFormulaPrimitive* FindFormula(const char* name);
   static TFormulaPrimitive* FindFormula(const char* name, const char *args);
   static TFormulaPrimitive* FindFormula(const char* name, UInt_t nargs);
   Double_t Eval(Double_t* x);                   //eval primitive function
   Double_t Eval(TObject *o,  Double_t *x);      //eval member function
   Double_t Eval(Double_t *x, Double_t *param);  //eval primitive parametric function

   ClassDef(TFormulaPrimitive,0)  //The primitive formula
};

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