trikRuntime
mailboxInterface.h
Go to the documentation of this file.
1 /* Copyright 2015 CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QMetaType>
18 #include <QObject>
19 #include <QtNetwork/QHostAddress>
20 
21 #include "declSpec.h"
22 
23 namespace trikNetwork {
24 
31 class TRIKNETWORK_EXPORT MailboxInterface : public QObject
32 {
33  Q_OBJECT
34 
35 public:
37  virtual bool isConnected() const = 0;
38 
40  virtual void setHullNumber(int myHullNumber) = 0;
41 
43  virtual QHostAddress serverIp() const = 0;
44 
46  virtual QHostAddress myIp() const = 0;
47 
49  virtual void clearQueue() = 0;
50 
52  virtual void stopWaiting() = 0;
53 
55  virtual bool isEnabled() = 0;
56 
57 public slots:
59  virtual void connect(const QString &ip, int port) = 0;
60 
62  virtual void connect(const QString &ip) = 0;
63 
65  virtual void send(int hullNumber, const QString &message) = 0;
66 
68  virtual void send(const QString &message) = 0;
69 
71  virtual bool hasMessages() = 0;
72 
74  virtual void renewIp() = 0;
75 
80  virtual QString receive(bool wait = true) = 0;
81 
83  virtual int myHullNumber() const = 0;
84 
85 signals:
89  void newMessage(int sender, const QString &message);
90 
92  void connectionStatusChanged(bool connected);
93 };
94 
95 }
96 
97 Q_DECLARE_METATYPE(trikNetwork::MailboxInterface*)
static const int port
Definition: trikCommunicatorTest.cpp:24
Definition: trikCommunicator.h:31
#define TRIKNETWORK_EXPORT
Definition: declSpec.h:23
Allows communication between robots.
Definition: mailboxInterface.h:31