List of commits:
Subject Hash Author Date (UTC)
cleanup d4a0e241f80849385bca4323ce28a38788bd03aa Ubuntu 2019-12-23 05:49:59
abstraction complete 210e60e6a600a1a1565a5eba52c9cceb7fc2d108 Ubuntu 2019-12-23 05:48:13
batch is now abstract 681a77dad6a0af7d2b053bdb1f24eda94158828d Ubuntu 2019-12-23 04:23:05
some cleanup 67af884f30b760e6dfeb16866faf180c2f419f3e mucbuc 2019-12-23 02:37:58
tests passing 227d2a97ddcc62abf13835ff77ed2abb55e304ee mucbuc 2019-12-22 21:32:38
some cleanup 32f6958b242ade546d396db1ad593b1b1e864533 mucbuc 2019-12-22 20:02:55
agent 8714f1b8e69d8037fb634fefefa2166cc0d73cc8 mucbuc 2019-12-22 19:56:03
shared_agent b647e38e4bb58096f6c58756dfa2718cacc30e64 mucbuc 2019-12-22 18:56:17
fix compile time error fbc1c35e2389d9fffebe94808385ded809b4061a mucbuc 2019-11-03 00:30:41
cleanup template stuff 4ebc0945d2e8cf2c7a1f75d3dab125b83f76078d mucbuc 2019-11-02 21:09:51
more cleanup bfbe00170ae67ea7e8e1cb23e4e352b18188b5a9 mucbuc 2019-11-02 21:01:10
delete explicit template stuff 1a43665b79bb3df8e28cb7be2d460cbec6cd6a0f mucbuc 2019-11-02 20:55:26
use parameter pack aaff690514d7543a66c285cf9214ebad55c6876e mucbuc 2019-11-02 20:49:43
builds d8412e21c450b8da35dc1f248cb713859bb40c26 mucbuc 2019-11-02 20:26:54
ignore test tmp 0c68fe48a97a80098e224875f1f7aa948a7c6a59 Ubuntu 2018-10-07 09:50:49
plusify 5521f5f65b89bdb2a848d3e497b1c591fe39c15e Ubuntu 2018-10-06 12:18:21
Uni test (#2) 9b73df9337debfea1a000811645609bdd2d8a5ea Mark Busenitz 2018-06-25 10:46:04
license 8e6ee3e912b6273862fbecc34777ef8268ddd5dd mbusenitz 2017-11-21 04:38:04
doc hook (#1) 2d744d1ce1deb15ed20f1d5819de7e2d9230e2c7 Mark Busenitz 2017-03-25 20:27:28
package.json a4c059735b1201b5749b10f758fcfe3561d9ead6 mbusenitz 2017-03-21 04:20:38
Commit d4a0e241f80849385bca4323ce28a38788bd03aa - cleanup
Author: Ubuntu
Author date (UTC): 2019-12-23 05:49
Committer name: Ubuntu
Committer date (UTC): 2019-12-23 05:49
Parent(s): 210e60e6a600a1a1565a5eba52c9cceb7fc2d108
Signer:
Signing key:
Signing status: N
Tree: 6b9ee7faa6d45fda8a57bae9ff3160fb0d445a8f
File Lines added Lines deleted
src/agent.h 2 2
src/batch.h 4 4
src/batch_impl.h 14 16
src/batch_impl.hxx 28 28
src/shared_agent.h 16 17
src/shared_agent.hxx 8 9
File src/agent.h changed (mode: 100644) (index d12808e..eb2e705)
4 4 namespace om636 { namespace om636 {
5 5 namespace control { namespace control {
6 6
7 template <typename ... T>
7 template <typename... T>
8 8 struct Agent { struct Agent {
9 9
10 virtual ~Agent() = default;
10 virtual ~Agent() = default;
11 11 virtual void invoke(T...) = 0; virtual void invoke(T...) = 0;
12 12
13 13 virtual void kill_invoke(T...) = 0; virtual void kill_invoke(T...) = 0;
File src/batch.h changed (mode: 100644) (index e2bceee..630346f)
7 7
8 8 namespace om636 { namespace om636 {
9 9 namespace control { namespace control {
10 template <typename ...T>
10 template <typename... T>
11 11 class Batch { class Batch {
12 12 public: public:
13 13 typedef Agent<T...> agent_type; typedef Agent<T...> agent_type;
14 14
15 15 virtual ~Batch() = default; virtual ~Batch() = default;
16 16 virtual std::shared_ptr<agent_type> hook(std::function<void(T...)>) = 0; virtual std::shared_ptr<agent_type> hook(std::function<void(T...)>) = 0;
17 virtual void unhook() = 0;
18 virtual void traverse(T ...) = 0;
19 virtual void traverse_destructive(T ...) = 0;
17 virtual void unhook() = 0;
18 virtual void traverse(T...) = 0;
19 virtual void traverse_destructive(T...) = 0;
20 20 }; };
21 21
22 22 } //control } //control
File src/batch_impl.h changed (mode: 100644) (index ada1aee..e18169d)
5 5 #include <memory> #include <memory>
6 6 #include <vector> #include <vector>
7 7
8 #include "shared_agent.h"
9 8 #include "batch.h" #include "batch.h"
9 #include "shared_agent.h"
10 10
11 11 namespace om636 { namespace om636 {
12 12 namespace control { namespace control {
13 template <typename ...T>
14 class BatchImpl : public Batch<T...>
15 {
13 template <typename... T>
14 class BatchImpl : public Batch<T...> {
16 15 public: public:
17 16 typedef Batch<T...> base_type; typedef Batch<T...> base_type;
18 using typename base_type::agent_type;
17 using typename base_type::agent_type;
19 18
20 19 BatchImpl() = default; BatchImpl() = default;
21 20 ~BatchImpl() override = default; ~BatchImpl() override = default;
22 21
23 22 std::shared_ptr<agent_type> hook(std::function<void(T...)>) override; std::shared_ptr<agent_type> hook(std::function<void(T...)>) override;
24 23 void unhook() override; void unhook() override;
25 void traverse(T ...) override;
26 void traverse_destructive(T ...) override;
24 void traverse(T...) override;
25 void traverse_destructive(T...) override;
27 26
28 template <typename U, typename V>
29 std::shared_ptr<U> hook(V);
27 template <typename U, typename V>
28 std::shared_ptr<U> hook(V);
30 29
31 30 private: private:
32 typedef std::weak_ptr<agent_type> pointer_type;
31 typedef std::weak_ptr<agent_type> pointer_type;
33 32 typedef std::vector<pointer_type> batch_type; typedef std::vector<pointer_type> batch_type;
34 33 batch_type& elements(); batch_type& elements();
35 34 const batch_type& elements() const; const batch_type& elements() const;
 
... ... namespace control {
42 41
43 42 namespace utils { namespace utils {
44 43
45 template <typename T, typename ... V>
44 template <typename T, typename... V>
46 45 void process_and_kill(T&, V...); void process_and_kill(T&, V...);
47 46
48 template <typename T, typename ... V>
47 template <typename T, typename... V>
49 48 void process(T&, V...); void process(T&, V...);
50 49
51 50 template <typename T> template <typename T>
52 51 void kill_all(T&); void kill_all(T&);
53
54 struct empty_base
55 {
56 virtual ~empty_base() = default;
52
53 struct empty_base {
54 virtual ~empty_base() = default;
57 55 }; };
58 56 } }
59 57
File src/batch_impl.hxx changed (mode: 100644) (index 1942583..84eae8c)
1 1 namespace om636 { namespace om636 {
2 2 namespace control { namespace control {
3 3 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
4 template <typename ...T>
4 template <typename... T>
5 5 auto BatchImpl<T...>::hook(std::function<void(T...)> callback) -> std::shared_ptr<agent_type> auto BatchImpl<T...>::hook(std::function<void(T...)> callback) -> std::shared_ptr<agent_type>
6 6 { {
7 auto agent( std::make_shared<shared_agent<utils::empty_base, T...>>(callback) );
8 m_elements_add.push_back(agent);
9 return agent;
7 auto agent(std::make_shared<shared_agent<utils::empty_base, T...>>(callback));
8 m_elements_add.push_back(agent);
9 return agent;
10 10 } }
11 11
12 12 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
13 template <typename ...T>
13 template <typename... T>
14 14 void BatchImpl<T...>::unhook() void BatchImpl<T...>::unhook()
15 15 { {
16 16 utils::kill_all(elements()); utils::kill_all(elements());
 
... ... namespace control {
18 18 } }
19 19
20 20 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
21 template <typename ...T>
22 void BatchImpl<T...>::traverse(T ... arg)
21 template <typename... T>
22 void BatchImpl<T...>::traverse(T... arg)
23 23 { {
24 24 merge_added_elements(); merge_added_elements();
25 25
26 utils::process(elements(), arg ... );
26 utils::process(elements(), arg...);
27 27 } }
28 28
29 29 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
30 template <typename ...T>
31 void BatchImpl<T...>::traverse_destructive(T ... arg)
30 template <typename... T>
31 void BatchImpl<T...>::traverse_destructive(T... arg)
32 32 { {
33 33 merge_added_elements(); merge_added_elements();
34 34
35 utils::process_and_kill(elements(), arg ...);
35 utils::process_and_kill(elements(), arg...);
36 36 } }
37 37
38 38 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
39 template <typename ...T>
39 template <typename... T>
40 40 auto BatchImpl<T...>::elements() -> batch_type& auto BatchImpl<T...>::elements() -> batch_type&
41 41 { {
42 42 return m_elements; return m_elements;
43 43 } }
44 44
45 45 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
46 template <typename ...T>
46 template <typename... T>
47 47 auto BatchImpl<T...>::elements() const -> const batch_type& auto BatchImpl<T...>::elements() const -> const batch_type&
48 48 { {
49 49 return m_elements; return m_elements;
50 50 } }
51 51
52 52 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
53 template <typename ...T>
53 template <typename... T>
54 54 void BatchImpl<T...>::merge_added_elements() void BatchImpl<T...>::merge_added_elements()
55 55 { {
56 56 elements().insert(elements().end(), m_elements_add.begin(), m_elements_add.end()); elements().insert(elements().end(), m_elements_add.begin(), m_elements_add.end());
 
... ... namespace control {
58 58 } }
59 59
60 60 namespace utils { namespace utils {
61
62 /////////////////////////////////////////////////////////////////////////////////////
63 template <typename T, typename ... V>
64 void process(T& elements, V ... v)
61
62 /////////////////////////////////////////////////////////////////////////////////////
63 template <typename T, typename... V>
64 void process(T& elements, V... v)
65 65 { {
66 66 T copy(elements); T copy(elements);
67 67 for_each(copy.begin(), copy.end(), [&](typename T::value_type p) { for_each(copy.begin(), copy.end(), [&](typename T::value_type p) {
68 68 auto s(p.lock()); auto s(p.lock());
69 if (s && !s->is_dead())
70 s->invoke(v ...);
69 if (s && !s->is_dead())
70 s->invoke(v...);
71 71 //else //else
72 //elements.erase(p);
72 //elements.erase(p);
73 73 }); });
74 74 } }
75 75
76 76 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
77 template <typename T, typename ... V>
78 void process_and_kill(T& elements, V ... v)
77 template <typename T, typename... V>
78 void process_and_kill(T& elements, V... v)
79 79 { {
80 80 T copy(elements); T copy(elements);
81 81 for_each(copy.begin(), copy.end(), [&](typename T::value_type p) { for_each(copy.begin(), copy.end(), [&](typename T::value_type p) {
82 82 auto s(p.lock()); auto s(p.lock());
83 if (s && !s->is_dead())
84 s->kill_invoke(v ...);
83 if (s && !s->is_dead())
84 s->kill_invoke(v...);
85 85 }); });
86 86 elements.clear(); elements.clear();
87 87 } }
 
... ... namespace control {
92 92 { {
93 93 for_each(elements.begin(), elements.end(), [](typename T::value_type p) { for_each(elements.begin(), elements.end(), [](typename T::value_type p) {
94 94 auto s(p.lock()); auto s(p.lock());
95 if (s) {
96 s->kill();
97 }
95 if (s) {
96 s->kill();
97 }
98 98 }); });
99 99 elements.clear(); elements.clear();
100 100 } }
File src/shared_agent.h changed (mode: 100644) (index 429e4d3..aa8158c)
8 8 namespace om636 { namespace om636 {
9 9 namespace control { namespace control {
10 10
11 template<typename T, typename ...U>
12 struct shared_agent : T, Agent<U...>
13 {
14 template<class V>
15 shared_agent(V && cb);
16
17 ~shared_agent() = default;//override = default;
18
19 void invoke(U...) override;
20 void kill_invoke(U...) override;
21 void kill() override;
22 bool is_dead() override;
23
24 private:
25 typedef std::function<void(U...)> callback_type;
26 callback_type m_callback;
27 };
11 template <typename T, typename... U>
12 struct shared_agent : T, Agent<U...> {
13 template <class V>
14 shared_agent(V&& cb);
15
16 ~shared_agent() = default; //override = default;
17
18 void invoke(U...) override;
19 void kill_invoke(U...) override;
20 void kill() override;
21 bool is_dead() override;
22
23 private:
24 typedef std::function<void(U...)> callback_type;
25 callback_type m_callback;
26 };
28 27
29 28 } // control } // control
30 29 } // om636 } // om636
File src/shared_agent.hxx changed (mode: 100644) (index 3afcc97..94871bb)
... ... namespace control {
4 4 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
5 5 // shared_agent // shared_agent
6 6 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
7 template <typename T, typename ...U>
7 template <typename T, typename... U>
8 8 template <typename V> template <typename V>
9 shared_agent<T, U...>::shared_agent(V && callback)
9 shared_agent<T, U...>::shared_agent(V&& callback)
10 10 : m_callback(callback) : m_callback(callback)
11 11 { {
12 12 } }
13 13
14 14 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
15 template <typename T, typename ...U>
16 void shared_agent<T, U...>::invoke(U ... args)
15 template <typename T, typename... U>
16 void shared_agent<T, U...>::invoke(U... args)
17 17 { {
18 18 ASSERT(!is_dead()); ASSERT(!is_dead());
19 19 m_callback(args...); m_callback(args...);
20 20 } }
21 21
22 22 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
23 template <typename T, typename ...U>
24 void shared_agent<T, U...>::kill_invoke(U ... args)
23 template <typename T, typename... U>
24 void shared_agent<T, U...>::kill_invoke(U... args)
25 25 { {
26 26 ASSERT(!is_dead()); ASSERT(!is_dead());
27 27 callback_type temp(m_callback); callback_type temp(m_callback);
 
... ... namespace control {
30 30 } }
31 31
32 32 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
33 template <typename T, typename ...U>
33 template <typename T, typename... U>
34 34 void shared_agent<T, U...>::kill() void shared_agent<T, U...>::kill()
35 35 { {
36 36 m_callback = callback_type(); m_callback = callback_type();
37 37 } }
38 38
39 39 ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
40 template <typename T, typename ...U>
40 template <typename T, typename... U>
41 41 bool shared_agent<T, U...>::is_dead() bool shared_agent<T, U...>::is_dead()
42 42 { {
43 43 return !m_callback; return !m_callback;
 
... ... namespace control {
45 45
46 46 } //control } //control
47 47 } // om636amespace om636 { } // om636amespace om636 {
48
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mucbuc/dynamo

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mucbuc/dynamo

Clone this repository using git:
git clone git://git.rocketgit.com/user/mucbuc/dynamo

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main