|
@ -10,6 +10,23 @@ |
|
|
#include <vector> |
|
|
#include <vector> |
|
|
#include <memory> |
|
|
#include <memory> |
|
|
|
|
|
|
|
|
|
|
|
// The Model currently is as follows:
|
|
|
|
|
|
// The Model creates the TestTree using PityUnits.
|
|
|
|
|
|
// When creating the model you specify how many nodes you want
|
|
|
|
|
|
// The Model has a PityUnit rootUnit.
|
|
|
|
|
|
// The Model then creates a list of PityNodes, each containing a PityUnit connected to the rootUnit
|
|
|
|
|
|
// The PityNode, when run will modify the model to represent the perspective of the respective node nr.
|
|
|
|
|
|
// The perspective currently is complete by specifying a node, since there is a 1-1 node/ident relationship currently
|
|
|
|
|
|
//
|
|
|
|
|
|
// ATTENTION - TODO:
|
|
|
|
|
|
// Currently there is a strict 1-1 relationship of nodes and identities.
|
|
|
|
|
|
// One Node has exactly one identity, and this identity is only on this node.
|
|
|
|
|
|
// This needs to be enhanced to be a n-n relationship
|
|
|
|
|
|
// The Transport only addresses nodes, not idents, therefore
|
|
|
|
|
|
// If you have one ident on n nodes, the transport needs to check the model for all nodes the
|
|
|
|
|
|
// ident is on and send the message to all these nodes.
|
|
|
|
|
|
// If you have a node that has n identities, the persepective needs to specify node AND ident.
|
|
|
|
|
|
|
|
|
namespace pEp { |
|
|
namespace pEp { |
|
|
namespace PityTest11 { |
|
|
namespace PityTest11 { |
|
|
class PityModel { |
|
|
class PityModel { |
|
@ -17,16 +34,22 @@ namespace pEp { |
|
|
PityModel() = delete; |
|
|
PityModel() = delete; |
|
|
PityModel(const std::string& name, int nodeCount); |
|
|
PityModel(const std::string& name, int nodeCount); |
|
|
std::string getName() const; |
|
|
std::string getName() const; |
|
|
void setName(std::string name) ; |
|
|
void setName(std::string name); |
|
|
std::vector<std::shared_ptr<PityNode>> getNodes() const; |
|
|
std::vector<std::shared_ptr<PityNode>> getNodes() const; |
|
|
PityUnit<PityModel>& rootUnit(); |
|
|
PityUnit<PityModel>& rootUnit(); |
|
|
PityUnit<PityModel>* getNodeUnit(int nr) const; |
|
|
PityUnit<PityModel>* getNodeUnit(int nr) const; |
|
|
|
|
|
|
|
|
|
|
|
//Transport
|
|
|
|
|
|
void sendMsg(const std::string nodename, const std::string& msg) const; |
|
|
|
|
|
std::string pollMsg() const; |
|
|
|
|
|
std::string receiveMsg(int timeout_msec = 100) const; |
|
|
|
|
|
|
|
|
PityNode* own_node = nullptr; |
|
|
PityNode* own_node = nullptr; |
|
|
|
|
|
|
|
|
//internal logging
|
|
|
//internal logging
|
|
|
static bool debug_log_enabled; |
|
|
static bool debug_log_enabled; |
|
|
Adapter::pEpLog::pEpLogger logger_debug{ "PityModel", debug_log_enabled }; |
|
|
Adapter::pEpLog::pEpLogger logger_debug{ "PityModel", debug_log_enabled }; |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
PityUnit<PityModel> _root_unit; |
|
|
PityUnit<PityModel> _root_unit; |
|
|
std::vector<std::shared_ptr<PityNode>> _nodes; |
|
|
std::vector<std::shared_ptr<PityNode>> _nodes; |
|
|