ACE_FILE_Addr Class Reference

Defines the FILE address family address format. More...

#include <FILE_Addr.h>

Inheritance diagram for ACE_FILE_Addr:

Inheritance graph
[legend]
Collaboration diagram for ACE_FILE_Addr:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_FILE_Addr (void)
 Default constructor.

 ACE_FILE_Addr (const ACE_FILE_Addr &sa)
 Copy constructor.

int set (const ACE_FILE_Addr &sa)
 ACE_FILE_Addr (const ACE_TCHAR *filename)
 Create a ACE_FILE_Addr from a pathname.

int set (const ACE_TCHAR *filename)
 Create a ACE_FILE_Addr from a pathname.

ACE_FILE_Addroperator= (const ACE_FILE_Addr &)
 Assignment operator.

virtual void * get_addr (void) const
 Return a pointer to the address.

virtual int addr_to_string (ACE_TCHAR *addr, size_t) const
 Transform the current address into string format.

bool operator== (const ACE_FILE_Addr &SAP) const
 Compare two addresses for equality.

bool operator!= (const ACE_FILE_Addr &SAP) const
 Compare two addresses for inequality.

const ACE_TCHARget_path_name (void) const
 Return the path name used for the rendezvous point.

void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Attributes

ACE_TCHAR filename_ [MAXPATHLEN+1]
 Name of the file.


Detailed Description

Defines the FILE address family address format.

Definition at line 34 of file FILE_Addr.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_FILE_Addr::ACE_FILE_Addr void   ) 
 

Default constructor.

Definition at line 20 of file FILE_Addr.cpp.

References ACE_TCHAR, AF_FILE, and filename_.

00021   : ACE_Addr (AF_FILE, sizeof this->filename_ / sizeof (ACE_TCHAR))
00022 {
00023   this->filename_[0] = '\0';
00024 }

ACE_FILE_Addr::ACE_FILE_Addr const ACE_FILE_Addr sa  ) 
 

Copy constructor.

Definition at line 70 of file FILE_Addr.cpp.

References AF_FILE, and set().

00071   : ACE_Addr (AF_FILE, sizeof this->filename_)
00072 {
00073   this->set (sa);
00074 }

ACE_FILE_Addr::ACE_FILE_Addr const ACE_TCHAR filename  )  [explicit]
 

Create a ACE_FILE_Addr from a pathname.

Definition at line 97 of file FILE_Addr.cpp.

References ACE_TCHAR, and set().

00098 {
00099   this->set (filename);
00100 }


Member Function Documentation

int ACE_FILE_Addr::addr_to_string ACE_TCHAR addr,
size_t 
const [virtual]
 

Transform the current address into string format.

Definition at line 103 of file FILE_Addr.cpp.

References ACE_TCHAR, and ACE_OS::strsncpy().

00104 {
00105   ACE_OS::strsncpy (s, this->filename_, len);
00106   return 0;
00107 }

void ACE_FILE_Addr::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_Addr.

Definition at line 118 of file FILE_Addr.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.

Referenced by ACE_FILE_IO::dump().

00119 {
00120 #if defined (ACE_HAS_DUMP)
00121   ACE_TRACE ("ACE_FILE_Addr::dump");
00122 
00123   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00124   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("filename_ = %s"), this->filename_));
00125   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00126 #endif /* ACE_HAS_DUMP */
00127 }

void * ACE_FILE_Addr::get_addr void   )  const [virtual]
 

Return a pointer to the address.

Reimplemented from ACE_Addr.

Definition at line 112 of file FILE_Addr.cpp.

References filename_.

00113 {
00114   return (void *) &this->filename_;
00115 }

ACE_INLINE const ACE_TCHAR * ACE_FILE_Addr::get_path_name void   )  const
 

Return the path name used for the rendezvous point.

Definition at line 29 of file FILE_Addr.inl.

References filename_.

Referenced by ACE_FILE_Connector::ACE_FILE_Connector(), and ACE_FILE_Connector::connect().

00030 {
00031   return this->filename_;
00032 }

ACE_INLINE bool ACE_FILE_Addr::operator!= const ACE_FILE_Addr SAP  )  const
 

Compare two addresses for inequality.

Definition at line 21 of file FILE_Addr.inl.

00022 {
00023   return !((*this) == sap);     // This is lazy, of course... ;-)
00024 }

ACE_FILE_Addr & ACE_FILE_Addr::operator= const ACE_FILE_Addr  ) 
 

Assignment operator.

Definition at line 88 of file FILE_Addr.cpp.

References set().

00089 {
00090   if (this != &sa)
00091     this->set (sa);
00092   return *this;
00093 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE bool ACE_FILE_Addr::operator== const ACE_FILE_Addr SAP  )  const
 

Compare two addresses for equality.

Definition at line 13 of file FILE_Addr.inl.

References filename_, and ACE_OS::strcmp().

00014 {
00015   return ACE_OS::strcmp (this->filename_, sap.filename_) == 0;
00016 }

int ACE_FILE_Addr::set const ACE_TCHAR filename  ) 
 

Create a ACE_FILE_Addr from a pathname.

Definition at line 77 of file FILE_Addr.cpp.

References ACE_TCHAR, AF_FILE, ACE_Addr::base_set(), and ACE_OS::strsncpy().

00078 {
00079   this->ACE_Addr::base_set (AF_FILE,
00080                             static_cast<int> (ACE_OS::strlen (filename) + 1));
00081   (void) ACE_OS::strsncpy (this->filename_,
00082                            filename,
00083                            sizeof this->filename_ / sizeof (ACE_TCHAR));
00084   return 0;
00085 }

int ACE_FILE_Addr::set const ACE_FILE_Addr sa  ) 
 

Acts like a copy constructor. If == ACE_Addr::sap_any then create a temporary filename using <ACE_OS::mktemp>.

Definition at line 27 of file FILE_Addr.cpp.

References ACE_ERROR, ACE_LIB_TEXT, AF_ANY, AF_FILE, ACE_Addr::base_set(), filename_, ACE_Addr::get_size(), ACE::get_temp_dir(), ACE_Addr::get_type(), LM_ERROR, MAXPATHLEN, ACE_OS::mktemp(), ACE_OS::strcat(), ACE_OS::strcpy(), and ACE_OS::strsncpy().

Referenced by ACE_FILE_Addr(), ACE_FILE_Connector::connect(), and operator=().

00028 {
00029   if (sa.get_type () == AF_ANY)
00030     {
00031 #if defined (ACE_DEFAULT_TEMP_FILE)
00032       // Create a temporary file.
00033       ACE_OS::strcpy (this->filename_,
00034                       ACE_DEFAULT_TEMP_FILE);
00035 #else /* ACE_DEFAULT_TEMP_FILE */
00036       if (ACE::get_temp_dir (this->filename_,
00037                                       MAXPATHLEN - 15) == -1)
00038         // -15 for ace-file-XXXXXX
00039         {
00040           ACE_ERROR ((LM_ERROR,
00041                       ACE_LIB_TEXT ("Temporary path too long, ")
00042                       ACE_LIB_TEXT ("defaulting to current directory\n")));
00043           this->filename_[0] = 0;
00044         }
00045 
00046       // Add the filename to the end
00047       ACE_OS::strcat (this->filename_, ACE_LIB_TEXT ("ace-fileXXXXXX"));
00048 
00049 #endif /* ACE_DEFAULT_TEMP_FILE */
00050 
00051       if (ACE_OS::mktemp (this->filename_) == 0)
00052         return -1;
00053       this->base_set (AF_FILE,
00054                       static_cast<int> (ACE_OS::strlen (this->filename_) + 1));
00055     }
00056   else
00057     {
00058       (void) ACE_OS::strsncpy (this->filename_,
00059                                sa.filename_,
00060                                sa.get_size ());
00061 
00062       this->base_set (sa.get_type (),
00063                       sa.get_size ());
00064     }
00065   return 0;
00066 }


Member Data Documentation

ACE_FILE_Addr::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Addr.

Definition at line 76 of file FILE_Addr.h.

ACE_TCHAR ACE_FILE_Addr::filename_[MAXPATHLEN + 1] [private]
 

Name of the file.

Definition at line 80 of file FILE_Addr.h.

Referenced by ACE_FILE_Addr(), get_addr(), get_path_name(), operator==(), and set().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:22:14 2006 for ACE by doxygen 1.3.6