VPTissue Reference Manual
Protocol.h
Go to the documentation of this file.
1 #ifndef SIMPT_PAREX_PROTOCOL_H_
2 #define SIMPT_PAREX_PROTOCOL_H_
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include <QObject>
23 #include <boost/property_tree/ptree_fwd.hpp>
24 
25 class QTcpSocket;
26 
27 namespace SimPT_Parex {
28 
29 class Connection;
30 class ServerInfo;
31 
35 class Protocol : public QObject
36 {
37  Q_OBJECT
38 public:
44  Protocol(QTcpSocket* socket, QObject* parent = nullptr);
45 
51  Protocol(ServerInfo* server, QObject *parent = nullptr);
52 
56  virtual ~Protocol();
57 
61  bool IsConnected();
62 
63 signals:
65  void Ended();
66 
68  void Error(const std::string &error);
69 
70 protected:
72  void SendPtree(const boost::property_tree::ptree& pt);
73 
75  virtual void ReceivePtree(const boost::property_tree::ptree& pt) = 0;
76 
78  std::string GetClientIP() const;
79 
81  int GetClientPort() const ;
82 
83 private slots:
85  void Receive(const QByteArray& message);
86 
87 private:
88  Connection* m_connection;
89 };
90 
91 } // namespace
92 
93 #endif // end-of-include-guard
Protocol(QTcpSocket *socket, QObject *parent=nullptr)
Constructor.
Definition: Protocol.cpp:33
Base class for the XML/ptree protocols between client, server and node.
Definition: Protocol.h:35
void Error(const std::string &error)
Signal emitted when an error occured.
void SendPtree(const boost::property_tree::ptree &pt)
Sends a ptree over the connection.
Definition: Protocol.cpp:78
void Ended()
Signal emitted when the protocol has ended and the connection is closed.
Class managing a TCP stream of messages.
Definition: Connection.h:31
virtual ~Protocol()
Destructor.
Definition: Protocol.cpp:61
Class for storing server info used on client-side.
Definition: ServerInfo.h:29
virtual void ReceivePtree(const boost::property_tree::ptree &pt)=0
Method called when a ptree was received over the connection.
Namespace for SimPT parameter explorer package.
Definition: Client.cpp:52
bool IsConnected()
Check if still connected.
Definition: Protocol.cpp:73
see the online Qt documentation