-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVerb.hpp
181 lines (147 loc) · 7.49 KB
/
Verb.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
///
/// Langulus::Flow
/// Copyright (c) 2017 Dimo Markov <[email protected]>
/// Part of the Langulus framework, see https://langulus.com
///
/// SPDX-License-Identifier: GPL-3.0-or-later
///
#pragma once
#include "Common.hpp"
#include <Anyness/Verb.hpp>
namespace Langulus::Flow
{
struct Code;
///
/// A type-erased verb
///
/// It's practically a single call to the framework, or a single statement
/// in a code flow. Langulus is based around natural language processing
/// theory found on verbs, so this is the natural name for such thing
///
struct Verb : A::Verb {
LANGULUS(NAME) "Verb";
LANGULUS(ACT_AS) Verb;
LANGULUS_CONVERTS_TO(Code, Text);
LANGULUS_BASES(A::Verb);
///
/// Construction
///
using A::Verb::Verb;
Verb(const Verb&) = default;
Verb(Verb&&) = default;
template<CT::Data T1, CT::Data...TN> requires CT::VerbMakable<T1, TN...>
Verb(T1&&, TN&&...);
template<CT::Verb>
NOD() static Verb From(const Charge& = {}, VerbState = {});
template<CT::Verb>
NOD() static Verb From(CT::UnfoldInsertable auto&&, const Charge& = {}, VerbState = {});
NOD() static Verb FromMeta(VMeta, CT::UnfoldInsertable auto&&, const Charge& = {}, VerbState = {});
NOD() static Verb FromMeta(VMeta, const Charge& = {}, VerbState = {});
template<CT::VerbBased THIS = Verb>
NOD() THIS Fork(auto&&...) const noexcept;
///
/// Assignment
///
using A::Verb::operator =;
Verb& operator = (CT::VerbAssignable auto&&);
template<CT::VerbBased THIS = Verb, CT::Data T1, CT::Data...TN>
requires CT::UnfoldInsertable<T1, TN...>
THIS& SetSource(T1&&, TN&&...);
template<CT::VerbBased THIS = Verb, CT::Data T1, CT::Data...TN>
requires CT::UnfoldInsertable<T1, TN...>
THIS& SetArgument(T1&&, TN&&...);
template<CT::VerbBased THIS = Verb, CT::Data T1, CT::Data...TN>
requires CT::UnfoldInsertable<T1, TN...>
THIS& SetOutput(T1&&, TN&&...);
///
/// Charge arithmetics
///
template<CT::VerbBased THIS = Verb>
THIS operator * (const Verb&) const;
template<CT::VerbBased THIS = Verb>
THIS operator * (Real) const;
template<CT::VerbBased THIS = Verb>
THIS operator ^ (Real) const;
template<CT::VerbBased THIS = Verb>
THIS& operator *= (Real) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& operator ^= (Real) noexcept;
///
/// Capsulation
///
template<CT::VerbBased THIS = Verb>
NOD() Hash GetHash() const;
template<CT::VerbBased THIS = Verb>
THIS& ShortCircuit(bool) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& Multicast(bool) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& SetVerbState(VerbState) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& Invert() noexcept;
template<CT::VerbBased THIS = Verb>
THIS& SetMass(Real) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& SetRate(Real) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& SetTime(Real) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& SetPriority(Real) noexcept;
template<CT::VerbBased THIS = Verb>
THIS& SetCharge(const Charge&) noexcept;
///
/// RTTI
///
template<CT::VerbBased = Verb>
NOD() constexpr Token GetToken() const;
template<CT::VerbBased = Verb>
NOD() constexpr bool IsVerb(VMeta) const noexcept;
template<CT::Verb, CT::VerbBased = Verb>
NOD() constexpr bool IsVerb() const noexcept;
template<CT::VerbBased = Verb>
NOD() constexpr VMeta GetVerb() const noexcept;
template<CT::Verb>
Verb& SetVerb();
LANGULUS_API(FLOW)
Verb& SetVerb(VMeta) noexcept;
///
/// Comparison
///
template<CT::VerbBased = Verb>
NOD() bool operator == (const CT::VerbBased auto&) const;
template<CT::VerbBased = Verb>
NOD() bool operator == (VMeta) const noexcept;
///
/// Insertion
///
template<CT::VerbBased THIS = Verb>
THIS& operator << (CT::UnfoldInsertable auto&&);
template<CT::VerbBased THIS = Verb>
THIS& operator >> (CT::UnfoldInsertable auto&&);
template<CT::VerbBased THIS = Verb>
THIS& operator <<= (CT::UnfoldInsertable auto&&);
template<CT::VerbBased THIS = Verb>
THIS& operator >>= (CT::UnfoldInsertable auto&&);
template<CT::Dense>
bool GenericAvailableFor() const noexcept;
static bool GenericExecuteIn(CT::Dense auto&, CT::VerbBased auto&);
static bool GenericExecuteDefault(Many const&, CT::VerbBased auto&);
static bool GenericExecuteDefault(Many&, CT::VerbBased auto&);
static bool GenericExecuteStateless(CT::VerbBased auto&);
NOD() explicit operator Code() const;
template<bool OR>
Count CompleteDispatch(Count, Abandoned<Many>&&);
///
/// Flow
///
template<CT::VerbBased V>
V& Then(V&) const;
template<CT::VerbBased V>
V& Then(V&);
private:
// Functionality graveyard
using Many::Serialize;
};
/// A handy container for verbs
using Script = TMany<Verb>;
} // namespace Langulus::Flow