-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e1b6ed
commit 165c235
Showing
28 changed files
with
257 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,39 @@ | ||
// | ||
// Created by tanneberger on 11/17/24. | ||
// | ||
|
||
#ifndef CONSUMER_HH | ||
#define CONSUMER_HH | ||
#ifndef CONSUMER_HH //NOLINT | ||
#define CONSUMER_HH //NOLINT | ||
|
||
#include <reactor-cpp/reactor-cpp.hh> | ||
|
||
using namespace reactor; | ||
using namespace std::chrono_literals; | ||
|
||
class Consumer : public Reactor { | ||
private: | ||
class Inner: public Scope { | ||
Inner(Reactor* reactor, std::size_t index) : Scope(reactor), index_(index) {} | ||
std::size_t index_; | ||
|
||
[[maybe_unused]] const Inner& __lf_inner = *this; | ||
class Consumer final: public Reactor { // NOLINT | ||
class Inner : public Scope { | ||
Inner(Reactor* reactor, std::size_t index) | ||
: Scope(reactor) | ||
, index_(index) {} | ||
std::size_t index_ = 0; | ||
|
||
void reaction_1([[maybe_unused]] const Input<unsigned>& in) { | ||
std::cout << "consumer: " << index_ << " received value:" << *in.get() << std::endl; | ||
void reaction_1(const Input<unsigned>& in) const { | ||
std::cout << "consumer: " << index_ << " received value:" << *in.get() << '\n'; | ||
} | ||
|
||
friend Consumer; | ||
}; | ||
|
||
Inner __lf_inner; | ||
Reaction handle{"handle", 1, this, [this]() { __lf_inner.reaction_1(this->in); }}; | ||
Inner _lf_inner; | ||
Reaction handle{"handle", 1, this, [this]() { _lf_inner.reaction_1(this->in); }}; | ||
|
||
public: | ||
Consumer(const std::string& name, Environment* env, std::size_t index) : Reactor(name, env), __lf_inner(this, index) { | ||
std::cout << "creating instance of consumer" << std::endl; | ||
Consumer(const std::string& name, Environment* env, std::size_t index) | ||
: Reactor(name, env) | ||
, _lf_inner(this, index) { | ||
std::cout << "creating instance of consumer" << '\n'; | ||
} | ||
~Consumer() override { | ||
std::cout << "Consumer Object is deleted" << std::endl; | ||
}; | ||
~Consumer() override { std::cout << "Consumer Object is deleted" << '\n'; }; | ||
|
||
Input<unsigned> in{"in", this}; | ||
Input<unsigned> in{"in", this}; //NOLINT | ||
|
||
void assemble() override { | ||
handle.declare_trigger(&in); | ||
} | ||
void assemble() override { handle.declare_trigger(&in); } | ||
}; | ||
|
||
|
||
#endif //CONSUMER_HH | ||
#endif // CONSUMER_HH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.