OpenDaVINCI  4.15.3
POSIXUDPFactoryWorker.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_CORE_WRAPPER_POSIX_POSIXUDPFACTORYWORKER_H_
21 #define OPENDAVINCI_CORE_WRAPPER_POSIX_POSIXUDPFACTORYWORKER_H_
22 
23 #include <iostream>
24 #include <sstream>
25 
27 
31 
34 
35 namespace odcore {
36  namespace wrapper {
37 
38  using namespace std;
39 
41  public:
42  static odcore::io::udp::UDPSender* createUDPSender(const string &address, const uint32_t &port) {
43  return new POSIX::POSIXUDPSender(address, port);
44  };
45 
46  static odcore::io::udp::UDPReceiver* createUDPReceiver(const string &address, const uint32_t &port) {
47  bool isMulticast = false;
48  string::size_type posFirstDot = address.find(".");
49  if (posFirstDot != string::npos) {
50  stringstream numericalValueStream(address.substr(0, posFirstDot));
51  uint32_t numericalValue = 0;
52  numericalValueStream >> numericalValue;
53  isMulticast = ( (numericalValue >= 224) && (numericalValue <= 239) );
54  CLOG3 << "Creating " << (isMulticast ? "multicast" : "regular") << " UDP receiver at " << address << ":" << port << "." << endl;
55  }
56  return new POSIX::POSIXUDPReceiver(address, port, isMulticast);
57  };
58  };
59 
60  }
61 } // odcore::wrapper
62 
63 #endif /*OPENDAVINCI_CORE_WRAPPER_POSIX_POSIXUDPFACTORYWORKER_H_*/
static odcore::io::udp::UDPReceiver * createUDPReceiver(const string &address, const uint32_t &port)
Definition: POSIXUDPFactoryWorker.h:46
Definition: UDPSender.h:60
Definition: POSIXUDPSender.h:47
static odcore::io::udp::UDPSender * createUDPSender(const string &address, const uint32_t &port)
Definition: POSIXUDPFactoryWorker.h:42
#define CLOG3
Definition: opendavinci.h:224
Definition: POSIXUDPReceiver.h:49
#define OPENDAVINCI_API
Definition: opendavinci.h:67
Definition: NetworkLibraryProducts.h:28
Definition: UDPReceiver.h:82
Definition: POSIXUDPReceiver.h:36