Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TVirtualObject.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Philippe Canal July, 2008
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TVirtualObject
13 #define ROOT_TVirtualObject
14 
15 /**
16 \class TVirtualObject
17 \ingroup IO
18 
19 Wrapper around an object and giving indirect access to its content
20 even if the object is not of a class in the Cint/Reflex dictionary.
21 */
22 
23 #include "TClassRef.h"
24 
25 
26 class TVirtualObject {
27 private:
28 
29  TVirtualObject(const TVirtualObject&) = delete; // not implemented
30  TVirtualObject &operator=(const TVirtualObject&) = delete; // not implemented
31 
32 public:
33  TClassRef fClass;
34  void *fObject;
35 
36  TVirtualObject(TClass *cl) : fClass(cl), fObject(cl ? cl->New() : 0) { }
37  ~TVirtualObject() { if (fClass) fClass->Destructor(fObject); }
38 
39 
40  TClass *GetClass() const { return fClass; }
41  void *GetObject() const { return fObject; }
42 
43 };
44 
45 #endif // ROOT_TVirtualObject