Logo ROOT   6.14/05
Reference Guide
RooExpensiveObjectCache.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id$
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_EXPENSIVE_OBJECT_CACHE
17 #define ROO_EXPENSIVE_OBJECT_CACHE
18 
19 #include "Rtypes.h"
20 #include "RooArgSet.h"
21 #include "TString.h"
22 #include <list>
23 #include <map>
24 
26 public:
27 
30  virtual ~RooExpensiveObjectCache() ;
31 
32  Bool_t registerObject(const char* ownerName, const char* objectName, TObject& cacheObject, TIterator* paramIter) ;
33  Bool_t registerObject(const char* ownerName, const char* objectName, TObject& cacheObject, const RooArgSet& params) ;
34  const TObject* retrieveObject(const char* name, TClass* tclass, const RooArgSet& params) ;
35 
36  const TObject* getObj(Int_t uniqueID) ;
37  Bool_t clearObj(Int_t uniqueID) ;
38  Bool_t setObj(Int_t uniqueID, TObject* obj) ;
39  void clearAll() ;
40 
41  void importCacheObjects(RooExpensiveObjectCache& other, const char* ownerName, Bool_t verbose=kFALSE) ;
42 
44 
45  Int_t size() const { return _map.size() ; }
46 
47  static void cleanup() ;
48 
49  void print() const ;
50 
52  public:
53  ExpensiveObject() { _uid = 0 ; _payload = 0 ; } ;
54  ExpensiveObject(Int_t uid, const char* ownerName, TObject& payload, TIterator* paramIter) ;
55  ExpensiveObject(Int_t uid, const ExpensiveObject& other) ;
56  virtual ~ExpensiveObject() ;
57  Bool_t matches(TClass* tc, const RooArgSet& params) ;
58 
59  Int_t uid() const { return _uid ; }
60  const TObject* payload() const { return _payload ; }
61  TObject* payload() { return _payload ; }
62  void setPayload(TObject* obj) { _payload = obj ; }
63  const char* ownerName() const { return _ownerName.Data() ; }
64 
65  void print() ;
66 
67  protected:
68 
69  Int_t _uid ; // Unique element ID ;
70  TObject* _payload ; // Payload
71  std::map<TString,Double_t> _realRefParams ; // Names and values of real-valued reference parameters
72  std::map<TString,Int_t> _catRefParams ; // Names and values of discrete-valued reference parameters
73  TString _ownerName ; // Name of RooAbsArg object that is associated to cache contents
74 
75  ClassDef(ExpensiveObject,2) ; // Cache element containing expensive object and parameter values for which object is valid
76 } ;
77 
78 
79 protected:
80 
82 
84 
85  std::map<TString,ExpensiveObject*> _map ;
86 
87 
88  ClassDef(RooExpensiveObjectCache,2) // Singleton class that serves as session repository for expensive objects
89 };
90 
91 #endif
void clearAll()
Clear all cache elements.
static RooExpensiveObjectCache * _instance
Bool_t clearObj(Int_t uniqueID)
Clear cache element with given unique ID Retrieve payload object of cache element with given unique I...
static void cleanup()
Static function called by RooSentinel atexit() handler to cleanup at end of program.
Bool_t matches(TClass *tc, const RooArgSet &params)
Check object type ;.
RooExpensiveObjectCache is a singleton class that serves as repository for objects that are expensive...
std::map< TString, ExpensiveObject * > _map
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual ~RooExpensiveObjectCache()
Destructor.
const TObject * retrieveObject(const char *name, TClass *tclass, const RooArgSet &params)
Retrieve object from cache that was registered under given name with given parameters, if current parameter values match those that were stored in the registry for this object.
Iterator abstract base class.
Definition: TIterator.h:30
#define ClassDef(name, id)
Definition: Rtypes.h:320
void importCacheObjects(RooExpensiveObjectCache &other, const char *ownerName, Bool_t verbose=kFALSE)
std::map< TString, Double_t > _realRefParams
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
Bool_t setObj(Int_t uniqueID, TObject *obj)
Place new payload object in cache element with given unique ID.
static RooExpensiveObjectCache & instance()
Return reference to singleton instance.
const Bool_t kFALSE
Definition: RtypesCore.h:88
Mother of all ROOT objects.
Definition: TObject.h:37
const TObject * getObj(Int_t uniqueID)
Retrieve payload object of cache element with given unique ID.
Bool_t registerObject(const char *ownerName, const char *objectName, TObject &cacheObject, TIterator *paramIter)
Register object associated with given name and given associated parameters with given values in cache...
char name[80]
Definition: TGX11.cxx:109
const char * Data() const
Definition: TString.h:364