OpenDDS  Snapshot(2023/04/28-20:55)
MulticastLoader.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 "MulticastLoader.h"
9 #include "MulticastInst.h"
10 
13 
14 namespace {
15  const char MULTICAST_NAME[] = "multicast";
16 }
17 
19 
20 namespace OpenDDS {
21 namespace DCPS {
22 
23 class MulticastType : public TransportType {
24 public:
25  const char* name() { return MULTICAST_NAME; }
26 
27  TransportInst_rch new_inst(const std::string& name)
28  {
29  return make_rch<MulticastInst>(name);
30  }
31 };
32 
33 int
34 MulticastLoader::init(int /*argc*/, ACE_TCHAR* /*argv*/[])
35 {
36  static bool initialized(false);
37 
38  if (initialized) return 0; // already initialized
39 
41  if (!registry->register_type(make_rch<MulticastType>())) {
42  return 0;
43  }
44 
46  registry->get_config(TransportRegistry::DEFAULT_CONFIG_NAME);
47 
48  TransportInst_rch default_unrel =
49  registry->create_inst(TransportRegistry::DEFAULT_INST_PREFIX
50  + std::string("0410_MCAST_UNRELIABLE"),
51  MULTICAST_NAME);
52  MulticastInst* mi = dynamic_cast<MulticastInst*>(default_unrel.in());
53  if (!mi) {
54  ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) MulticastLoader::init:")
55  ACE_TEXT(" failed to obtain MulticastInst.\n")), -1);
56  }
57  mi->reliable_ = false;
58  cfg->sorted_insert(default_unrel);
59 
60  TransportInst_rch default_rel =
61  registry->create_inst(TransportRegistry::DEFAULT_INST_PREFIX
62  + std::string("0420_MCAST_RELIABLE"), MULTICAST_NAME);
63  cfg->sorted_insert(default_rel);
64 
65  initialized = true;
66 
67  return 0;
68 }
69 
70 ACE_FACTORY_DEFINE(OpenDDS_Multicast, MulticastLoader)
73  ACE_TEXT("OpenDDS_Multicast"),
77  0)
78 
79 } // namespace DCPS
80 } // namespace OpenDDS
81 
#define TheTransportRegistry
ACE_FACTORY_DEFINE(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
& ACE_SVC_NAME(TAO_AV_TCP_Factory)
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
TransportInst_rch new_inst(const std::string &name)
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
#define ACE_ERROR_RETURN(X, Y)
LM_ERROR
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
bool register_type(const TransportType_rch &type)