MEM_Addr.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    MEM_Addr.h
00006  *
00007  *  $Id: MEM_Addr.h 80826 2008-03-04 14:51:23Z wotte $
00008  *
00009  *  @author Nanbor Wang <nanbor@cs.wustl.edu>
00010  */
00011 //==========================================================================
00012 
00013 
00014 #ifndef ACE_MEM_ADDR_H
00015 #define ACE_MEM_ADDR_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include /**/ "ace/ACE_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00025 
00026 #include "ace/INET_Addr.h"
00027 
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 /**
00031  * @class ACE_MEM_Addr
00032  *
00033  * @brief Defines a C++ wrapper facade for the shared memory transport
00034  * address family format.
00035  */
00036 class ACE_Export ACE_MEM_Addr : public ACE_Addr
00037 {
00038 public:
00039   // = Initialization methods.
00040   /// Default constructor.
00041   ACE_MEM_Addr (void);
00042 
00043   /// Copy constructor.
00044   ACE_MEM_Addr (const ACE_MEM_Addr &);
00045 
00046   /// Creates an ACE_MEM_Addr from a @a port_number
00047   ACE_MEM_Addr (u_short port_number);
00048 
00049   /// Creates an ACE_MEM_Addr from a @a port_name.
00050   explicit ACE_MEM_Addr (const ACE_TCHAR port_name[]);
00051 
00052   /// Default dtor.
00053   ~ACE_MEM_Addr (void);
00054 
00055   // = Direct initialization methods.
00056 
00057   /// Default initialization routine.
00058   int initialize_local (u_short port);
00059 
00060   /// Check if @a sap designates an endpoint on the same host.
00061   int same_host (const ACE_INET_Addr& sap);
00062 
00063   // These methods are useful after the object has been constructed.
00064 
00065   /**
00066    * Initializes an ACE_MEM_Addr from a @a port_number.  If @a encode
00067    * is enabled then @a port_number is converted into network byte order,
00068    * otherwise it is assumed to be in network byte order already and
00069    * are passed straight through.
00070    */
00071   int set (u_short port_number, int encode = 1);
00072 
00073   /// Uses <getservbyname> to initialize an ACE_MEM_Addr from a
00074   /// <port_name>, the remote <host_name>, and the <protocol>.
00075   int set (const ACE_TCHAR port_name[]);
00076 
00077   /// Return a pointer to the underlying network address.
00078   virtual void *get_addr (void) const;
00079 
00080   /// Set a pointer to the address.
00081   virtual void set_addr (void *, int len);
00082 
00083   /// Transform the external ACE_MEM_Addr address into string
00084   /// format.
00085   virtual int addr_to_string (ACE_TCHAR buffer[],
00086                               size_t size,
00087                               int ipaddr_format = 1) const;
00088 
00089   /// Initializes the external ACE_MEM_Addr from the @a address.
00090   virtual int string_to_addr (const ACE_TCHAR address[]);
00091 
00092   /// Sets the port number.
00093   void set_port_number (u_short,
00094                         int encode = 1);
00095 
00096   /// Return the port number, converting it into host byte order.
00097   u_short get_port_number (void) const;
00098 
00099   /// Return the character representation of the hostname.
00100   int get_host_name (ACE_TCHAR hostname[],
00101                      size_t hostnamelen) const;
00102 
00103   /**
00104    * Return the character representation of the hostname (this version
00105    * is non-reentrant since it returns a pointer to a static data
00106    * area).
00107    */
00108   const char *get_host_name (void) const;
00109 
00110   /// Return the "dotted decimal" external address.
00111   const char *get_host_addr (void) const;
00112 
00113   /// Return the 4-byte external IP address, converting it into host byte
00114   /// order.
00115   ACE_UINT32 get_ip_address (void) const;
00116 
00117   const ACE_INET_Addr &get_remote_addr (void) const;
00118   const ACE_INET_Addr &get_local_addr (void) const;
00119 
00120   /// Compare two addresses for equality.  The addresses are considered
00121   /// equal if they contain the same IP address and port number.
00122   bool operator == (const ACE_MEM_Addr &SAP) const;
00123   bool operator == (const ACE_INET_Addr &SAP) const;
00124 
00125   /// Compare two addresses for inequality.
00126   bool operator != (const ACE_MEM_Addr &SAP) const;
00127   bool operator != (const ACE_INET_Addr &SAP) const;
00128 
00129   /// Computes and returns hash value.
00130   virtual u_long hash (void) const;
00131 
00132   /// Dump the state of an object.
00133   void dump (void) const;
00134 
00135   /// Declare the dynamic allocation hooks.
00136   ACE_ALLOC_HOOK_DECLARE;
00137 
00138 private:
00139   /// External INET addr used for identifying host.
00140   ACE_INET_Addr external_;
00141 
00142   /// Internal INET addr for accepting/connecting.
00143   ACE_INET_Addr internal_;
00144 };
00145 
00146 ACE_END_VERSIONED_NAMESPACE_DECL
00147 
00148 #if defined (__ACE_INLINE__)
00149 #include "ace/MEM_Addr.inl"
00150 #endif /* __ACE_INLINE__ */
00151 
00152 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00153 
00154 #include /**/ "ace/post.h"
00155 #endif /* ACE_MEM_ADDR_H */

Generated on Tue Feb 2 17:18:40 2010 for ACE by  doxygen 1.4.7