ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/ObjectService/interface/NamedObject.h
Revision: 1.1
Committed: Wed Jul 30 09:04:39 2008 UTC (16 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
Log Message:
Start of ObjectService.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: ObjectService.h,v 1.7 2008/07/03 08:25:12 loizides Exp $
3 //
4 // ObjectService
5 // Class for storing event objects:
6 // It assumes ownership of the object.
7 // It is needed to force the THashTable to call Hash on a TNamed
8 // to allow lookup using the hash value given the object's name
9 // (as opposed to its pointer value, as is done for TObject's).
10 //
11 //
12 // Authors: C.Loizides
13 //--------------------------------------------------------------------------------------------------
14
15 #ifndef MITPROD_NAMEDOBJECT_H
16 #define MITPROD_NAMEDOBJECT_H
17
18 #include <TNamed.h>
19
20 namespace mithep
21 {
22 template<class T>
23 class NamedObject : public TNamed
24 {
25 public:
26 NamedObject(T *ptr) : TNamed(((TObject*)ptr)->GetName(),0), fPtr(ptr) {}
27 NamedObject(T *ptr, const char *n) : TNamed(n,0), fPtr(ptr) {}
28 ~NamedObject() { delete fPtr; }
29 T *Get() { return fPtr; }
30 const T *Get() const { return fPtr; }
31
32 private:
33 T *fPtr; //pointer to object
34 };
35 }
36 #endif