SHMIOP_Factory.cpp

Go to the documentation of this file.
00001 #include "tao/Strategies/SHMIOP_Factory.h"
00002 
00003 #if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0)
00004 
00005 #include "tao/Strategies/SHMIOP_Acceptor.h"
00006 #include "tao/Strategies/SHMIOP_Connector.h"
00007 
00008 #include "tao/ORB_Constants.h"
00009 
00010 #include "ace/Arg_Shifter.h"
00011 #include "ace/Argv_Type_Converter.h"
00012 #include "ace/OS_NS_strings.h"
00013 
00014 
00015 ACE_RCSID (Strategies,
00016            SHMIOP_Factory,
00017            "$Id: SHMIOP_Factory.cpp 74199 2006-08-23 12:50:53Z johnnyw $")
00018 
00019 
00020 static const char prefix_[] = "shmiop";
00021 
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023 
00024 TAO_SHMIOP_Protocol_Factory::TAO_SHMIOP_Protocol_Factory (void)
00025   : TAO_Protocol_Factory (TAO_TAG_SHMEM_PROFILE),
00026     mmap_prefix_ (0),
00027     min_bytes_ (10*1024)        // @@ Nanbor, remove this magic number!!
00028 {
00029 }
00030 
00031 TAO_SHMIOP_Protocol_Factory::~TAO_SHMIOP_Protocol_Factory (void)
00032 {
00033   delete [] this->mmap_prefix_;
00034 }
00035 
00036 int
00037 TAO_SHMIOP_Protocol_Factory::match_prefix (const ACE_CString &prefix)
00038 {
00039   // Check for the proper prefix for this protocol.
00040   return (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_) == 0);
00041 }
00042 
00043 const char *
00044 TAO_SHMIOP_Protocol_Factory::prefix (void) const
00045 {
00046   return ::prefix_;
00047 }
00048 
00049 char
00050 TAO_SHMIOP_Protocol_Factory::options_delimiter (void) const
00051 {
00052   return '/';
00053 }
00054 
00055 TAO_Acceptor *
00056 TAO_SHMIOP_Protocol_Factory::make_acceptor (void)
00057 {
00058   TAO_SHMIOP_Acceptor *acceptor = 0;
00059 
00060   ACE_NEW_RETURN (acceptor,
00061                   TAO_SHMIOP_Acceptor,
00062                   0);
00063 
00064   acceptor->set_mmap_options (this->mmap_prefix_,
00065                               this->min_bytes_);
00066 
00067   return acceptor;
00068 }
00069 
00070 int
00071 TAO_SHMIOP_Protocol_Factory::init (int argc,
00072                                    ACE_TCHAR* argv[])
00073 {
00074   // Copy command line parameter not to use original as well as type conversion.
00075   ACE_Argv_Type_Converter command_line(argc, argv);
00076 
00077   ACE_Arg_Shifter arg_shifter (command_line.get_argc(), command_line.get_TCHAR_argv());
00078 
00079   while (arg_shifter.is_anything_left ())
00080     {
00081       const ACE_TCHAR *current_arg = 0;
00082 
00083       if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-MMAPFileSize"))))
00084         {
00085           this->min_bytes_ = ACE_OS::atoi (current_arg);
00086           arg_shifter.consume_arg ();
00087         }
00088       else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-MMAPFilePrefix"))))
00089         {
00090           this->mmap_prefix_ = ACE::strnew (current_arg);
00091           arg_shifter.consume_arg ();
00092         }
00093       else
00094         // Any arguments that don't match are ignored so that the
00095         // caller can still use them.
00096         arg_shifter.ignore_arg ();
00097     }
00098 
00099   return 0;
00100 }
00101 
00102 TAO_Connector *
00103 TAO_SHMIOP_Protocol_Factory::make_connector (void)
00104 {
00105   TAO_Connector *connector = 0;
00106 
00107   ACE_NEW_RETURN (connector,
00108                   TAO_SHMIOP_Connector,
00109                   0);
00110   return connector;
00111 }
00112 
00113 int
00114 TAO_SHMIOP_Protocol_Factory::requires_explicit_endpoint (void) const
00115 {
00116   return 1;
00117 }
00118 
00119 TAO_END_VERSIONED_NAMESPACE_DECL
00120 
00121 ACE_STATIC_SVC_DEFINE (TAO_SHMIOP_Protocol_Factory,
00122                        ACE_TEXT ("SHMIOP_Factory"),
00123                        ACE_SVC_OBJ_T,
00124                        &ACE_SVC_NAME (TAO_SHMIOP_Protocol_Factory),
00125                        ACE_Service_Type::DELETE_THIS |
00126                                   ACE_Service_Type::DELETE_OBJ,
00127                        0)
00128 
00129 ACE_FACTORY_DEFINE (TAO_Strategies, TAO_SHMIOP_Protocol_Factory)
00130 
00131 #endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */

Generated on Tue Feb 2 17:47:18 2010 for TAO_Strategies by  doxygen 1.4.7