Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RUnique.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_Browsable_RUnique
10#define ROOT7_Browsable_RUnique
11
13
14namespace ROOT {
15namespace Experimental {
16namespace Browsable {
17
18/** \class RUnique<T>
19\ingroup rbrowser
20\brief Holder of with unique_ptr<T> instance. Should be used to transfer unique_ptr<T> in browsable methods
21\author Sergey Linev <S.Linev@gsi.de>
22\date 2019-10-19
23\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
24*/
25
26template<class T>
27class RUnique : public RHolder {
28 std::unique_ptr<T> fUnique; ///<! holder without IO
29protected:
30 void *TakeObject() final { return fUnique.release(); }
31public:
32 RUnique(T *obj) { fUnique.reset(obj); }
33 RUnique(std::unique_ptr<T> &&obj) { fUnique = std::move(obj); }
34 virtual ~RUnique() = default;
35
36 const TClass *GetClass() const final { return TClass::GetClass<T>(); }
37 const void *GetObject() const final { return fUnique.get(); }
38};
39
40} // namespace Browsable
41} // namespace Experimental
42} // namespace ROOT
43
44
45#endif
Basic class for object holder of any kind.
Definition RHolder.hxx:33
const TClass * GetClass() const final
Returns class of contained object.
Definition RUnique.hxx:36
RUnique(std::unique_ptr< T > &&obj)
Definition RUnique.hxx:33
void * TakeObject() final
Returns pointer with ownership, normally via unique_ptr<T>::release() or tobj->Clone()
Definition RUnique.hxx:30
const void * GetObject() const final
Returns direct (temporary) object pointer.
Definition RUnique.hxx:37
std::unique_ptr< T > fUnique
! holder without IO
Definition RUnique.hxx:28
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...