tbaseConvergence.hpp
Go to the documentation of this file.
1
2#pragma once
3
8
9namespace by {
10
11 template <typename T> struct ConvergenceClosure {
12 typedef std::function<nbool(const T&)> is;
13 };
14
15 template <> struct ConvergenceClosure<void> {
16 typedef std::function<nbool()> is;
17 };
18
19 template <typename T> class tbaseConvergence: public baseConvergence {
21
22 protected:
23 using onConverge = typename ConvergenceClosure<T>::is;
24
25 public:
27 _obj(obj), _func(func), _onConverge(closure) {}
28
29 public:
44 nbool converge() override {
45 WHEN(!_obj) .ret(false);
46 baseFunc& fun = _func OR.ret(false);
47
48 frameInteract objScope(*_obj);
49 frameInteract funScope(fun);
50 return convergeWithoutFrame();
51 }
52
53 baseFunc& getFunc() { return *_func; }
54
55 const baseFunc& getFunc() const BY_CONST_FUNC(getFunc());
56
57 baseObj& getObj() { return *_obj; }
58
59 const baseObj& getObj() const BY_CONST_FUNC(getObj());
60
61 protected:
62 onConverge _getClosure() { return _onConverge; }
63
64 private:
65 tstr<baseObj> _obj;
66 tstr<baseFunc> _func;
67 onConverge _onConverge;
68 };
69} // namespace by
Base class for convergence algorithms.
Definition: baseConvergence.hpp:10
Base class for all function types.
Definition: baseFunc.hpp:18
Base class for all objects in byeol language.
Definition: baseObj.hpp:24
func closure with captured object scope
Definition: closure.hpp:19
Definition: frameInteract.hpp:8
Function definition in byeol language.
Definition: func.hpp:20
Managed object in byeol programming environment.
Definition: obj.hpp:19
Definition: tbaseConvergence.hpp:19
nbool converge() override
Definition: tbaseConvergence.hpp:44
Definition: tbaseConvergence.hpp:11