-
Notifications
You must be signed in to change notification settings - Fork 0
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
FyS
committed
Nov 20, 2023
1 parent
04584a1
commit c865554
Showing
16 changed files
with
177 additions
and
240 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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Dual Licensing Either : | ||
// - AGPL | ||
// or | ||
// - Subscription license for commercial usage (without requirement of licensing propagation). | ||
// please contact [email protected] for additional information about this subscription commercial licensing. | ||
// | ||
// Created by FyS on 23/04/23. License 2022-2023 | ||
// | ||
// In the case no license has been purchased for the use (modification or distribution in any way) of the software stack | ||
// the APGL license is applying. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <concepts> | ||
#include <future> | ||
#include <optional> | ||
#include <string> | ||
#include <variant> | ||
#include <vector> | ||
|
||
#include "fap_request.hh" | ||
|
||
namespace fabko::agent_protocol { | ||
|
||
struct proposition { | ||
std::string id; | ||
}; | ||
|
||
struct propositions { | ||
std::optional<std::vector<proposition>> props; | ||
status st{status::awaiting}; | ||
}; | ||
|
||
enum class decision_status { | ||
SUCCESS, | ||
RETRY, | ||
CANCELLED, | ||
}; | ||
|
||
/** | ||
* | ||
* @tparam T | ||
*/ | ||
template<typename T> | ||
concept c_board_com = | ||
requires(T a) { | ||
{ T::make_board(request{}) } -> std::convertible_to<std::string>; | ||
{ a.propositions(std::string{}) } -> std::convertible_to<std::future<propositions>>; | ||
{ a.commit_decision(std::string{}) } -> std::convertible_to<decision_status>; | ||
} && std::movable<T>; | ||
|
||
namespace p2p { | ||
class board_protocol { | ||
public: | ||
static std::string instantiate_black_board(const std::string&); | ||
std::future<propositions> request_propositions(const std::string&); | ||
decision_status commit_decision(const std::string&); | ||
}; | ||
} // namespace p2p | ||
|
||
namespace local { | ||
class board_protocol { | ||
struct impl; | ||
|
||
public: | ||
~board_protocol(); | ||
board_protocol(); | ||
|
||
static std::string instantiate_black_board(const std::string&); | ||
std::future<propositions> request_propositions(const std::string&); | ||
decision_status commit_decision(const std::string&); | ||
|
||
private: | ||
std::unique_ptr<impl> _impl; | ||
}; | ||
} // namespace local | ||
|
||
using board_protocol = std::variant<local::board_protocol, p2p::board_protocol>; | ||
|
||
} // namespace fabko::agent_protocol |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// - AGPL | ||
// or | ||
// - Subscription license for commercial usage (without requirement of licensing propagation). | ||
// please contact [email protected] for additional information about this subscription commercial licensing. | ||
// | ||
// Created by FyS on 23/04/23. License 2022-2023 | ||
// | ||
// In the case no license has been purchased for the use (modification or distribution in any way) of the software stack | ||
// the APGL license is applying. | ||
|
||
#include <agent.hh> | ||
|
||
#include "boardcom.hh" | ||
|
||
namespace fabko::agent_protocol::local { | ||
|
||
struct board_protocol::impl { | ||
std::vector<std::shared_ptr<agent>> _agent_ring; | ||
}; | ||
|
||
board_protocol::~board_protocol() = default; | ||
|
||
std::string board_protocol::instantiate_black_board(const std::string&) { | ||
return {}; | ||
} | ||
|
||
std::future<propositions> board_protocol::request_propositions(const std::string&) { | ||
return std::future<propositions>(); | ||
} | ||
|
||
agent_protocol::decision_status board_protocol::commit_decision(const std::string&) { | ||
return agent_protocol::decision_status::RETRY; | ||
} | ||
|
||
board_protocol::board_protocol(): _impl(std::make_unique<impl>()) { | ||
} | ||
|
||
} |
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.