#ifndef GRADIDO_LOGIN_SERVER_CONTROLLER_NODE_SERVER_INCLUDE #define GRADIDO_LOGIN_SERVER_CONTROLLER_NODE_SERVER_INCLUDE #include "../model/table/NodeServer.h" #include "../controller/HederaId.h" #include "Poco/SharedPtr.h" #include "TableControllerBase.h" namespace controller { struct NodeServerConnection { NodeServerConnection(const std::string& _url, int _port) : url(_url), port(_port) {} NodeServerConnection() :port(0) {}; bool isValid() { return url != "" && port; } std::string url; int port; Poco::AutoPtr hederaId; }; typedef Poco::Tuple NodeServerFullTuple; class NodeServer : public TableControllerBase { public: ~NodeServer(); static Poco::AutoPtr create(const std::string& url, int port, int groupId, model::table::NodeServerType type, int nodeHederaId); static std::vector> load(model::table::NodeServerType type, int group_id = 0); static std::vector> listAll(); // pick server randomly NodeServerConnection pick(model::table::NodeServerType type, int group_id = 0); inline bool deleteFromDB() { return mDBModel->deleteFromDB(); } inline Poco::AutoPtr getModel() { return _getModel(); } inline void setHederaId(Poco::AutoPtr hederaId) { mHederaID = hederaId; } inline Poco::AutoPtr getHederaId() { return mHederaID; } protected: NodeServer(model::table::NodeServer* dbModel); Poco::AutoPtr mHederaID; }; } #endif //GRADIDO_LOGIN_SERVER_CONTROLLER_NODE_SERVER_INCLUDE