16 #ifndef ROOT7_RDirectoryEntry
17 #define ROOT7_RDirectoryEntry
25 namespace Experimental {
29 class RDirectoryEntry {
31 using clock_t = std::chrono::system_clock;
32 using time_point_t = std::chrono::time_point<clock_t>;
35 time_point_t fDate = clock_t::now();
37 std::shared_ptr<void> fObj;
40 RDirectoryEntry(): RDirectoryEntry(nullptr) {}
42 RDirectoryEntry(std::nullptr_t): RDirectoryEntry(std::make_shared<std::nullptr_t>(nullptr)) {}
45 explicit RDirectoryEntry(T *ptr): RDirectoryEntry(std::make_shared<T>(*ptr))
49 explicit RDirectoryEntry(
const std::shared_ptr<T> &ptr): fType(TClass::GetClass<T>()), fObj(ptr)
53 const time_point_t &GetDate()
const {
return fDate; }
57 void SetChanged() { fDate = clock_t::now(); }
60 const std::type_info &GetTypeInfo()
const {
return *fType->GetTypeInfo(); }
63 TClass *GetType()
const {
return fType; }
66 std::shared_ptr<void> &GetPointer() {
return fObj; }
67 const std::shared_ptr<void> &GetPointer()
const {
return fObj; }
70 std::shared_ptr<U> CastPointer()
const;
72 explicit operator bool()
const {
return !!fObj; }
74 void swap(RDirectoryEntry &other) noexcept;
78 std::shared_ptr<U> RDirectoryEntry::CastPointer()
const
80 if (
auto ptr = fType->DynamicCast(TClass::GetClass<U>(), fObj.get()))
81 return std::shared_ptr<U>(fObj,
static_cast<U *
>(ptr));
82 return std::shared_ptr<U>();
85 inline void RDirectoryEntry::swap(RDirectoryEntry &other) noexcept
89 swap(fDate, other.fDate);
90 swap(fType, other.fType);
91 swap(fObj, other.fObj);
94 inline void swap(RDirectoryEntry &e1, RDirectoryEntry &e2) noexcept