source: pacpussensors/trunk/PacpusSocket/PacpusUDPSocket.h@ 145

Last change on this file since 145 was 99, checked in by nguyenhu, 9 years ago

compilation under linux with 0.2.X framework

File size: 2.4 KB
RevLine 
[85]1/*********************************************************************
2// created: 2012/03/01 - 14:06
3// filename: PacpusUDPSocket.h
4//
5// author: Pierre Hudelaine
6// Copyright Heudiasyc UMR UTC/CNRS 7253
[99]7//
[85]8// version: $Id: $
9//
10// purpose: Create network socket if needed in Pacpus
11//
12*********************************************************************/
13
14#include <qudpsocket.h>
15
16#include "Pacpus/kernel/Log.h"
[99]17#include "Pacpus/kernel/ComponentBase.h"
18#include "Pacpus/kernel/ComponentFactory.h"
[85]19
20// Export macro for PacpusSocket DLL for Windows only
21#ifdef WIN32
22# ifdef PACPUSSOCKET_EXPORTS
23 // make DLL
24# define PACPUSSOCKET_API __declspec(dllexport)
25# else
26 // use DLL
27# define PACPUSSOCKET_API __declspec(dllimport)
28# endif
29#else
[99]30 // On other platforms, simply ignore this
31# define PACPUSSOCKET_API
[85]32#endif
33
34class QByteArray;
35
36namespace pacpus {
37
38class PACPUSSOCKET_API Client
39{
[99]40public:
[85]41 /// Constructor
42 Client();
43 Client(QHostAddress address, quint16 port) {address_ = address; port_ = port;};
44 /// Destructor
45 ~Client();
[99]46
[85]47 QHostAddress address_;
48 quint16 port_;
[99]49
50 QHostAddress getAddress() {return address_;};
[85]51 quint16 getPort() {return port_;};
52};
53
54class PACPUSSOCKET_API PacpusUDPSocket
55 : public QObject
[99]56 , public ComponentBase
57{
[85]58 Q_OBJECT
59
[99]60public:
[85]61 /// Constructor
62 PacpusUDPSocket(QString name);
63
64 /// Destructor
65 ~PacpusUDPSocket();
66 PacpusUDPSocket * getSocket() {return this;}
67
68public Q_SLOTS:
69 /// Slot de lecture des paquets envoys pour tests
70 void readPendingDatagrams();
71
72 /// Slot d'envoie des paquets
[99]73 void sendQString(const QString& frame);
[85]74 void sendDatagrams(QByteArray frame);
[99]75
[85]76Q_SIGNALS:
77 void newDatagram(QByteArray datagram);
78 void newQString(QString string);
79
80protected:
81 // The 3 virtual methods relative to the ComponentBase inheritance
82 virtual void startActivity();
83 virtual void stopActivity();
84 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
[99]85
86 virtual void addInputs();
[87]87 virtual void addOutputs();
[85]88
[99]89 OutputInterface<QString, PacpusUDPSocket>* udpSocketOutput_;
90
[85]91 QUdpSocket * udpSocket_;
92
93 quint16 port2bind_;
94 quint16 port2send_;
95 QHostAddress address2send_;
[99]96 QString socketType_;
97
[85]98 QList <Client *> listClients;
99};
100
101} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.