Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / tao / Strategies / COIOP_Connector.cpp
blob22df884473007085740b9817c11968e396cbbb44
1 #include "tao/Strategies/COIOP_Connector.h"
3 #if defined (TAO_HAS_COIOP) && (TAO_HAS_COIOP != 0)
5 #include "ace/Connector.h"
6 #include "tao/debug.h"
7 #include "tao/ORB_Core.h"
8 #include "tao/SystemException.h"
9 #include "ace/OS_NS_strings.h"
10 #include "ace/OS_NS_string.h"
11 #include "tao/Strategies/COIOP_Profile.h"
12 #include <cstring>
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 TAO_COIOP_Connector::TAO_COIOP_Connector ()
17 : TAO_Connector (TAO_TAG_COIOP_PROFILE)
21 int
22 TAO_COIOP_Connector::open (TAO_ORB_Core *orb_core)
24 this->orb_core (orb_core);
26 // Create our connect strategy
27 if (this->create_connect_strategy () == -1)
28 return -1;
30 return 0;
33 int
34 TAO_COIOP_Connector::close ()
36 return 0;
39 int
40 TAO_COIOP_Connector::set_validate_endpoint (TAO_Endpoint *endpoint)
42 TAO_COIOP_Endpoint *COIOP_endpoint =
43 this->remote_endpoint (endpoint);
45 if (COIOP_endpoint == 0)
46 return -1;
48 return 0;
51 TAO_Transport *
52 TAO_COIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *,
53 TAO_Transport_Descriptor_Interface &,
54 ACE_Time_Value * /*max_wait_time*/)
56 // No remote connection possible with COIOP
57 return 0;
60 TAO_Profile *
61 TAO_COIOP_Connector::create_profile (TAO_InputCDR& cdr)
63 TAO_Profile *pfile = 0;
64 ACE_NEW_RETURN (pfile,
65 TAO_COIOP_Profile (this->orb_core ()),
66 0);
68 int const r = pfile->decode (cdr);
69 if (r == -1)
71 pfile->_decr_refcnt ();
72 pfile = 0;
75 return pfile;
78 TAO_Profile *
79 TAO_COIOP_Connector::make_profile ()
81 // The endpoint should be of the form:
82 // N.n@uuid/object_key
83 // or:
84 // uuid/object_key
86 TAO_Profile *profile = 0;
87 ACE_NEW_THROW_EX (profile,
88 TAO_COIOP_Profile (this->orb_core ()),
89 CORBA::NO_MEMORY (
90 CORBA::SystemException::_tao_minor_code (
91 TAO::VMCID,
92 ENOMEM),
93 CORBA::COMPLETED_NO));
95 return profile;
98 int
99 TAO_COIOP_Connector::check_prefix (const char *endpoint)
101 // Check for a valid string
102 if (!endpoint || !*endpoint)
103 return -1; // Failure
105 const char *protocol[] = { "COIOP", "COIOPloc" };
107 size_t const slot = std::strchr (endpoint, ':') - endpoint;
109 size_t const len0 = std::strlen (protocol[0]);
110 size_t const len1 = std::strlen (protocol[1]);
112 // Check for the proper prefix in the IOR. If the proper prefix
113 // isn't in the IOR then it is not an IOR we can use.
114 if (slot == len0
115 && ACE_OS::strncasecmp (endpoint, protocol[0], len0) == 0)
116 return 0;
117 else if (slot == len1
118 && ACE_OS::strncasecmp (endpoint, protocol[1], len1) == 0)
119 return 0;
121 return -1;
122 // Failure: not an COIOP IOR
123 // DO NOT throw an exception here.
126 char
127 TAO_COIOP_Connector::object_key_delimiter () const
129 return TAO_COIOP_Profile::object_key_delimiter_;
132 TAO_COIOP_Endpoint *
133 TAO_COIOP_Connector::remote_endpoint (TAO_Endpoint *endpoint)
135 if (endpoint->tag () != TAO_TAG_COIOP_PROFILE)
136 return 0;
138 TAO_COIOP_Endpoint *COIOP_endpoint =
139 dynamic_cast<TAO_COIOP_Endpoint *> (endpoint );
141 return COIOP_endpoint;
145 TAO_COIOP_Connector::cancel_svc_handler (
146 TAO_Connection_Handler * /* svc_handler */)
148 return 0;
151 TAO_END_VERSIONED_NAMESPACE_DECL
153 #endif /* TAO_HAS_COIOP && TAO_HAS_COIOP != 0 */