add Env and Lambda

This commit is contained in:
falsycat 2023-07-21 06:28:36 +09:00
parent 0ffac63089
commit 09320615b9
4 changed files with 78 additions and 0 deletions

View File

@ -15,6 +15,9 @@ target_sources(nf7_iface
common/observer.hh
common/task.hh
common/value.hh
subsys/interface.hh
env.hh
lambda.hh
version.hh
)

11
iface/env.hh Normal file
View File

@ -0,0 +1,11 @@
// No copyright
#pragma once
#include "iface/common/container.hh"
#include "iface/subsys/interface.hh"
namespace nf7 {
using Env = Container<subsys::Interface>;
} // namespace nf7

40
iface/lambda.hh Normal file
View File

@ -0,0 +1,40 @@
// No copyright
#pragma once
#include <memory>
#include <span>
#include <utility>
#include <vector>
#include "iface/common/dealer.hh"
#include "iface/common/value.hh"
namespace nf7 {
class Lambda {
public:
Lambda() = delete;
Lambda(std::vector<std::shared_ptr<Taker<Value>>>&& takers,
std::vector<std::shared_ptr<Maker<Value>>>&& makers) noexcept
: takers_(std::move(takers)), makers_(makers) {
}
virtual ~Lambda() = default;
Lambda(const Lambda&) = delete;
Lambda(Lambda&&) = delete;
Lambda& operator=(const Lambda&) = delete;
Lambda& operator=(Lambda&&) = delete;
std::span<const std::shared_ptr<Taker<Value>>> takers() const noexcept {
return takers_;
}
std::span<const std::shared_ptr<Maker<Value>>> makers() const noexcept {
return makers_;
}
private:
std::vector<std::shared_ptr<Taker<Value>>> takers_;
std::vector<std::shared_ptr<Maker<Value>>> makers_;
};
} // namespace nf7

24
iface/subsys/interface.hh Normal file
View File

@ -0,0 +1,24 @@
// No copyright
#pragma once
namespace nf7::subsys {
class Interface {
public:
Interface() = delete;
explicit Interface(const char* name) : name_(name) { }
virtual ~Interface() = default;
Interface(const Interface&) = delete;
Interface(Interface&&) = delete;
Interface& operator=(const Interface&) = delete;
Interface& operator=(Interface&&) = delete;
const char* name() const noexcept { return name_; }
private:
const char* name_;
};
} // namespace nf7::subsys