OpenDDS  Snapshot(2023/04/28-20:55)
TcpLoader.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 "TcpLoader.h"
9 #include "TcpInst.h"
13 
14 #include "tao/debug.h"
15 #include "ace/OS_NS_strings.h"
16 
17 namespace {
18  const char TCP_NAME[] = "tcp";
19 }
20 
22 
23 namespace OpenDDS {
24 namespace DCPS {
25 
26 TcpLoader::TcpLoader()
27 {
28  DBG_ENTRY_LVL("TcpLoader", "TcpLoader", 6);
29 }
30 
31 TcpLoader::~TcpLoader()
32 {
33  DBG_ENTRY_LVL("TcpLoader", "~TcpLoader", 6);
34 }
35 
36 class TcpType : public TransportType {
37 public:
38  const char* name() { return TCP_NAME; }
39 
40  TransportInst_rch new_inst(const std::string& name)
41  {
42  return make_rch<TcpInst>(name);
43  }
44 };
45 
46 int
47 TcpLoader::init(int, ACE_TCHAR*[])
48 {
49  DBG_ENTRY_LVL("TcpLoader", "init", 6);
50 
51  static bool initialized = false;
52 
53  // Only allow initialization once.
54  if (initialized)
55  return 0;
56 
58  if (!registry->register_type(make_rch<TcpType>())) {
59  return 0;
60  }
61 
62  TransportInst_rch default_inst =
63  registry->create_inst(TransportRegistry::DEFAULT_INST_PREFIX +
64  std::string("0500_TCP"), TCP_NAME);
65  registry->get_config(TransportRegistry::DEFAULT_CONFIG_NAME)
66  ->sorted_insert(default_inst);
67 
68  initialized = true;
69  return 0;
70 }
71 
72 /////////////////////////////////////////////////////////////////////
73 
74 ACE_FACTORY_DEFINE(OpenDDS_Tcp, TcpLoader)
76  ACE_TEXT("OpenDDS_Tcp"),
81  0)
82 }
83 }
84 
#define TheTransportRegistry
ACE_FACTORY_DEFINE(OpenDDS_InfoRepoDiscovery, IRDiscoveryLoader)
const char * name()
Definition: TcpLoader.cpp:38
& 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
char ACE_TCHAR
TransportConfig_rch get_config(const OPENDDS_STRING &name) const
TransportInst_rch new_inst(const std::string &name)
Definition: TcpLoader.cpp:40
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")
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
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
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
bool register_type(const TransportType_rch &type)