11 #ifndef ROOT_TRESULTPROXY 12 #define ROOT_TRESULTPROXY 21 namespace Experimental {
38 namespace Experimental {
65 template <typename V, bool isCont = TDFInternal::TIsContainer<V>::fgValue>
66 struct TIterationHelper {
67 using Iterator_t =
void;
68 void GetBegin(
const V &) { static_assert(
sizeof(V) == 0,
"It does not make sense to ask begin for this class."); }
69 void GetEnd(
const V &) { static_assert(
sizeof(V) == 0,
"It does not make sense to ask end for this class."); }
73 struct TIterationHelper<V, true> {
74 using Iterator_t = decltype(std::begin(std::declval<V>()));
75 static Iterator_t GetBegin(
const V &
v) {
return std::begin(v); };
76 static Iterator_t GetEnd(
const V &
v) {
return std::end(v); };
79 using SPT_t = std::shared_ptr<T>;
80 using SPTLM_t = std::shared_ptr<TDFDetail::TLoopManager>;
81 using WPTLM_t = std::weak_ptr<TDFDetail::TLoopManager>;
87 std::make_shared<bool>(
false);
99 if (!*fReadiness) TriggerRun();
100 return fObjPtr.get();
104 : fReadiness(readiness), fImplWeakPtr(firstData), fObjPtr(objPtr)
129 typename TIterationHelper<T>::Iterator_t
begin()
131 if (!*fReadiness) TriggerRun();
132 return TIterationHelper<T>::GetBegin(*fObjPtr);
137 typename TIterationHelper<T>::Iterator_t
end()
139 if (!*fReadiness) TriggerRun();
140 return TIterationHelper<T>::GetEnd(*fObjPtr);
144 template <
typename T>
147 auto df = fImplWeakPtr.lock();
149 throw std::runtime_error(
"The main TDataFrame is not reachable: did it go out of scope?");
158 template <
typename T>
161 auto readiness = std::make_shared<bool>(
false);
170 #endif // ROOT_TRESULTPROXY const T & GetValue()
Get a const reference to the encapsulated object.
Namespace for new ROOT classes and functions.
std::shared_ptr< TDFDetail::TLoopManager > SPTLM_t
T * Get()
Get the pointer to the encapsulated result.
std::weak_ptr< TDFDetail::TLoopManager > WPTLM_t
WPTLM_t fImplWeakPtr
Points to the TLoopManager at the root of the functional graph.
Smart pointer for the return type of actions.
SPT_t fObjPtr
Shared pointer encapsulating the wrapped result.
TResultProxy(const SPT_t &objPtr, const ShrdPtrBool_t &readiness, const SPTLM_t &firstData)
TIterationHelper< T >::Iterator_t begin()
Return an iterator to the beginning of the contained object if this makes sense, throw a compilation ...
std::shared_ptr< T > SPT_t
TResultProxy< T > MakeResultProxy(const std::shared_ptr< T > &r, const std::shared_ptr< TLoopManager > &df)
T * operator->()
Get a pointer to the encapsulated object.
std::shared_ptr< bool > ShrdPtrBool_t
void TriggerRun()
Triggers the event loop in the TLoopManager instance to which it's associated via the fImplWeakPtr...
T & operator*()
Get a pointer to the encapsulated object.
typedef void((*Func_t)())
TIterationHelper< T >::Iterator_t end()
Return an iterator to the end of the contained object if this makes sense, throw a compilation error ...