Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / MEM_Addr.h
blob60306b5af8551e885d449c421bfe3a10b3afd3b6
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file MEM_Addr.h
7 * @author Nanbor Wang <nanbor@cs.wustl.edu>
8 */
9 //==========================================================================
12 #ifndef ACE_MEM_ADDR_H
13 #define ACE_MEM_ADDR_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/ACE_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
24 #include "ace/INET_Addr.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 /**
29 * @class ACE_MEM_Addr
31 * @brief Defines a C++ wrapper facade for the shared memory transport
32 * address family format.
34 class ACE_Export ACE_MEM_Addr : public ACE_Addr
36 public:
37 /// Default constructor.
38 ACE_MEM_Addr ();
40 /// Copy constructor.
41 ACE_MEM_Addr (const ACE_MEM_Addr &);
43 /// Assignment operator
44 ACE_MEM_Addr& operator= (const ACE_MEM_Addr&) = default;
46 /// Creates an ACE_MEM_Addr from a @a port_number
47 ACE_MEM_Addr (u_short port_number);
49 /// Creates an ACE_MEM_Addr from a @a port_name.
50 explicit ACE_MEM_Addr (const ACE_TCHAR port_name[]);
52 /// Default dtor.
53 ~ACE_MEM_Addr () = default;
55 // = Direct initialization methods.
57 /// Default initialization routine.
58 int initialize_local (u_short port);
60 /// Check if @a sap designates an endpoint on the same host.
61 int same_host (const ACE_INET_Addr& sap);
63 // These methods are useful after the object has been constructed.
65 /**
66 * Initializes an ACE_MEM_Addr from a @a port_number. If @a encode
67 * is enabled then @a port_number is converted into network byte order,
68 * otherwise it is assumed to be in network byte order already and
69 * are passed straight through.
71 int set (u_short port_number, int encode = 1);
73 /// Uses <getservbyname> to initialize an ACE_MEM_Addr from a
74 /// @a port_name, the remote <host_name>, and the <protocol>.
75 int set (const ACE_TCHAR port_name[]);
77 /// Return a pointer to the underlying network address.
78 virtual void *get_addr () const;
80 /// Set a pointer to the address.
81 virtual void set_addr (const void *, int len);
83 /// Transform the external ACE_MEM_Addr address into string
84 /// format.
85 virtual int addr_to_string (ACE_TCHAR buffer[],
86 size_t size,
87 int ipaddr_format = 1) const;
89 /// Initializes the external ACE_MEM_Addr from the @a address.
90 virtual int string_to_addr (const ACE_TCHAR address[]);
92 /// Sets the port number.
93 void set_port_number (u_short,
94 int encode = 1);
96 /// Return the port number, converting it into host byte order.
97 u_short get_port_number () const;
99 /// Return the character representation of the hostname.
100 int get_host_name (ACE_TCHAR hostname[],
101 size_t hostnamelen) const;
104 * Return the character representation of the hostname (this version
105 * is non-reentrant since it returns a pointer to a static data
106 * area).
108 const char *get_host_name () const;
111 * Return the "dotted decimal" external Internet address representation of
112 * the hostname storing it in the @a addr (which is assumed to be
113 * @a addr_size bytes long). This version is reentrant.
115 const char *get_host_addr (char *addr, int addr_size) const;
118 * Return the "dotted decimal" external Internet address representation of
119 * the hostname. This version is non-reentrant since it returns a
120 * pointer to a static data area. You should therefore either
121 * (1) do a "deep copy" of the address returned by get_host_addr(), e.g.,
122 * using strdup() or (2) use the "reentrant" version of
123 * get_host_addr() described above.
125 const char *get_host_addr () const;
127 /// Return the 4-byte external IP address, converting it into host byte
128 /// order.
129 ACE_UINT32 get_ip_address () const;
131 const ACE_INET_Addr &get_remote_addr () const;
132 const ACE_INET_Addr &get_local_addr () const;
134 /// Compare two addresses for equality. The addresses are considered
135 /// equal if they contain the same IP address and port number.
136 bool operator == (const ACE_MEM_Addr &SAP) const;
137 bool operator == (const ACE_INET_Addr &SAP) const;
139 /// Compare two addresses for inequality.
140 bool operator != (const ACE_MEM_Addr &SAP) const;
141 bool operator != (const ACE_INET_Addr &SAP) const;
143 /// Computes and returns hash value.
144 virtual u_long hash () const;
146 /// Dump the state of an object.
147 void dump () const;
149 /// Declare the dynamic allocation hooks.
150 ACE_ALLOC_HOOK_DECLARE;
152 private:
153 /// External INET addr used for identifying host.
154 ACE_INET_Addr external_;
156 /// Internal INET addr for accepting/connecting.
157 ACE_INET_Addr internal_;
160 ACE_END_VERSIONED_NAMESPACE_DECL
162 #if defined (__ACE_INLINE__)
163 #include "ace/MEM_Addr.inl"
164 #endif /* __ACE_INLINE__ */
166 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
168 #include /**/ "ace/post.h"
169 #endif /* ACE_MEM_ADDR_H */