Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TVirtualObject.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/io:$Id$
0002 // Author: Philippe Canal July, 2008
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010   *************************************************************************/
0011 
0012 #ifndef ROOT_TVirtualObject
0013 #define ROOT_TVirtualObject
0014 
0015 /**
0016 \class TVirtualObject
0017 \ingroup IO
0018 
0019 Wrapper around an object and giving indirect access to its content
0020 even if the object is not of a class in the Cint/Reflex dictionary.
0021 */
0022 
0023 #include "TClassRef.h"
0024 
0025 
0026 class TVirtualObject {
0027 private:
0028 
0029    TVirtualObject(const TVirtualObject&) = delete;
0030    TVirtualObject &operator=(const TVirtualObject&) = delete;
0031 
0032 public:
0033    TClassRef  fClass;
0034    void      *fObject;
0035 
0036    TVirtualObject(TClass *cl) : fClass(cl), fObject(cl ? cl->New() : nullptr) { }
0037    ~TVirtualObject() { if (fClass) fClass->Destructor(fObject); }
0038 
0039 
0040    TClass *GetClass() const { return fClass; }
0041    void   *GetObject() const { return fObject; }
0042 
0043 };
0044 
0045 #endif // ROOT_TVirtualObject