Public Member Functions | Private Member Functions | Private Attributes

IIOPEndpointValue_i Class Reference

Implementation of the IIOP-Specific endpoint policy value. More...

#include <IIOPEndpointValue_i.h>

Inheritance diagram for IIOPEndpointValue_i:
Inheritance graph
[legend]
Collaboration diagram for IIOPEndpointValue_i:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 IIOPEndpointValue_i ()
 IIOPEndpointValue_i (const char *host, CORBA::UShort port)
virtual ~IIOPEndpointValue_i (void)
CORBA::Boolean is_equivalent (const TAO_Endpoint *endpoint) const
CORBA::Boolean validate_acceptor (TAO_Acceptor *, bool is_multi_prot) const
char * host (void)
 Host attribute get/set operators.
void host (const char *h)
CORBA::UShort port (void)
 Port attribute get/set operators.
void port (CORBA::UShort p)
CORBA::ULong protocol_tag (void)

Private Member Functions

CORBA::Boolean is_equivalent_i (CORBA::UShort port, const char *host) const

Private Attributes

CORBA::String_var host_
CORBA::UShort port_
ACE_INET_Addr addr_

Detailed Description

Implementation of the IIOP-Specific endpoint policy value.

This class is used by applications to create an instance of an endpoint value for constructing an EndpointPolicy. While the endpoint policy argument is of type EndpointPolicy::EndpointValueBase, always use instances of this type so that the endpoint policy framework is able to call the equivalency test method.

Definition at line 57 of file IIOPEndpointValue_i.h.


Constructor & Destructor Documentation

IIOPEndpointValue_i::IIOPEndpointValue_i (  ) 

Default Constructor. It is acceptable to create an empty value and modify the state via the attributes.

Definition at line 17 of file IIOPEndpointValue_i.cpp.

  :host_(""),
   port_(0)
{
}

IIOPEndpointValue_i::IIOPEndpointValue_i ( const char *  host,
CORBA::UShort  port 
)

Value initializing constructor, this is typically for creation of one-off values.

Definition at line 23 of file IIOPEndpointValue_i.cpp.

  :host_(host),
   port_(port)
{
  if (this->addr_.set(port, host) != 0 || host == 0 || host[0] == 0)
    this->addr_.set_type (-1);
}

IIOPEndpointValue_i::~IIOPEndpointValue_i ( void   )  [virtual]

Definition at line 31 of file IIOPEndpointValue_i.cpp.

{
}


Member Function Documentation

char * IIOPEndpointValue_i::host ( void   ) 

Host attribute get/set operators.

Definition at line 96 of file IIOPEndpointValue_i.cpp.

{
  return CORBA::string_dup (this->host_.in());
}

void IIOPEndpointValue_i::host ( const char *  h  ) 

Definition at line 102 of file IIOPEndpointValue_i.cpp.

{
  this->host_ = h;
  if (this->addr_.set(this->port_, this->host_.in ()) != 0)
    this->addr_.set_type (-1);
}

CORBA::Boolean IIOPEndpointValue_i::is_equivalent ( const TAO_Endpoint endpoint  )  const

The is_equivalent test is used by the endpoint policy framework for testing if a target endpoint is the same as the endpoint defined by this value.

Definition at line 36 of file IIOPEndpointValue_i.cpp.

{
  const TAO_IIOP_Endpoint *iep =
    dynamic_cast<const TAO_IIOP_Endpoint *>(endpoint);
  if (iep == 0)
    return 0;
  return this->addr_.get_type() != -1 ? this->addr_ == iep->object_addr() :
    this->is_equivalent_i (iep->port(), iep->host());
}

CORBA::Boolean IIOPEndpointValue_i::is_equivalent_i ( CORBA::UShort  port,
const char *  host 
) const [private]

Definition at line 47 of file IIOPEndpointValue_i.cpp.

{
  bool is_eq = this->port_ == port;
  if (is_eq)
    is_eq = (this->host_.in()[0] == '\0' ||
            ACE_OS::strcasecmp(host, this->host_.in()) == 0);
  return is_eq;
}

CORBA::UShort IIOPEndpointValue_i::port ( void   ) 

Port attribute get/set operators.

Definition at line 110 of file IIOPEndpointValue_i.cpp.

{
  return this->port_;
}

void IIOPEndpointValue_i::port ( CORBA::UShort  p  ) 

Definition at line 116 of file IIOPEndpointValue_i.cpp.

{
  this->port_ = p;
  if (this->addr_.set(this->port_, this->host_.in ()) != 0)
    this->addr_.set_type (-1);
}

CORBA::ULong IIOPEndpointValue_i::protocol_tag ( void   ) 

Definition at line 124 of file IIOPEndpointValue_i.cpp.

{
  return IOP::TAG_INTERNET_IOP;
}

CORBA::Boolean IIOPEndpointValue_i::validate_acceptor ( TAO_Acceptor acceptor,
bool  is_multi_prot 
) const

The validate_acceptor method is used during EndpointPolicy creation to ensure there is an acceptor which provides this endpoint. Currently the test is limited to only validating that the acceptor's tag is consistent, as the interfaces do not yet exist for examining the eventual TAO_Endpoint values the acceptor would produce.

Definition at line 58 of file IIOPEndpointValue_i.cpp.

{
  TAO_IIOP_Acceptor *iacc = dynamic_cast<TAO_IIOP_Acceptor *>(acceptor);
  if (iacc == 0)
    return false;

#if 0
  // @@@ mesnier_p@ociweb.com @@@
  // This test was originally intended to validate that there is an
  // acceptor available which supports the target endpoint. However,
  // variablility in the definition of a "hostname" makes this hard
  // to determine, without adding more overhead, probably to the
  // IIOP_Acceptor class.
  // I'm not sure this level of validation is really required, so
  // for now I'm just leaving it out.

  const ACE_INET_Addr * eps = iacc->endpoints ();
  CORBA::ULong eps_count = iacc->endpoint_count ();
  for (CORBA::ULong eps_idx = 0; eps_idx < eps_count; ++ eps_idx)
    {
      char hostname[513];
      eps[eps_idx].get_host_name(hostname,512);
      if (this->is_equivalent_i(eps[eps_idx].get_port_number(),hostname))
        return true;
    }
  return false;
#else
  // @@@ mesnier_p@ociweb.com @@@
  // Rather than blindly returning true, we need to reject defaulted
  // endpoint hosts except when the ORB has more than one protocol
  // acceptor defined;

  return is_multi_prot || this->host_.in()[0] != '\0';
#endif /* 0 */
}


Member Data Documentation

Definition at line 105 of file IIOPEndpointValue_i.h.

Definition at line 102 of file IIOPEndpointValue_i.h.

Definition at line 103 of file IIOPEndpointValue_i.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines