Changeset 178 in flair-src for trunk/lib/FlairCore/src
- Timestamp:
- May 19, 2017, 4:15:52 PM (8 years ago)
- Location:
- trunk/lib/FlairCore/src
- Files:
-
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/UdpSocket.cpp
r177 r178 4 4 // %flair:license} 5 5 // created: 2013/11/17 6 // filename: Socket.cpp6 // filename: UdpSocket.cpp 7 7 // 8 8 // author: Guillaume Sanahuja … … 15 15 // 16 16 /*********************************************************************/ 17 #include " Socket.h"18 #include " Socket_impl.h"17 #include "UdpSocket.h" 18 #include "UdpSocket_impl.h" 19 19 #include <FrameworkManager.h> 20 20 #include <string.h> … … 26 26 namespace core { 27 27 28 Socket::Socket(const Object *parent, string name, uint16_t port)28 UdpSocket::UdpSocket(const Object *parent, string name, uint16_t port) 29 29 : Object(parent, name) { 30 pimpl_ = new Socket_impl(this, name, port);30 pimpl_ = new UdpSocket_impl(this, name, port); 31 31 } 32 32 33 Socket::Socket(const Object *parent, string name, string address,33 UdpSocket::UdpSocket(const Object *parent, string name, string address, 34 34 bool broadcast) 35 35 : Object(parent, name) { 36 pimpl_ = new Socket_impl(this, name, address, broadcast);36 pimpl_ = new UdpSocket_impl(this, name, address, broadcast); 37 37 } 38 38 39 Socket::~Socket() { delete pimpl_; }39 UdpSocket::~UdpSocket() { delete pimpl_; } 40 40 41 void Socket::SendMessage(const char *message, size_t message_len) {41 void UdpSocket::SendMessage(const char *message, size_t message_len) { 42 42 pimpl_->SendMessage(message, message_len); 43 43 } 44 44 45 void Socket::SendMessage(string message) { pimpl_->SendMessage(message); }45 void UdpSocket::SendMessage(string message) { pimpl_->SendMessage(message); } 46 46 47 ssize_t Socket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,47 ssize_t UdpSocket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src, 48 48 size_t *src_len) { 49 49 return pimpl_->RecvMessage(buf, buf_len, timeout, src, src_len); 50 50 } 51 51 52 void Socket::NetworkToHost(char *data, size_t dataSize) {52 void UdpSocket::NetworkToHost(char *data, size_t dataSize) { 53 53 if (core::IsBigEndian()) 54 54 return; … … 69 69 } 70 70 71 void Socket::HostToNetwork(char *data, size_t dataSize) {71 void UdpSocket::HostToNetwork(char *data, size_t dataSize) { 72 72 if (IsBigEndian()) 73 73 return; -
trunk/lib/FlairCore/src/UdpSocket.h
r177 r178 11 11 */ 12 12 13 #ifndef SOCKET_H14 #define SOCKET_H13 #ifndef UDPSOCKET_H 14 #define UDPSOCKET_H 15 15 16 16 #include <unistd.h> … … 18 18 #include <Object.h> 19 19 20 class Socket_impl;20 class UdpSocket_impl; 21 21 22 22 namespace flair { 23 23 namespace core { 24 24 25 /*! \class Socket25 /*! \class UdpSocket 26 26 * 27 27 * \brief Class encapsulating a UDP socket. It assumes packets are coming from … … 29 29 * 30 30 */ 31 class Socket : public Object {31 class UdpSocket : public Object { 32 32 public: 33 33 /*! … … 41 41 * \param broadcast true if address is a broadcast address 42 42 */ 43 Socket(const Object *parent, std::string name, std::string address,43 UdpSocket(const Object *parent, std::string name, std::string address, 44 44 bool broadcast = false); 45 45 … … 53 53 * \param port listening port 54 54 */ 55 Socket(const Object *parent, std::string name, uint16_t port);55 UdpSocket(const Object *parent, std::string name, uint16_t port); 56 56 57 57 /*! … … 59 59 * 60 60 */ 61 ~ Socket();61 ~UdpSocket(); 62 62 63 63 /*! … … 103 103 104 104 private: 105 class Socket_impl *pimpl_;105 class UdpSocket_impl *pimpl_; 106 106 }; 107 107 … … 109 109 } // end namespace flair 110 110 111 #endif // SOCKET_H111 #endif // UDPSOCKET_H -
trunk/lib/FlairCore/src/UdpSocket_impl.cpp
r177 r178 15 15 // 16 16 /*********************************************************************/ 17 #include " Socket_impl.h"18 #include " Socket.h"17 #include "UdpSocket_impl.h" 18 #include "UdpSocket.h" 19 19 #include "FrameworkManager.h" 20 20 #include <fcntl.h> … … 29 29 using namespace flair::core; 30 30 31 Socket_impl::Socket_impl(constSocket *self, string name, uint16_t port) {31 UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, uint16_t port) { 32 32 this->self = self; 33 33 this->port = port; … … 37 37 } 38 38 39 Socket_impl::Socket_impl(constSocket *self, string name, string address,39 UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, string address, 40 40 bool broadcast) { 41 41 this->self = self; … … 51 51 } 52 52 53 void Socket_impl::Init(void) {53 void UdpSocket_impl::Init(void) { 54 54 int yes = 1; 55 55 … … 143 143 } 144 144 145 Socket_impl::~Socket_impl() {145 UdpSocket_impl::~UdpSocket_impl() { 146 146 #ifdef __XENO__ 147 147 is_running = false; … … 157 157 } 158 158 159 void Socket_impl::SendMessage(const char *src, size_t src_len) {159 void UdpSocket_impl::SendMessage(const char *src, size_t src_len) { 160 160 ssize_t written; 161 161 string to_send; … … 189 189 } 190 190 191 void Socket_impl::SendMessage(string message) {191 void UdpSocket_impl::SendMessage(string message) { 192 192 ssize_t written; 193 193 … … 214 214 } 215 215 216 ssize_t Socket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,216 ssize_t UdpSocket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout, 217 217 char *src, size_t *src_len) { 218 218 ssize_t nb_read; … … 291 291 292 292 #ifdef __XENO__ 293 void * Socket_impl::user(void *arg) {294 Socket_impl *caller = (Socket_impl *)arg;293 void *UdpSocket_impl::user(void *arg) { 294 UdpSocket_impl *caller = (UdpSocket_impl *)arg; 295 295 int pipe_fd = -1; 296 296 string devname; -
trunk/lib/FlairCore/src/unexported/UdpSocket_impl.h
r177 r178 4 4 // %flair:license} 5 5 /*! 6 * \file Socket_impl.h6 * \file UdpSocket_impl.h 7 7 * \brief Classe creant une socket 8 8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253 … … 11 11 */ 12 12 13 #ifndef SOCKET_IMPL_H14 #define SOCKET_IMPL_H13 #ifndef UDPSOCKET_IMPL_H 14 #define UDPSOCKET_IMPL_H 15 15 16 16 #include <sys/socket.h> … … 21 21 #endif 22 22 23 namespace flair { 24 namespace core { 25 class Socket; 26 } 27 } 23 namespace flair { namespace core { 24 class UdpSocket; 25 } } 28 26 29 class Socket_impl {27 class UdpSocket_impl { 30 28 public: 31 Socket_impl(const flair::core::Socket *self, std::string name,29 UdpSocket_impl(const flair::core::UdpSocket *self, std::string name, 32 30 std::string address, bool broadcast = false); 33 Socket_impl(const flair::core::Socket *self, std::string name, uint16_t port);34 ~ Socket_impl();31 UdpSocket_impl(const flair::core::UdpSocket *self, std::string name, uint16_t port); 32 ~UdpSocket_impl(); 35 33 36 34 void SendMessage(std::string message); … … 45 43 bool broadcast; 46 44 void Init(void); 47 const flair::core:: Socket *self;45 const flair::core::UdpSocket *self; 48 46 struct sockaddr_in sock_in; 49 47 #ifdef __XENO__ … … 55 53 }; 56 54 57 #endif // SOCKET_IMPL_H55 #endif // UDPSOCKET_IMPL_H
Note:
See TracChangeset
for help on using the changeset viewer.