File indexing completed on 2025-01-18 10:10:30
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT7_Browsable_RAnyObjectHolder
0010 #define ROOT7_Browsable_RAnyObjectHolder
0011
0012 #include <ROOT/Browsable/RHolder.hxx>
0013
0014 namespace ROOT {
0015 namespace Browsable {
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 class RAnyObjectHolder : public RHolder {
0026 TClass *fClass{nullptr};
0027 void *fObj{nullptr};
0028 bool fOwner{false};
0029 protected:
0030 void *AccessObject() final { return fOwner ? nullptr : fObj; }
0031
0032 void *TakeObject() final
0033 {
0034 if (!fOwner)
0035 return nullptr;
0036 auto res = fObj;
0037 fObj = nullptr;
0038 fOwner = false;
0039 return res;
0040 }
0041
0042 RHolder* DoCopy() const final
0043 {
0044 if (fOwner || !fObj || !fClass) return nullptr;
0045 return new RAnyObjectHolder(fClass, fObj, false);
0046 }
0047
0048 public:
0049 RAnyObjectHolder(TClass *cl, void *obj, bool owner = false) { fClass = cl; fObj = obj; fOwner = owner; }
0050 virtual ~RAnyObjectHolder()
0051 {
0052 if (fOwner)
0053 fClass->Destructor(fObj);
0054 }
0055
0056 void Forget() final
0057 {
0058 fClass = nullptr;
0059 fObj = nullptr;
0060 fOwner = false;
0061 }
0062
0063 const TClass *GetClass() const final { return fClass; }
0064 const void *GetObject() const final { return fObj; }
0065 };
0066
0067
0068 }
0069 }
0070
0071
0072 #endif