Changeset 178 in flair-src for trunk/lib


Ignore:
Timestamp:
May 19, 2017, 4:15:52 PM (8 years ago)
Author:
Bayard Gildas
Message:

Change Udp socket object name (from "Socket" to "UdpSocket")

Location:
trunk/lib
Files:
5 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/UdpSocket.cpp

    r177 r178  
    44// %flair:license}
    55//  created:    2013/11/17
    6 //  filename:   Socket.cpp
     6//  filename:   UdpSocket.cpp
    77//
    88//  author:     Guillaume Sanahuja
     
    1515//
    1616/*********************************************************************/
    17 #include "Socket.h"
    18 #include "Socket_impl.h"
     17#include "UdpSocket.h"
     18#include "UdpSocket_impl.h"
    1919#include <FrameworkManager.h>
    2020#include <string.h>
     
    2626namespace core {
    2727
    28 Socket::Socket(const Object *parent, string name, uint16_t port)
     28UdpSocket::UdpSocket(const Object *parent, string name, uint16_t port)
    2929    : Object(parent, name) {
    30   pimpl_ = new Socket_impl(this, name, port);
     30  pimpl_ = new UdpSocket_impl(this, name, port);
    3131}
    3232
    33 Socket::Socket(const Object *parent, string name, string address,
     33UdpSocket::UdpSocket(const Object *parent, string name, string address,
    3434               bool broadcast)
    3535    : Object(parent, name) {
    36   pimpl_ = new Socket_impl(this, name, address, broadcast);
     36  pimpl_ = new UdpSocket_impl(this, name, address, broadcast);
    3737}
    3838
    39 Socket::~Socket() { delete pimpl_; }
     39UdpSocket::~UdpSocket() { delete pimpl_; }
    4040
    41 void Socket::SendMessage(const char *message, size_t message_len) {
     41void UdpSocket::SendMessage(const char *message, size_t message_len) {
    4242  pimpl_->SendMessage(message, message_len);
    4343}
    4444
    45 void Socket::SendMessage(string message) { pimpl_->SendMessage(message); }
     45void UdpSocket::SendMessage(string message) { pimpl_->SendMessage(message); }
    4646
    47 ssize_t Socket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,
     47ssize_t UdpSocket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,
    4848                            size_t *src_len) {
    4949  return pimpl_->RecvMessage(buf, buf_len, timeout, src, src_len);
    5050}
    5151
    52 void Socket::NetworkToHost(char *data, size_t dataSize) {
     52void UdpSocket::NetworkToHost(char *data, size_t dataSize) {
    5353  if (core::IsBigEndian())
    5454    return;
     
    6969}
    7070
    71 void Socket::HostToNetwork(char *data, size_t dataSize) {
     71void UdpSocket::HostToNetwork(char *data, size_t dataSize) {
    7272  if (IsBigEndian())
    7373    return;
  • trunk/lib/FlairCore/src/UdpSocket.h

    r177 r178  
    1111 */
    1212
    13 #ifndef SOCKET_H
    14 #define SOCKET_H
     13#ifndef UDPSOCKET_H
     14#define UDPSOCKET_H
    1515
    1616#include <unistd.h>
     
    1818#include <Object.h>
    1919
    20 class Socket_impl;
     20class UdpSocket_impl;
    2121
    2222namespace flair {
    2323namespace core {
    2424
    25 /*! \class Socket
     25/*! \class UdpSocket
    2626*
    2727* \brief Class encapsulating a UDP socket. It assumes packets are coming from
     
    2929*
    3030*/
    31 class Socket : public Object {
     31class UdpSocket : public Object {
    3232public:
    3333  /*!
     
    4141  * \param broadcast true if address is a broadcast address
    4242  */
    43   Socket(const Object *parent, std::string name, std::string address,
     43  UdpSocket(const Object *parent, std::string name, std::string address,
    4444         bool broadcast = false);
    4545
     
    5353  * \param port listening port
    5454  */
    55   Socket(const Object *parent, std::string name, uint16_t port);
     55  UdpSocket(const Object *parent, std::string name, uint16_t port);
    5656
    5757  /*!
     
    5959  *
    6060  */
    61   ~Socket();
     61  ~UdpSocket();
    6262
    6363  /*!
     
    103103
    104104private:
    105   class Socket_impl *pimpl_;
     105  class UdpSocket_impl *pimpl_;
    106106};
    107107
     
    109109} // end namespace flair
    110110
    111 #endif // SOCKET_H
     111#endif // UDPSOCKET_H
  • trunk/lib/FlairCore/src/UdpSocket_impl.cpp

    r177 r178  
    1515//
    1616/*********************************************************************/
    17 #include "Socket_impl.h"
    18 #include "Socket.h"
     17#include "UdpSocket_impl.h"
     18#include "UdpSocket.h"
    1919#include "FrameworkManager.h"
    2020#include <fcntl.h>
     
    2929using namespace flair::core;
    3030
    31 Socket_impl::Socket_impl(const Socket *self, string name, uint16_t port) {
     31UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, uint16_t port) {
    3232  this->self = self;
    3333  this->port = port;
     
    3737}
    3838
    39 Socket_impl::Socket_impl(const Socket *self, string name, string address,
     39UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, string address,
    4040                         bool broadcast) {
    4141  this->self = self;
     
    5151}
    5252
    53 void Socket_impl::Init(void) {
     53void UdpSocket_impl::Init(void) {
    5454  int yes = 1;
    5555
     
    143143}
    144144
    145 Socket_impl::~Socket_impl() {
     145UdpSocket_impl::~UdpSocket_impl() {
    146146#ifdef __XENO__
    147147  is_running = false;
     
    157157}
    158158
    159 void Socket_impl::SendMessage(const char *src, size_t src_len) {
     159void UdpSocket_impl::SendMessage(const char *src, size_t src_len) {
    160160  ssize_t written;
    161161  string to_send;
     
    189189}
    190190
    191 void Socket_impl::SendMessage(string message) {
     191void UdpSocket_impl::SendMessage(string message) {
    192192  ssize_t written;
    193193
     
    214214}
    215215
    216 ssize_t Socket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,
     216ssize_t UdpSocket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,
    217217                                 char *src, size_t *src_len) {
    218218  ssize_t nb_read;
     
    291291
    292292#ifdef __XENO__
    293 void *Socket_impl::user(void *arg) {
    294   Socket_impl *caller = (Socket_impl *)arg;
     293void *UdpSocket_impl::user(void *arg) {
     294  UdpSocket_impl *caller = (UdpSocket_impl *)arg;
    295295  int pipe_fd = -1;
    296296  string devname;
  • trunk/lib/FlairCore/src/unexported/UdpSocket_impl.h

    r177 r178  
    44// %flair:license}
    55/*!
    6  * \file Socket_impl.h
     6 * \file UdpSocket_impl.h
    77 * \brief Classe creant une socket
    88 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
     
    1111 */
    1212
    13 #ifndef SOCKET_IMPL_H
    14 #define SOCKET_IMPL_H
     13#ifndef UDPSOCKET_IMPL_H
     14#define UDPSOCKET_IMPL_H
    1515
    1616#include <sys/socket.h>
     
    2121#endif
    2222
    23 namespace flair {
    24 namespace core {
    25 class Socket;
    26 }
    27 }
     23namespace flair { namespace core {
     24  class UdpSocket;
     25} }
    2826
    29 class Socket_impl {
     27class UdpSocket_impl {
    3028public:
    31   Socket_impl(const flair::core::Socket *self, std::string name,
     29  UdpSocket_impl(const flair::core::UdpSocket *self, std::string name,
    3230              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();
    3533
    3634  void SendMessage(std::string message);
     
    4543  bool broadcast;
    4644  void Init(void);
    47   const flair::core::Socket *self;
     45  const flair::core::UdpSocket *self;
    4846  struct sockaddr_in sock_in;
    4947#ifdef __XENO__
     
    5553};
    5654
    57 #endif // SOCKET_IMPL_H
     55#endif // UDPSOCKET_IMPL_H
  • trunk/lib/FlairSensorActuator/src/EmulatedController.cpp

    r157 r178  
    1414#include <Controller.h>
    1515#include <TcpSocket.h>
    16 #include <Socket.h>
     16#include <UdpSocket.h>
    1717#include <cstring>
    1818#include <string>
  • trunk/lib/FlairSensorActuator/src/HostEthController.cpp

    r137 r178  
    2626#include <TargetController.h>
    2727#include <TcpSocket.h>
    28 #include <Socket.h>
     28#include <UdpSocket.h>
    2929#include <cstring>
    3030#include <string>
     
    5454  controlSocket = new TcpSocket((Thread *)this, "eth controller control socket",
    5555                                blocking, !blocking);
    56   dataSocket = new Socket((Thread *)this, "eth controller data socket",
     56  dataSocket = new UdpSocket((Thread *)this, "eth controller data socket",
    5757                          _address + ":" + std::to_string(_port + 1));
    5858  dataSender =
  • trunk/lib/FlairSensorActuator/src/HostEthController.h

    r137 r178  
    2828class cvmatrix;
    2929class TcpSocket;
    30 class Socket;
     30class UdpSocket;
    3131class Mutex;
    3232}
     
    6464  std::string controllerName;
    6565  core::TcpSocket *controlSocket; // connection to the target
    66   core::Socket *dataSocket;
     66  core::UdpSocket *dataSocket;
    6767  std::string targetAddress;
    6868  int targetPort;
  • trunk/lib/FlairSensorActuator/src/TargetEthController.cpp

    r137 r178  
    2121#include <FrameworkManager.h>
    2222#include <TcpSocket.h>
    23 #include <Socket.h>
     23#include <UdpSocket.h>
    2424#include <cstring>
    2525#include <string>
     
    4444      new TcpSocket(getFrameworkManager(), "TEC_listening_socket", blocking, blocking);
    4545  dataSocket =
    46       new Socket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side
     46      new UdpSocket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side
    4747}
    4848
  • trunk/lib/FlairSensorActuator/src/TargetEthController.h

    r137 r178  
    2929class cvmatrix;
    3030class TcpSocket;
    31 class Socket;
     31class UdpSocket;
    3232}
    3333namespace gui {
     
    7878  int listeningPort;
    7979  core::TcpSocket *controlSocket = NULL;
    80   core::Socket *dataSocket;
     80  core::UdpSocket *dataSocket;
    8181  std::string *axisName = NULL;
    8282  std::string *buttonName = NULL;
Note: See TracChangeset for help on using the changeset viewer.