TcpLoader.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "Tcp_pch.h"
00009 
00010 #include "TcpLoader.h"
00011 #include "TcpInst.h"
00012 #include "dds/DCPS/transport/framework/TransportRegistry.h"
00013 #include "dds/DCPS/transport/framework/TransportType.h"
00014 #include "dds/DCPS/transport/framework/EntryExit.h"
00015 
00016 #include "tao/debug.h"
00017 #include "ace/OS_NS_strings.h"
00018 
00019 namespace {
00020   const char TCP_NAME[] = "tcp";
00021 }
00022 
00023 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00024 
00025 namespace OpenDDS {
00026 namespace DCPS {
00027 
00028 TcpLoader::TcpLoader()
00029 {
00030   DBG_ENTRY_LVL("TcpLoader", "TcpLoader", 6);
00031 }
00032 
00033 TcpLoader::~TcpLoader()
00034 {
00035   DBG_ENTRY_LVL("TcpLoader", "~TcpLoader", 6);
00036 }
00037 
00038 class TcpType : public TransportType {
00039 public:
00040   const char* name() { return TCP_NAME; }
00041 
00042   TransportInst_rch new_inst(const std::string& name)
00043   {
00044     return make_rch<TcpInst>(name);
00045   }
00046 };
00047 
00048 int
00049 TcpLoader::init(int, ACE_TCHAR*[])
00050 {
00051   DBG_ENTRY_LVL("TcpLoader", "init", 6);
00052 
00053   static bool initialized = false;
00054 
00055   // Only allow initialization once.
00056   if (initialized)
00057     return 0;
00058 
00059   TransportRegistry* registry = TheTransportRegistry;
00060   registry->register_type(make_rch<TcpType>());
00061   TransportInst_rch default_inst =
00062     registry->create_inst(TransportRegistry::DEFAULT_INST_PREFIX +
00063                           std::string("0500_TCP"), TCP_NAME);
00064   registry->get_config(TransportRegistry::DEFAULT_CONFIG_NAME)
00065     ->sorted_insert(default_inst);
00066 
00067   initialized = true;
00068   return 0;
00069 }
00070 
00071 /////////////////////////////////////////////////////////////////////
00072 
00073 ACE_FACTORY_DEFINE(OpenDDS_Tcp, TcpLoader)
00074 ACE_STATIC_SVC_DEFINE(TcpLoader,
00075                       ACE_TEXT("OpenDDS_Tcp"),
00076                       ACE_SVC_OBJ_T,
00077                       &ACE_SVC_NAME(TcpLoader),
00078                       ACE_Service_Type::DELETE_THIS
00079                       | ACE_Service_Type::DELETE_OBJ,
00080                       0)
00081 }
00082 }
00083 
00084 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1