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 Browsable {
16
17/** \class RUnique<T>
18\ingroup rbrowser
19\brief Holder of with unique_ptr<T> instance. Should be used to transfer unique_ptr<T> in browsable methods
20\author Sergey Linev <S.Linev@gsi.de>
21\date 2019-10-19
22\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
23*/
24
25template<class T>
26class RUnique : public RHolder {
27 std::unique_ptr<T> fUnique; ///<! holder without IO
28protected:
29 void *TakeObject() final { return fUnique.release(); }
30public:
31 RUnique(T *obj) { fUnique.reset(obj); }
32 RUnique(std::unique_ptr<T> &&obj) { fUnique = std::move(obj); }
33 virtual ~RUnique() = default;
34
35 const TClass *GetClass() const final { return TClass::GetClass<T>(); }
36 const void *GetObject() const final { return fUnique.get(); }
37};
38
39} // namespace Browsable
40} // namespace ROOT
41
42
43#endif
Basic class for object holder of any kind.
Definition RHolder.hxx:35
RUnique(std::unique_ptr< T > &&obj)
Definition RUnique.hxx:32
const void * GetObject() const final
Returns direct (temporary) object pointer.
Definition RUnique.hxx:36
void * TakeObject() final
Returns pointer with ownership, normally via unique_ptr<T>::release() or tobj->Clone()
Definition RUnique.hxx:29
virtual ~RUnique()=default
const TClass * GetClass() const final
Returns class of contained object.
Definition RUnique.hxx:35
std::unique_ptr< T > fUnique
! holder without IO
Definition RUnique.hxx:27
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...