MulticastLoader.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 "MulticastLoader.h"
00009 #include "MulticastInst.h"
00010 
00011 #include "dds/DCPS/transport/framework/TransportRegistry.h"
00012 #include "dds/DCPS/transport/framework/TransportType.h"
00013 
00014 namespace {
00015   const char MULTICAST_NAME[] = "multicast";
00016 }
00017 
00018 namespace OpenDDS {
00019 namespace DCPS {
00020 
00021 class MulticastType : public TransportType {
00022 public:
00023   const char* name() { return MULTICAST_NAME; }
00024 
00025   TransportInst* new_inst(const std::string& name)
00026   {
00027     return new MulticastInst(name);
00028   }
00029 };
00030 
00031 int
00032 MulticastLoader::init(int /*argc*/, ACE_TCHAR* /*argv*/[])
00033 {
00034   static bool initialized(false);
00035 
00036   if (initialized) return 0;  // already initialized
00037 
00038   TransportRegistry* registry = TheTransportRegistry;
00039   registry->register_type(new MulticastType);
00040   TransportConfig_rch cfg =
00041     registry->get_config(TransportRegistry::DEFAULT_CONFIG_NAME);
00042 
00043   TransportInst_rch default_unrel =
00044     registry->create_inst(TransportRegistry::DEFAULT_INST_PREFIX
00045                           + std::string("0410_MCAST_UNRELIABLE"),
00046                           MULTICAST_NAME);
00047   MulticastInst* mi = dynamic_cast<MulticastInst*>(default_unrel.in());
00048   mi->reliable_ = false;
00049   cfg->sorted_insert(default_unrel);
00050 
00051   TransportInst_rch default_rel =
00052     registry->create_inst(TransportRegistry::DEFAULT_INST_PREFIX
00053                           + std::string("0420_MCAST_RELIABLE"), MULTICAST_NAME);
00054   cfg->sorted_insert(default_rel);
00055 
00056   initialized = true;
00057 
00058   return 0;
00059 }
00060 
00061 ACE_FACTORY_DEFINE(OpenDDS_Multicast, MulticastLoader)
00062 ACE_STATIC_SVC_DEFINE(
00063   MulticastLoader,
00064   ACE_TEXT("OpenDDS_Multicast"),
00065   ACE_SVC_OBJ_T,
00066   &ACE_SVC_NAME(MulticastLoader),
00067   ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00068   0)
00069 
00070 } // namespace DCPS
00071 } // namespace OpenDDS

Generated on Fri Feb 12 20:05:24 2016 for OpenDDS by  doxygen 1.4.7