salsa 0.7.1
Loading...
Searching...
No Matches
Distributor.hh
1#pragma once
2#include <map>
3#include <json/json.h>
4
5#include "NodeInfo.pb.h"
6#include "TaskInfo.pb.h"
7#include "Socket.hh"
8namespace Salsa {
17class NodeManager;
18
19class Distributor : public Object {
20public:
21 Distributor(std::string uuid, std::shared_ptr<Socket> pPipe, NodeManager * pNM);
22 virtual ~Distributor();
23
25 std::string uuid() const;
26
28 std::shared_ptr<Socket> pipe() const;
29
31 void print() const;
32
33 // TODO Client ops
34 void addClient(std::string uuid, std::string type);
35 void removeClient(std::string uuid);
36
37 // TODO Other ops
38 void addOther(std::string uuid, std::string type);
39 void removeOther(std::string uuid);
40
41 // TODO Get node info
42 NodeInfo * nodeInfo() const;
43
45 virtual void onEnter(Message * pInMsg, std::vector<std::string> & out, std::string type);
46 virtual void onExit(Message * pInMsg, std::vector<std::string> & out);
47 virtual void onWhisper(Message * pInMsg, std::vector<std::string> & out);
48
50 Json::Value jsonValueNodeInfo() const { return mJsonValue; }
51 virtual void upadateJsonValueNodeInfo();
52
53protected:
54 std::string mUUID{};
55 std::shared_ptr<Socket> mpPipe = nullptr;
56 std::map<std::string, std::string> mClients{};
57 std::map<std::string, std::string> mOthers{};
59 NodeInfo * mpNodeInfo{new NodeInfo()};
60 Json::Value mJsonValue;
61
62 mutable TaskInfo mTaskInfoCache{};
63};
64} // namespace Salsa
Base Distributor class.
virtual void onWhisper(Message *pInMsg, std::vector< std::string > &out)
Json::Value jsonValueNodeInfo() const
Returns json value.
std::map< std::string, std::string > mClients
List of clients.
Json::Value mJsonValue
Node Info as json value.
NodeInfo * nodeInfo() const
std::map< std::string, std::string > mOthers
List of others.
void addClient(std::string uuid, std::string type)
virtual void upadateJsonValueNodeInfo()
std::string mUUID
Self UUID.
void removeClient(std::string uuid)
void print() const
TODO Prints distributor's state.
std::shared_ptr< Socket > mpPipe
Pipe for messages (net connector)
NodeManager * mpNodeManager
Node Manager.
virtual ~Distributor()
TaskInfo mTaskInfoCache
Task Info cache.
void addOther(std::string uuid, std::string type)
virtual void onEnter(Message *pInMsg, std::vector< std::string > &out, std::string type)
TODO Three horsemen of apocalypse.
void removeOther(std::string uuid)
virtual void onExit(Message *pInMsg, std::vector< std::string > &out)
std::shared_ptr< Socket > pipe() const
TODO Returns distributor's pipe?
NodeInfo * mpNodeInfo
Node Info.
std::string uuid() const
Returns distributor's UUID.
Distributor(std::string uuid, std::shared_ptr< Socket > pPipe, NodeManager *pNM)
Definition Distributor.cc:3
Base Message class.
Definition Message.hh:15
NodeManager class.
Base Salsa Object class.
Definition Object.hh:15