00001 /* -*- C++ -*- */ 00002 00003 //============================================================================= 00004 /** 00005 * @file FILE_Connector.h 00006 * 00007 * $Id: FILE_Connector.h 80826 2008-03-04 14:51:23Z wotte $ 00008 * 00009 * @author Doug Schmidt <schmidt@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_FILE_CONNECTOR_H 00014 #define ACE_FILE_CONNECTOR_H 00015 #include /**/ "ace/pre.h" 00016 00017 #include "ace/FILE_IO.h" 00018 #include "ace/Log_Msg.h" 00019 #include "ace/os_include/os_fcntl.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 /** 00028 * @class ACE_FILE_Connector 00029 * 00030 * @brief Defines an active connection factory for the ACE_FILE wrappers. 00031 * 00032 * Note that the O_APPEND flag is only partly supported on Win32. If 00033 * you specify O_APPEND, then the file pointer will be positioned at 00034 * the end of the file initially during open, but it is not 00035 * re-positioned at the end prior to each write, as specified by 00036 * POSIX. This is generally good enough for typical situations, but 00037 * it is ``not quite right'' in its semantics. 00038 */ 00039 class ACE_Export ACE_FILE_Connector 00040 { 00041 public: 00042 // = Initialization methods. 00043 /// Default constructor. 00044 ACE_FILE_Connector (void); 00045 00046 /** 00047 * Actively ``connect'' and produce a @a new_io ACE_FILE_IO object 00048 * if things go well. The @a remote_sap is the file that we are 00049 * trying to create/open. If it's the default value of 00050 * ACE_Addr::sap_any then the user is letting the OS create the 00051 * filename (via <ACE_OS::mkstemp>). The @a timeout is the amount of 00052 * time to wait to create/open the file. If it's 0 then we block 00053 * indefinitely. If *timeout == {0, 0} then the file is created 00054 * using non-blocking mode. If *timeout > {0, 0} then this is the 00055 * maximum amount of time to wait before timing out. The 00056 * @a local_sap and @a reuse_addr parameters are ignored. The @a flags 00057 * and @a perms arguments are passed down to the <ACE_OS::open> 00058 * method. 00059 */ 00060 ACE_FILE_Connector (ACE_FILE_IO &new_io, 00061 const ACE_FILE_Addr &remote_sap, 00062 ACE_Time_Value *timeout = 0, 00063 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00064 int reuse_addr = 0, 00065 int flags = O_RDWR | O_CREAT, 00066 int perms = ACE_DEFAULT_FILE_PERMS); 00067 00068 /** 00069 * Actively ``connect'' and produce a @a new_io <ACE_FILE_IO> object 00070 * if things go well. The @a remote_sap is the file that we are 00071 * trying to create/open. If it's the default value of 00072 * ACE_Addr::sap_any then the user is letting the OS create the 00073 * filename (via <ACE_OS::mkstemp>). The @a timeout is the amount of 00074 * time to wait to create/open the file. If it's 0 then we block 00075 * indefinitely. If *timeout == {0, 0} then the file is created 00076 * using non-blocking mode. In this case, if the create/open can't 00077 * be done immediately the value of -1 is returned with <errno == 00078 * EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of 00079 * time to wait before timing out. If the time expires before the 00080 * connection is made @c errno == ETIME. The @a local_sap and 00081 * @a reuse_addr parameters are ignored. The @a flags and @a perms 00082 * arguments are passed down to the <ACE_OS::open> method. 00083 */ 00084 int connect (ACE_FILE_IO &new_io, 00085 const ACE_FILE_Addr &remote_sap, 00086 ACE_Time_Value *timeout = 0, 00087 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00088 int reuse_addr = 0, 00089 int flags = O_RDWR | O_CREAT, 00090 int perms = ACE_DEFAULT_FILE_PERMS); 00091 00092 /// Resets any event associations on this handle 00093 int reset_new_handle (ACE_HANDLE handle); 00094 00095 /// Dump the state of an object. 00096 void dump (void) const; 00097 00098 /// Declare the dynamic allocation hooks. 00099 ACE_ALLOC_HOOK_DECLARE; 00100 00101 // = Meta-type "trait" information. 00102 typedef ACE_FILE_Addr PEER_ADDR; 00103 typedef ACE_FILE_IO PEER_STREAM; 00104 }; 00105 00106 ACE_END_VERSIONED_NAMESPACE_DECL 00107 00108 #if defined (__ACE_INLINE__) 00109 #include "ace/FILE_Connector.inl" 00110 #endif /* __ACE_INLINE__ */ 00111 00112 #include /**/ "ace/post.h" 00113 #endif /* ACE_FILE_CONNECTOR_H */