Merge pull request #2218 from jwillemsen/jwi-pthreadsigmask
[ACE_TAO.git] / TAO / tao / Strategies / SHMIOP_Factory.cpp
blob88ad0f33aa3d93e8d84ef7bd7e6bbcd4356ef7c1
1 #include "tao/Strategies/SHMIOP_Factory.h"
3 #if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0)
5 #include "tao/Strategies/SHMIOP_Acceptor.h"
6 #include "tao/Strategies/SHMIOP_Connector.h"
8 #include "tao/ORB_Constants.h"
10 #include "ace/Arg_Shifter.h"
11 #include "ace/Argv_Type_Converter.h"
12 #include "ace/OS_NS_strings.h"
14 static const char prefix_[] = "shmiop";
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
18 TAO_SHMIOP_Protocol_Factory::TAO_SHMIOP_Protocol_Factory ()
19 : TAO_Protocol_Factory (TAO_TAG_SHMEM_PROFILE),
20 mmap_prefix_ (0),
21 min_bytes_ (10*1024) // @@ Nanbor, remove this magic number!!
25 TAO_SHMIOP_Protocol_Factory::~TAO_SHMIOP_Protocol_Factory ()
27 delete [] this->mmap_prefix_;
30 int
31 TAO_SHMIOP_Protocol_Factory::match_prefix (const ACE_CString &prefix)
33 // Check for the proper prefix for this protocol.
34 return (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_) == 0);
37 const char *
38 TAO_SHMIOP_Protocol_Factory::prefix () const
40 return ::prefix_;
43 char
44 TAO_SHMIOP_Protocol_Factory::options_delimiter () const
46 return '/';
49 TAO_Acceptor *
50 TAO_SHMIOP_Protocol_Factory::make_acceptor ()
52 TAO_SHMIOP_Acceptor *acceptor = 0;
54 ACE_NEW_RETURN (acceptor,
55 TAO_SHMIOP_Acceptor,
56 0);
58 acceptor->set_mmap_options (this->mmap_prefix_,
59 this->min_bytes_);
61 return acceptor;
64 int
65 TAO_SHMIOP_Protocol_Factory::init (int argc,
66 ACE_TCHAR* argv[])
68 // Copy command line parameter not to use original as well as type conversion.
69 ACE_Argv_Type_Converter command_line(argc, argv);
71 ACE_Arg_Shifter arg_shifter (command_line.get_argc(), command_line.get_TCHAR_argv());
73 while (arg_shifter.is_anything_left ())
75 const ACE_TCHAR *current_arg = 0;
77 if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-MMAPFileSize"))))
79 this->min_bytes_ = ACE_OS::atoi (current_arg);
80 arg_shifter.consume_arg ();
82 else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-MMAPFilePrefix"))))
84 this->mmap_prefix_ = ACE::strnew (current_arg);
85 arg_shifter.consume_arg ();
87 else
88 // Any arguments that don't match are ignored so that the
89 // caller can still use them.
90 arg_shifter.ignore_arg ();
93 return 0;
96 TAO_Connector *
97 TAO_SHMIOP_Protocol_Factory::make_connector ()
99 TAO_Connector *connector = 0;
101 ACE_NEW_RETURN (connector,
102 TAO_SHMIOP_Connector,
104 return connector;
108 TAO_SHMIOP_Protocol_Factory::requires_explicit_endpoint () const
110 return 1;
114 ACE_STATIC_SVC_DEFINE (TAO_SHMIOP_Protocol_Factory,
115 ACE_TEXT ("SHMIOP_Factory"),
116 ACE_SVC_OBJ_T,
117 &ACE_SVC_NAME (TAO_SHMIOP_Protocol_Factory),
118 ACE_Service_Type::DELETE_THIS |
119 ACE_Service_Type::DELETE_OBJ,
122 ACE_FACTORY_DEFINE (TAO_Strategies, TAO_SHMIOP_Protocol_Factory)
124 TAO_END_VERSIONED_NAMESPACE_DECL
126 #endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */