35 class ExplorationManager;
39 const std::shared_ptr<ExplorationManager>& explorationManager,
QObject* parent)
40 :
QObject(parent), m_protocol(nullptr), m_exploration_manager(explorationManager)
42 assert(socket &&
"socket cannot be a nullptr");
43 assert(explorationManager.get() &&
"explorationManager cannot be a nullptr");
47 connect(m_protocol, SIGNAL(Ended()),
this, SLOT(deleteLater()));
48 connect(m_protocol, SIGNAL(Error(
const std::string&)),
49 this, SLOT(DisplayError(
const std::string&)));
52 connect(m_protocol, SIGNAL(ExplorationReceived(
const Exploration*)),
53 this, SLOT(RegisterExploration(
const Exploration*)));
54 connect(m_exploration_manager.get(), SIGNAL(Updated()),
this, SLOT(Refresh()));
56 connect(m_protocol, SIGNAL(DeleteExploration(
const std::string&)),
57 this, SLOT(DeleteExploration(
const std::string&)));
58 connect(m_protocol, SIGNAL(ExplorationNamesRequested()),
59 this, SLOT(SendExplorationNames()));
60 connect(m_protocol, SIGNAL(Subscribe(
const std::string&)),
61 this, SLOT(Subscribe(
const std::string&)));
62 connect(m_protocol, SIGNAL(Unsubscribe(
const std::string&)),
63 this, SLOT(Unsubscribe(
const std::string&)));
64 connect(m_protocol, SIGNAL(StopTask(
const std::string&,
int)),
65 m_exploration_manager.get(), SLOT(StopTask(
const std::string&,
int)));
66 connect(m_protocol, SIGNAL(RestartTask(
const std::string&,
int)),
67 m_exploration_manager.get(), SLOT(RestartTask(
const std::string&,
int)));
70 void ClientHandler::DisplayError(
const std::string& error)
const
72 cerr <<
"ClientHandler Error: " << error << endl;
75 void ClientHandler::DeleteExploration(
const std::string& name)
78 m_exploration_manager->DeleteExploration(name);
81 void ClientHandler::Refresh()
83 if (m_subscribed_exploration !=
"") {
84 const ExplorationProgress *progress
85 = m_exploration_manager->GetExplorationProgress(m_subscribed_exploration);
94 void ClientHandler::RegisterExploration(
const Exploration* exploration)
96 cout <<
"ClientHandler::RegisterExploration" << endl;
97 m_exploration_manager->RegisterExploration(exploration);
98 Subscribe(exploration->GetName());
101 void ClientHandler::SendExplorationNames()
106 void ClientHandler::Subscribe(
const std::string& name)
108 m_subscribed_exploration = name;
112 void ClientHandler::Unsubscribe(
const std::string& name)
114 if (m_subscribed_exploration == name){
115 m_subscribed_exploration =
"";
void SendStatusDeleted(const std::string &name)
Send a deleted status for the exploration with the specified name.
Interface for Exploration.
ClientHandler(QTcpSocket *socket, const std::shared_ptr< ExplorationManager > &explorationManager, QObject *parent=0)
Constructor.
void SendExplorationNames(const std::vector< std::string > &names)
Send list of Exploration names.
Interface for ServerClientProtocol.
Interface for ClientHandler.
Interface for ExplorationManager.
ServerClient Protocol to deal with Client-Server communication (Server-side)
Namespace for SimPT parameter explorer package.
see the online Qt documentation
Class describing a generic exploration.
Interface for ExplorationProgress.
void SendStatus(const ExplorationProgress &status)
Send status for given exploration.