MEM_Addr.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    MEM_Addr.h
00006  *
00007  *  MEM_Addr.h,v 4.18 2006/02/09 17:03:20 jtc Exp
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,
00072            int encode = 1);
00073 
00074   /// Uses <getservbyname> to initialize an ACE_MEM_Addr from a
00075   /// <port_name>, the remote <host_name>, and the <protocol>.
00076   int set (const ACE_TCHAR port_name[]);
00077 
00078   /// Return a pointer to the underlying network address.
00079   virtual void *get_addr (void) const;
00080 
00081   /// Set a pointer to the address.
00082   virtual void set_addr (void *, int len);
00083 
00084   /// Transform the external ACE_MEM_Addr address into string
00085   /// format.
00086   virtual int addr_to_string (ACE_TCHAR buffer[],
00087                               size_t size,
00088                               int ipaddr_format = 1) const;
00089 
00090   /// Initializes the external ACE_MEM_Addr from the @a address.
00091   virtual int string_to_addr (const ACE_TCHAR address[]);
00092 
00093   /// Sets the port number.
00094   void set_port_number (u_short,
00095                         int encode = 1);
00096 
00097   /// Return the port number, converting it into host byte order.
00098   u_short get_port_number (void) const;
00099 
00100   /// Return the character representation of the hostname.
00101   int get_host_name (ACE_TCHAR hostname[],
00102                      size_t hostnamelen) const;
00103 
00104   /**
00105    * Return the character representation of the hostname (this version
00106    * is non-reentrant since it returns a pointer to a static data
00107    * area).
00108    */
00109   const char *get_host_name (void) const;
00110 
00111   /// Return the "dotted decimal" external address.
00112   const char *get_host_addr (void) const;
00113 
00114   /// Return the 4-byte external IP address, converting it into host byte
00115   /// order.
00116   ACE_UINT32 get_ip_address (void) const;
00117 
00118   const ACE_INET_Addr &get_remote_addr (void) const;
00119   const ACE_INET_Addr &get_local_addr (void) const;
00120 
00121   /// Compare two addresses for equality.  The addresses are considered
00122   /// equal if they contain the same IP address and port number.
00123   bool operator == (const ACE_MEM_Addr &SAP) const;
00124   bool operator == (const ACE_INET_Addr &SAP) const;
00125 
00126   /// Compare two addresses for inequality.
00127   bool operator != (const ACE_MEM_Addr &SAP) const;
00128   bool operator != (const ACE_INET_Addr &SAP) const;
00129 
00130   /// Computes and returns hash value.
00131   virtual u_long hash (void) const;
00132 
00133   /// Dump the state of an object.
00134   void dump (void) const;
00135 
00136   /// Declare the dynamic allocation hooks.
00137   ACE_ALLOC_HOOK_DECLARE;
00138 
00139 private:
00140   /// External INET addr used for identifying host.
00141   ACE_INET_Addr external_;
00142 
00143   /// Internal INET addr for accepting/connecting.
00144   ACE_INET_Addr internal_;
00145 };
00146 
00147 ACE_END_VERSIONED_NAMESPACE_DECL
00148 
00149 #if defined (__ACE_INLINE__)
00150 #include "ace/MEM_Addr.inl"
00151 #endif /* __ACE_INLINE__ */
00152 
00153 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00154 
00155 #include /**/ "ace/post.h"
00156 #endif /* ACE_MEM_ADDR_H */

Generated on Thu Nov 9 09:41:55 2006 for ACE by doxygen 1.3.6