ADD: adden more functionality includeing a tcp server for external comms
This commit is contained in:
64
include/SimControl/PodList.hpp
Normal file
64
include/SimControl/PodList.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace SimControl
|
||||
{
|
||||
struct PodListItem
|
||||
{
|
||||
std::string Uuid;
|
||||
std::string Image;
|
||||
std::string Ip;
|
||||
std::string Component;
|
||||
std::string Status;
|
||||
std::string PartOf;
|
||||
std::vector<std::pair<std::string,std::shared_ptr<PodListItem>>> relatedPods;
|
||||
|
||||
bool operator==(PodListItem const &rhs )
|
||||
{
|
||||
if (Uuid == rhs.Uuid) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class PodList
|
||||
{
|
||||
public:
|
||||
PodList();
|
||||
PodList(std::string jsonstring);
|
||||
|
||||
|
||||
void addPodToList(std::shared_ptr<PodListItem> pod);
|
||||
void addPodToList(std::string respond);
|
||||
|
||||
std::shared_ptr<PodListItem> getPod(std::string uuid);
|
||||
|
||||
bool removePod(std::string uuid);
|
||||
|
||||
std::vector<std::string> getPodsUUID();
|
||||
|
||||
nlohmann::json getPodTree(std::string uuid);
|
||||
|
||||
size_t size();
|
||||
|
||||
private:
|
||||
|
||||
void addPodsFromString(std::string respond);
|
||||
|
||||
std::map<std::string, std::shared_ptr<PodListItem>> podList_;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __SIMCONTROL__
|
||||
|
||||
#include "DirectCommunicationClient.hpp"
|
||||
#include "DirectCommunicationServer.hpp"
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "crossguid/guid.hpp"
|
||||
#include "kubecontrol/PodController.hpp"
|
||||
@@ -26,24 +27,33 @@ namespace SimControl {
|
||||
class SimControl{
|
||||
|
||||
public:
|
||||
SimControl(ushort CommandPort);
|
||||
SimControl(std::string CommandPort);
|
||||
~SimControl();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
const SimCore::Identifier ID_;
|
||||
ushort CommandPort_;
|
||||
std::string CommandPort_;
|
||||
void MainFunction_();
|
||||
|
||||
void HandleMessage(std::string msg);
|
||||
|
||||
void HandleExternalMessage(std::string msg);
|
||||
|
||||
|
||||
void startShip(std::string name);
|
||||
|
||||
|
||||
std::unique_ptr<kubecontrol::PodController> PodController_;
|
||||
|
||||
|
||||
std::thread MainThread_;
|
||||
std::atomic<bool> stopMainThread_ = false;
|
||||
|
||||
std::unique_ptr<DirectCommunication::DirectCommunicationClient> TCPClient_;
|
||||
std::shared_ptr<DirectCommunication::DirectCommunicationClient> TCPClient_ = nullptr;
|
||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> ExternalTCPServer_ = nullptr;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user