OpenDDS  Snapshot(2023/04/28-20:55)
UdpLoader.cpp
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #include "UdpLoader.h"
9 #include "UdpSendStrategy.h"
10 #include "UdpReceiveStrategy.h"
11 #include "UdpDataLink.h"
12 #include "UdpTransport.h"
13 #include "UdpInst.h"
14 
17 
18 namespace {
19  const char UDP_NAME[] = "udp";
20 }
21 
23 
24 namespace OpenDDS {
25 namespace DCPS {
26 
27 class UdpType : public TransportType {
28 public:
29  const char* name() { return UDP_NAME; }
30 
31  TransportInst_rch new_inst(const std::string& name)
32  {
33  return make_rch<UdpInst>(name);
34  }
35 };
36 
37 int
38 UdpLoader::init(int /*argc*/, ACE_TCHAR* /*argv*/[])
39 {
40  static bool initialized(false);
41 
42  if (initialized) return 0; // already initialized
43 
45  if (!registry->register_type(make_rch<UdpType>())) {
46  return 0;
47  }
48 
49  TransportInst_rch default_inst =
50  registry->create_inst(TransportRegistry::DEFAULT_INST_PREFIX +
51  std::string("0300_UDP"), UDP_NAME);
52  registry->get_config(TransportRegistry::DEFAULT_CONFIG_NAME)
53  ->sorted_insert(default_inst);
54 
55  initialized = true;
56 
57  return 0;
58 }
59 
60 ACE_FACTORY_DEFINE(OpenDDS_Udp, UdpLoader);
62  UdpLoader,
63  ACE_TEXT("OpenDDS_Udp"),
67  0)
68 
69 } // namespace DCPS
70 } // namespace OpenDDS
71 
#define TheTransportRegistry
TransportInst_rch new_inst(const std::string &name)
Definition: UdpLoader.cpp:31
& ACE_SVC_NAME(TAO_AV_TCP_Factory)
const char * name()
Definition: UdpLoader.cpp:29
ACE_STATIC_SVC_DEFINE(ACE_Logging_Strategy, ACE_TEXT("Logging_Strategy"), ACE_Service_Type::SERVICE_OBJECT, &ACE_SVC_NAME(ACE_Logging_Strategy), ACE_Service_Type::DELETE_THIS|ACE_Service_Type::DELETE_OBJ, 0) extern "C" int _get_dll_unload_policy()
ACE_SVC_OBJ_T
char ACE_TCHAR
TransportConfig_rch get_config(const OPENDDS_STRING &name) const
TransportInst_rch create_inst(const OPENDDS_STRING &name, const OPENDDS_STRING &transport_type)
const char *const name
Definition: debug.cpp:60
ACE_TEXT("TCP_Factory")
Base class for concrete transports to provide new objects.
Definition: TransportType.h:37
void sorted_insert(const TransportInst_rch &inst)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
ACE_FACTORY_DEFINE(OpenDDS_Udp, UdpLoader)
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
bool register_type(const TransportType_rch &type)