1+ // /
2+ // / Langulus::Flow
3+ // / Copyright (c) 2017 Dimo Markov <team@langulus.com>
4+ // / Part of the Langulus framework, see https://langulus.com
5+ // /
6+ // / SPDX-License-Identifier: GPL-3.0-or-later
7+ // /
8+ #pragma once
9+ #include " Producible.hpp"
10+
11+
12+ namespace Langulus ::Flow
13+ {
14+
15+ // / Move a produced item
16+ // / @param other - the item to move
17+ template <class T > LANGULUS (INLINED)
18+ ProducedFrom<T>::ProducedFrom(ProducedFrom&& other)
19+ : ProducedFrom {Move (other)} {}
20+
21+ // / Generic construction
22+ // / @param other - intent and element to initialize with
23+ template <class T > template <template <class > class S > LANGULUS (INLINED)
24+ ProducedFrom<T>::ProducedFrom(S<ProducedFrom>&& other)
25+ requires CT::Intent<S<ProducedFrom>>
26+ // mProducer intentionally not overwritten
27+ : mDescriptor {other.Nest (other->mDescriptor )} {}
28+
29+ // / Construct a produced item
30+ // / @param producer - the item's producer
31+ // / @param descriptor - the item's neat descriptor
32+ template <class T > LANGULUS (INLINED)
33+ ProducedFrom<T>::ProducedFrom(T* producer, const Many& descriptor)
34+ : mDescriptor {descriptor}
35+ , mProducer {producer} {}
36+
37+ // / Get the normalized descriptor of the produced item
38+ // / @return the normalized descriptor
39+ template <class T > LANGULUS (INLINED)
40+ auto ProducedFrom<T>::GetDescriptor() const noexcept -> const Many& {
41+ return mDescriptor ;
42+ }
43+
44+ // / Get the hash of the normalized descriptor (cached and efficient)
45+ // / @return the hash
46+ template <class T > LANGULUS (INLINED)
47+ Hash ProducedFrom<T>::GetHash() const noexcept {
48+ return mDescriptor .GetHash ();
49+ }
50+
51+ // / Return the producer of the item (a.k.a. the owner of the factory)
52+ // / @return a pointer to the producer instance
53+ template <class T > LANGULUS (INLINED)
54+ auto ProducedFrom<T>::GetProducer() const noexcept -> const Ref<T>& {
55+ return mProducer ;
56+ }
57+
58+ // / Return the producer of the item (a.k.a. the owner of the factory)
59+ // / @return a pointer to the producer instance
60+ template <class T > LANGULUS (INLINED)
61+ void ProducedFrom<T>::TeardownInner() {
62+ mDescriptor .Reset ();
63+ mProducer .Reset ();
64+ }
65+
66+ } // namespace Langulus::Flow
0 commit comments