*Backed out changeset 3be01fb200a5

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 15:51:44 -07:00
parent 26b5e033ff
commit e585187b24
2257 changed files with 103863 additions and 761 deletions
File diff suppressed because it is too large Load Diff
+144
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file ACE.h
@@ -15,13 +16,18 @@
* @author Douglas C. Schmidt <[email protected]>
*/
//=============================================================================
#ifndef ACE_ACE_H
#define ACE_ACE_H
#include /**/ "ace/pre.h"
#include "ace/config-lite.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/OS_NS_math.h"
#include "ace/Flag_Manip.h"
#include "ace/Handle_Ops.h"
@@ -29,16 +35,20 @@
#include "ace/Init_ACE.h"
#include "ace/Sock_Connect.h"
#include "ace/Default_Constants.h"
#if defined (ACE_EXPORT_MACRO)
# undef ACE_EXPORT_MACRO
#endif
#define ACE_EXPORT_MACRO ACE_Export
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declarations.
class ACE_Time_Value;
class ACE_Message_Block;
class ACE_Handle_Set;
/**
* @namespace ACE
*
@@ -53,26 +63,35 @@ namespace ACE
// = ACE version information.
/// e.g., the "5" in ACE 5.1.12.
extern ACE_Export u_int major_version (void);
/// e.g., the "1" in ACE 5.1.12.
extern ACE_Export u_int minor_version (void);
/// e.g., the "12" in ACE 5.1.12.
/// Returns 0 for "stable" (non-beta) releases.
extern ACE_Export u_int beta_version (void);
// = C++ compiler version information.
/// E.g., the "SunPro C++" in SunPro C++ 4.32.0
extern ACE_Export const ACE_TCHAR * compiler_name (void);
/// E.g., the "4" in SunPro C++ 4.32.0
extern ACE_Export u_int compiler_major_version (void);
/// E.g., the "32" in SunPro C++ 4.32.0
extern ACE_Export u_int compiler_minor_version (void);
/// E.g., the "0" in SunPro C++ 4.32.0
extern ACE_Export u_int compiler_beta_version (void);
/// Check if error indicates the process being out of handles (file
/// descriptors).
extern ACE_Export int out_of_handles (int error);
/// Simple wildcard matching function supporting '*' and '?'
/// return true if string s matches pattern.
extern ACE_Export bool wild_match(const char* s, const char* pattern, bool case_sensitive = true);
/**
* @name I/O operations
*
@@ -127,21 +146,27 @@ namespace ACE
size_t len,
int flags,
const ACE_Time_Value *timeout = 0);
#if defined (ACE_HAS_TLI)
extern ACE_Export ssize_t t_rcv (ACE_HANDLE handle,
void *buf,
size_t len,
int *flags,
const ACE_Time_Value *timeout = 0);
#endif /* ACE_HAS_TLI */
extern ACE_Export ssize_t recv (ACE_HANDLE handle,
void *buf,
size_t len,
const ACE_Time_Value *timeout = 0);
extern ACE_Export ssize_t recvmsg (ACE_HANDLE handle,
struct msghdr *msg,
int flags,
const ACE_Time_Value *timeout = 0);
extern ACE_Export ssize_t recvfrom (ACE_HANDLE handle,
char *buf,
int len,
@@ -149,6 +174,7 @@ namespace ACE
struct sockaddr *addr,
int *addrlen,
const ACE_Time_Value *timeout = 0);
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t recv_n (ACE_HANDLE handle,
void *buf,
@@ -156,7 +182,9 @@ namespace ACE
int flags,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
#if defined (ACE_HAS_TLI)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t t_rcv_n (ACE_HANDLE handle,
void *buf,
@@ -164,13 +192,16 @@ namespace ACE
int *flags,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
#endif /* ACE_HAS_TLI */
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t recv_n (ACE_HANDLE handle,
void *buf,
size_t len,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
/// Receive into a variable number of pieces.
/**
* Accepts a variable, caller-specified, number of pointer/length
@@ -182,40 +213,50 @@ namespace ACE
* @return -1 on error, else total number of bytes received.
*/
extern ACE_Export ssize_t recv (ACE_HANDLE handle, size_t n, ...);
extern ACE_Export ssize_t recvv (ACE_HANDLE handle,
iovec *iov,
int iovcnt,
const ACE_Time_Value *timeout = 0);
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t recvv_n (ACE_HANDLE handle,
iovec *iov,
int iovcnt,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
extern ACE_Export ssize_t recv_n (ACE_HANDLE handle,
ACE_Message_Block *message_block,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
extern ACE_Export ssize_t send (ACE_HANDLE handle,
const void *buf,
size_t len,
int flags,
const ACE_Time_Value *timeout = 0);
#if defined (ACE_HAS_TLI)
extern ACE_Export ssize_t t_snd (ACE_HANDLE handle,
const void *buf,
size_t len,
int flags,
const ACE_Time_Value *timeout = 0);
#endif /* ACE_HAS_TLI */
extern ACE_Export ssize_t send (ACE_HANDLE handle,
const void *buf,
size_t len,
const ACE_Time_Value *timeout = 0);
extern ACE_Export ssize_t sendmsg (ACE_HANDLE handle,
const struct msghdr *msg,
int flags,
const ACE_Time_Value *timeout = 0);
extern ACE_Export ssize_t sendto (ACE_HANDLE handle,
const char *buf,
int len,
@@ -223,6 +264,7 @@ namespace ACE
const struct sockaddr *addr,
int addrlen,
const ACE_Time_Value *timeout = 0);
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t send_n (ACE_HANDLE handle,
const void *buf,
@@ -230,7 +272,9 @@ namespace ACE
int flags,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
#if defined (ACE_HAS_TLI)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t t_snd_n (ACE_HANDLE handle,
const void *buf,
@@ -238,25 +282,31 @@ namespace ACE
int flags,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
#endif /* ACE_HAS_TLI */
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t send_n (ACE_HANDLE handle,
const void *buf,
size_t len,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
/// Varargs variant.
extern ACE_Export ssize_t send (ACE_HANDLE handle, size_t n, ...);
extern ACE_Export ssize_t sendv (ACE_HANDLE handle,
const iovec *iov,
int iovcnt,
const ACE_Time_Value *timeout = 0);
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t sendv_n (ACE_HANDLE handle,
const iovec *iov,
int iovcnt,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
/// Send all the @a message_blocks chained through their @c next and
/// @c cont pointers. This call uses the underlying OS gather-write
/// operation to reduce the domain-crossing penalty.
@@ -264,32 +314,39 @@ namespace ACE
const ACE_Message_Block *message_block,
const ACE_Time_Value *timeout = 0,
size_t *bytes_transferred = 0);
// = File system I/O functions (these don't support timeouts).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t read_n (ACE_HANDLE handle,
void *buf,
size_t len,
size_t *bytes_transferred = 0);
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t write_n (ACE_HANDLE handle,
const void *buf,
size_t len,
size_t *bytes_transferred = 0);
/// Write all the @a message_blocks chained through their @c next
/// and @c cont pointers. This call uses the underlying OS
/// gather-write operation to reduce the domain-crossing penalty.
extern ACE_Export ssize_t write_n (ACE_HANDLE handle,
const ACE_Message_Block *message_block,
size_t *bytes_transferred = 0);
extern ACE_Export ssize_t readv_n (ACE_HANDLE handle,
iovec *iov,
int iovcnt,
size_t *bytes_transferred = 0);
extern ACE_Export ssize_t writev_n (ACE_HANDLE handle,
const iovec *iov,
int iovcnt,
size_t *bytes_transferred = 0);
//@}
/**
* Wait up to @a timeout amount of time to passively establish a
* connection. This method doesn't perform the @c accept, it just
@@ -298,6 +355,7 @@ namespace ACE
extern ACE_Export int handle_timed_accept (ACE_HANDLE listener,
ACE_Time_Value *timeout,
int restart);
/**
* Wait up to @a timeout amount of time to complete an actively
* established non-blocking connection. If @a is_tli is non-0 then
@@ -308,6 +366,7 @@ namespace ACE
ACE_HANDLE listener,
const ACE_Time_Value *timeout,
int is_tli = 0);
/**
* Reset the limit on the number of open handles. If @a new_limit
* == -1 set the limit to the maximum allowable. Otherwise, set
@@ -316,12 +375,14 @@ namespace ACE
*/
extern ACE_Export int set_handle_limit (int new_limit = -1,
int increase_limit_only = 0);
/**
* Returns the maximum number of open handles currently permitted in
* this process. This maximum may be extended using
* @c ACE::set_handle_limit.
*/
extern ACE_Export int max_handles (void);
// = String functions
#if !defined (ACE_HAS_WINCE)
/**
@@ -332,28 +393,40 @@ namespace ACE
*/
extern ACE_Export ACE_TCHAR *strenvdup (const ACE_TCHAR *str);
#endif /* ACE_HAS_WINCE */
/// Returns a pointer to the "end" of the string, i.e., the character
/// past the '\0'.
extern ACE_Export const char *strend (const char *s);
/// This method is just like @c strdup, except that it uses
/// @c operator @c new rather than @c malloc. If @a s is NULL
/// returns NULL rather than segfaulting.
extern ACE_Export char *strnew (const char *s);
/// Delete the memory allocated by @c strnew.
ACE_NAMESPACE_INLINE_FUNCTION void strdelete (char *s);
/// Create a fresh new copy of @a str, up to @a n chars long. Uses
/// @c ACE_OS::malloc to allocate the new string.
extern ACE_Export char *strndup (const char *str, size_t n);
/// Create a fresh new copy of @a str, up to @a n chars long. Uses
/// @c ACE_OS::malloc to allocate the new string.
extern ACE_Export char *strnnew (const char *str, size_t n);
#if defined (ACE_HAS_WCHAR)
extern ACE_Export const wchar_t *strend (const wchar_t *s);
extern ACE_Export wchar_t *strnew (const wchar_t *s);
ACE_NAMESPACE_INLINE_FUNCTION void strdelete (wchar_t *s);
extern ACE_Export wchar_t *strndup (const wchar_t *str, size_t n);
extern ACE_Export wchar_t *strnnew (const wchar_t *str, size_t n);
#endif /* ACE_HAS_WCHAR */
/**
* On Windows, determines if a specified pathname ends with ".exe"
* (not case sensitive). If on Windows and there is no ".exe" suffix,
@@ -371,6 +444,7 @@ namespace ACE
* memory using delete [].
*/
extern ACE_Export const ACE_TCHAR *execname (const ACE_TCHAR *pathname);
/**
* Returns the "basename" of a @a pathname separated by @a delim.
* For instance, the basename of "/tmp/foo.cpp" is "foo.cpp" when
@@ -379,6 +453,7 @@ namespace ACE
extern ACE_Export const ACE_TCHAR *basename (const ACE_TCHAR *pathname,
ACE_TCHAR delim =
ACE_DIRECTORY_SEPARATOR_CHAR);
/**
* Returns the "dirname" of a @a pathname. For instance, the
* dirname of "/tmp/foo.cpp" is "/tmp" when @a delim is @a '/'. If
@@ -388,6 +463,7 @@ namespace ACE
extern ACE_Export const ACE_TCHAR *dirname (const ACE_TCHAR *pathname,
ACE_TCHAR delim =
ACE_DIRECTORY_SEPARATOR_CHAR);
/**
* Returns the current timestamp in the form
* "hour:minute:second:microsecond." The month, day, and year are
@@ -402,6 +478,7 @@ namespace ACE
extern ACE_Export ACE_TCHAR *timestamp (ACE_TCHAR date_and_time[],
size_t time_len,
bool return_pointer_to_first_digit = false);
/**
* if @a avoid_zombies == 0 call @c ACE_OS::fork directly, else
* create an orphan process that's inherited by the init process;
@@ -414,6 +491,7 @@ namespace ACE
extern ACE_Export pid_t fork (
const ACE_TCHAR *program_name = ACE_TEXT ("<unknown>"),
int avoid_zombies = 0);
/**
* Become a daemon process using the algorithm in Richard Stevens
* "Advanced Programming in the UNIX Environment." If
@@ -424,47 +502,63 @@ namespace ACE
const ACE_TCHAR pathname[] = ACE_TEXT ("/"),
bool close_all_handles = ACE_DEFAULT_CLOSE_ALL_HANDLES,
const ACE_TCHAR program_name[] = ACE_TEXT ("<unknown>"));
// = Miscellaneous functions.
/// Rounds the request to a multiple of the page size.
extern ACE_Export size_t round_to_pagesize (size_t len);
/// Rounds the request to a multiple of the allocation granularity.
extern ACE_Export size_t round_to_allocation_granularity (size_t len);
// @@ UNICODE what about buffer?
/// Format buffer into printable format. This is useful for
/// debugging.
extern ACE_Export size_t format_hexdump (const char *buffer, size_t size,
ACE_TCHAR *obuf, size_t obuf_sz);
/// Computes the hash value of {str} using the "Hash PJW" routine.
extern ACE_Export u_long hash_pjw (const char *str);
/// Computes the hash value of {str} using the "Hash PJW" routine.
extern ACE_Export u_long hash_pjw (const char *str, size_t len);
#if defined (ACE_HAS_WCHAR)
/// Computes the hash value of {str} using the "Hash PJW" routine.
extern ACE_Export u_long hash_pjw (const wchar_t *str);
/// Computes the hash value of {str} using the "Hash PJW" routine.
extern ACE_Export u_long hash_pjw (const wchar_t *str, size_t len);
#endif /* ACE_HAS_WCHAR */
/// Computes CRC-CCITT for the string.
extern ACE_Export ACE_UINT16 crc_ccitt(const char *str);
/// Computes CRC-CCITT for the buffer.
extern ACE_Export ACE_UINT16 crc_ccitt(const void *buf, size_t len,
ACE_UINT16 crc = 0);
/// Computes CRC-CCITT for the @ len iovec buffers.
extern ACE_Export ACE_UINT16 crc_ccitt(const iovec *iov, int len,
ACE_UINT16 crc = 0);
/// Computes the ISO 8802-3 standard 32 bits CRC for the string.
extern ACE_Export ACE_UINT32 crc32 (const char *str);
/// Computes the ISO 8802-3 standard 32 bits CRC for the buffer.
extern ACE_Export ACE_UINT32 crc32 (const void *buf, size_t len,
ACE_UINT32 crc = 0);
/// Computes the ISO 8802-3 standard 32 bits CRC for the
/// @ len iovec buffers.
extern ACE_Export ACE_UINT32 crc32 (const iovec *iov, int len,
ACE_UINT32 crc = 0);
/// Euclid's greatest common divisor algorithm.
extern ACE_Export u_long gcd (u_long x, u_long y);
/// Calculates the minimum enclosing frame size for the given values.
extern ACE_Export u_long minimum_frame_size (u_long period1, u_long period2);
/**
* Function that can burn up noticeable CPU time: brute-force
* determination of whether number @a n is prime. Returns 0 if
@@ -476,23 +570,28 @@ namespace ACE
extern ACE_Export u_long is_prime (const u_long n,
const u_long min_factor,
const u_long max_factor);
/// Map troublesome win32 errno values to values that standard C
/// strerr function understands. Thank you Microsoft.
extern ACE_Export int map_errno (int error);
/// Returns a string containing the error message corresponding to a
/// WinSock error. This works around an omission in the Win32 API.
/// @internal
extern ACE_Export const ACE_TCHAR * sock_error (int error);
/// Determins whether the given error code corresponds to to a
/// WinSock error. If so returns true, false otherwise.
/// @internal
extern ACE_Export bool is_sock_error (int error);
/**
* Checks if process with {pid} is still alive. Returns 1 if it is
* still alive, 0 if it isn't alive, and -1 if something weird
* happened.
*/
extern ACE_Export int process_active (pid_t pid);
/**
* Terminate the process abruptly with id @a pid. On Win32 platforms
* this uses {TerminateProcess} and on POSIX platforms is uses
@@ -502,6 +601,7 @@ namespace ACE
* cleanup before it shuts down.
*/
extern ACE_Export int terminate_process (pid_t pid);
/**
* This method uses process id and object pointer to come up with a
* machine wide unique name. The process ID will provide uniqueness
@@ -513,169 +613,213 @@ namespace ACE
ACE_NAMESPACE_INLINE_FUNCTION void unique_name (const void *object,
ACE_TCHAR *name,
size_t length);
/// Computes the base 2 logarithm of {num}.
ACE_NAMESPACE_INLINE_FUNCTION u_long log2 (u_long num);
/// Hex conversion utility.
ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR nibble2hex (u_int n);
/// Convert a hex character to its byte representation.
ACE_NAMESPACE_INLINE_FUNCTION u_char hex2byte (ACE_TCHAR c);
// = Set/get the debug level.
extern ACE_Export bool debug (void);
extern ACE_Export void debug (bool onoff);
/// Wrapper facade for @c select that uses @c ACE_Handle_Sets.
extern ACE_Export int select (int width,
ACE_Handle_Set *readfds,
ACE_Handle_Set *writefds = 0,
ACE_Handle_Set *exceptfds = 0,
const ACE_Time_Value *timeout = 0);
/// Wrapper facade for the most common use of @c select that uses
/// @c ACE_Handle_Sets.
extern ACE_Export int select (int width,
ACE_Handle_Set &readfds,
const ACE_Time_Value *timeout = 0);
/// Timed wait for handle to get read ready.
ACE_NAMESPACE_INLINE_FUNCTION
int handle_read_ready (ACE_HANDLE handle,
const ACE_Time_Value *timeout);
/// Timed wait for handle to get write ready.
ACE_NAMESPACE_INLINE_FUNCTION
int handle_write_ready (ACE_HANDLE handle,
const ACE_Time_Value *timeout);
/// Timed wait for handle to get exception ready.
ACE_NAMESPACE_INLINE_FUNCTION
int handle_exception_ready (ACE_HANDLE handle,
const ACE_Time_Value *timeout);
/// Timed wait for handle to get read, write, or exception ready.
extern ACE_Export int handle_ready (ACE_HANDLE handle,
const ACE_Time_Value *timeout,
int read_ready,
int write_ready,
int exception_ready);
/// Wait for @a timeout before proceeding to a @c recv operation.
/// @a val keeps track of whether we're in non-blocking mode or
/// not.
extern ACE_Export int enter_recv_timedwait (ACE_HANDLE handle,
const ACE_Time_Value *timeout,
int &val);
/// Wait for @a timeout before proceeding to a @c send operation.
/// @a val keeps track of whether we're in non-blocking mode or
/// not.
extern ACE_Export int enter_send_timedwait (ACE_HANDLE handle,
const ACE_Time_Value* timeout,
int &val);
/// This makes sure that @a handle is set into non-blocking mode.
/// @a val keeps track of whether were in non-blocking mode or not.
extern ACE_Export void record_and_set_non_blocking_mode (ACE_HANDLE handle,
int &val);
/// Cleanup after a timed operation, restore the appropriate
/// non-blocking status of @a handle.
extern ACE_Export void restore_non_blocking_mode (ACE_HANDLE handle,
int val);
// private:
// These functions aren't meant to be used internally, so they are
// not exported.
//
// = Recv_n helpers
//
ACE_NAMESPACE_INLINE_FUNCTION ssize_t recv_i (ACE_HANDLE handle,
void *buf,
size_t len);
extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
void *buf,
size_t len,
int flags,
size_t *bytes_transferred);
extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
void *buf,
size_t len,
int flags,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
#if defined (ACE_HAS_TLI)
extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle,
void *buf,
size_t len,
int *flags,
size_t *bytes_transferred);
extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle,
void *buf,
size_t len,
int *flags,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
#endif /* ACE_HAS_TLI */
extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
void *buf,
size_t len,
size_t *bytes_transferred);
extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
void *buf,
size_t len,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle,
iovec *iov,
int iovcnt,
size_t *bytes_transferred);
extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle,
iovec *iov,
int iovcnt,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
//
// = Send_n helpers
//
ACE_NAMESPACE_INLINE_FUNCTION ssize_t send_i (ACE_HANDLE handle,
const void *buf,
size_t len);
extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
const void *buf,
size_t len,
int flags,
size_t *bytes_transferred);
extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
const void *buf,
size_t len,
int flags,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
#if defined (ACE_HAS_TLI)
extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle,
const void *buf,
size_t len,
int flags,
size_t *bytes_transferred);
extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle,
const void *buf,
size_t len,
int flags,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
#endif /* ACE_HAS_TLI */
extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
const void *buf,
size_t len,
size_t *bytes_transferred);
extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
const void *buf,
size_t len,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle,
const iovec *iov,
int iovcnt,
size_t *bytes_transferred);
extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle,
const iovec *iov,
int iovcnt,
const ACE_Time_Value *timeout,
size_t *bytes_transferred);
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ACE.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_ACE_H */
+34
View File
@@ -1,14 +1,18 @@
// -*- C++ -*-
//
// $Id: ACE.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_Thread.h"
#include "ace/OS_NS_ctype.h"
#include "ace/OS_NS_sys_socket.h"
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Wrappers for methods that have been moved to ACE_OS.
ACE_INLINE ssize_t
ACE::read_n (ACE_HANDLE handle,
void *buf,
@@ -20,6 +24,7 @@ ACE::read_n (ACE_HANDLE handle,
len,
bytes_transferred);
}
ACE_INLINE ssize_t
ACE::write_n (ACE_HANDLE handle,
const void *buf,
@@ -31,6 +36,7 @@ ACE::write_n (ACE_HANDLE handle,
len,
bytes_transferred);
}
ACE_INLINE ssize_t
ACE::recv_n (ACE_HANDLE handle,
void *buf,
@@ -53,7 +59,9 @@ ACE::recv_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
#if defined (ACE_HAS_TLI)
ACE_INLINE ssize_t
ACE::t_rcv_n (ACE_HANDLE handle,
void *buf,
@@ -76,7 +84,9 @@ ACE::t_rcv_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
#endif /* ACE_HAS_TLI */
ACE_INLINE ssize_t
ACE::recv_n (ACE_HANDLE handle,
void *buf,
@@ -96,6 +106,7 @@ ACE::recv_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
ACE_INLINE ssize_t
ACE::recvv_n (ACE_HANDLE handle,
iovec *iov,
@@ -115,6 +126,7 @@ ACE::recvv_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
ACE_INLINE ssize_t
ACE::send_n (ACE_HANDLE handle,
const void *buf,
@@ -137,7 +149,9 @@ ACE::send_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
#if defined (ACE_HAS_TLI)
ACE_INLINE ssize_t
ACE::t_snd_n (ACE_HANDLE handle,
const void *buf,
@@ -160,7 +174,9 @@ ACE::t_snd_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
#endif /* ACE_HAS_TLI */
ACE_INLINE ssize_t
ACE::send_n (ACE_HANDLE handle,
const void *buf,
@@ -180,6 +196,7 @@ ACE::send_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
ACE_INLINE ssize_t
ACE::sendv_n (ACE_HANDLE handle,
const iovec *iov,
@@ -199,6 +216,7 @@ ACE::sendv_n (ACE_HANDLE handle,
timeout,
bytes_transferred);
}
ACE_INLINE ssize_t
ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len)
{
@@ -208,6 +226,7 @@ ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len)
return ACE_OS::write (handle, (const char *) buf, len);
#endif /* ACE_WIN32 */
}
ACE_INLINE ssize_t
ACE::recv_i (ACE_HANDLE handle, void *buf, size_t len)
{
@@ -217,6 +236,7 @@ ACE::recv_i (ACE_HANDLE handle, void *buf, size_t len)
return ACE_OS::read (handle, (char *) buf, len);
#endif /* ACE_WIN32 */
}
ACE_INLINE int
ACE::handle_read_ready (ACE_HANDLE handle,
const ACE_Time_Value *timeout)
@@ -227,6 +247,7 @@ ACE::handle_read_ready (ACE_HANDLE handle,
0,
0);
}
ACE_INLINE int
ACE::handle_write_ready (ACE_HANDLE handle,
const ACE_Time_Value *timeout)
@@ -237,6 +258,7 @@ ACE::handle_write_ready (ACE_HANDLE handle,
1,
0);
}
ACE_INLINE int
ACE::handle_exception_ready (ACE_HANDLE handle,
const ACE_Time_Value *timeout)
@@ -247,11 +269,13 @@ ACE::handle_exception_ready (ACE_HANDLE handle,
0,
1);
}
ACE_INLINE void
ACE::strdelete (char *s)
{
delete [] s;
}
#if defined (ACE_HAS_WCHAR)
ACE_INLINE void
ACE::strdelete (wchar_t *s)
@@ -259,6 +283,7 @@ ACE::strdelete (wchar_t *s)
delete [] s;
}
#endif /* ACE_HAS_WCHAR */
ACE_INLINE void
ACE::unique_name (const void *object,
ACE_TCHAR *name,
@@ -266,14 +291,18 @@ ACE::unique_name (const void *object,
{
ACE_OS::unique_name (object, name, length);
}
ACE_INLINE u_long
ACE::log2 (u_long num)
{
u_long log = 0;
for (; num > 1; ++log)
num >>= 1;
return log;
}
ACE_INLINE ACE_TCHAR
ACE::nibble2hex (u_int n)
{
@@ -287,9 +316,11 @@ ACE::nibble2hex (u_int n)
#else
static const ACE_TCHAR hex_chars[] = ACE_TEXT ("0123456789abcdef");
#endif
// Yes, this works for UNICODE
return hex_chars[n & 0x0f];
}
ACE_INLINE int
ACE::map_errno (int error)
{
@@ -300,8 +331,10 @@ ACE::map_errno (int error)
return EAGAIN; // Same as UNIX errno EWOULDBLOCK.
}
#endif /* ACE_WIN32 */
return error;
}
ACE_INLINE u_char
ACE::hex2byte (ACE_TCHAR c)
{
@@ -312,5 +345,6 @@ ACE::hex2byte (ACE_TCHAR c)
else
return (u_char) (10 + c - ACE_TEXT ('A'));
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
+18
View File
@@ -1,9 +1,12 @@
// $Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ACE.h"
ACE_RCSID (ace,
ACE_crc32,
"$Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $")
namespace
{
/*****************************************************************/
@@ -25,6 +28,7 @@ namespace
/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/*****************************************************************/
const ACE_UINT32 crc_table[] =
{
0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL,
@@ -92,29 +96,37 @@ namespace
0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L,
0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
};
/*****************************************************************/
/* End of CRC Lookup Table */
/*****************************************************************/
}
#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8))
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_UINT32
ACE::crc32 (const char *string)
{
ACE_UINT32 crc = 0xFFFFFFFF;
for (const char *p = string;
*p != 0;
++p)
{
COMPUTE (crc, *p);
}
return ~crc;
}
ACE_UINT32
ACE::crc32 (const void *buffer, size_t len, ACE_UINT32 crc)
{
crc = ~crc;
for (const char *p = (const char *) buffer,
*e = (const char *) buffer + len;
p != e;
@@ -122,12 +134,15 @@ ACE::crc32 (const void *buffer, size_t len, ACE_UINT32 crc)
{
COMPUTE (crc, *p);
}
return ~crc;
}
ACE_UINT32
ACE::crc32 (const iovec *iov, int len, ACE_UINT32 crc)
{
crc = ~crc;
for (int i = 0; i < len; ++i)
{
for (const char *p = (const char *) iov[i].iov_base,
@@ -136,9 +151,12 @@ ACE::crc32 (const iovec *iov, int len, ACE_UINT32 crc)
++p)
COMPUTE (crc, *p);
}
return ~crc;
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#undef COMPUTE
+18
View File
@@ -1,8 +1,11 @@
// $Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ACE.h"
ACE_RCSID (ace,
ACE_crc_ccitt,
"$Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $")
namespace
{
/*****************************************************************/
@@ -24,6 +27,7 @@ namespace
/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/*****************************************************************/
const ACE_UINT16 crc_table[] =
{
0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
@@ -59,29 +63,37 @@ namespace
0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
};
/*****************************************************************/
/* End of CRC Lookup Table */
/*****************************************************************/
}
#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8))
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_UINT16
ACE::crc_ccitt (const char *string)
{
ACE_UINT16 crc = 0xFFFF;
for (const char *p = string;
*p != 0;
++p)
{
COMPUTE (crc, *p);
}
return ~crc;
}
ACE_UINT16
ACE::crc_ccitt (const void *buffer, size_t len, ACE_UINT16 crc)
{
crc = ~crc;
for (const char *p = (const char *) buffer,
*e = (const char *) buffer + len;
p != e;
@@ -89,12 +101,15 @@ ACE::crc_ccitt (const void *buffer, size_t len, ACE_UINT16 crc)
{
COMPUTE (crc, *p);
}
return ~crc;
}
ACE_UINT16
ACE::crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc)
{
crc = ~crc;
for (int i = 0; i < len; ++i)
{
for (const char *p = (const char *) iov[i].iov_base,
@@ -103,9 +118,12 @@ ACE::crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc)
++p)
COMPUTE (crc, *p);
}
return ~crc;
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#undef COMPUTE
+9
View File
@@ -4,10 +4,14 @@
// This file is generated automatically by
// generate_export_file.pl
// ------------------------------
#ifndef ACE_EXPORT_H
#define ACE_EXPORT_H
#include "ace/config-lite.h"
#if defined (ACE_AS_STATIC_LIBS)
# if !defined (ACE_HAS_DLL)
# define ACE_HAS_DLL 0
# endif /* ! ACE_HAS_DLL */
@@ -16,6 +20,7 @@
# define ACE_HAS_DLL 1
# endif /* ! ACE_HAS_DLL */
#endif /* ACE_AS_STATIC_LIB */
#if defined (ACE_HAS_DLL)
# if (ACE_HAS_DLL == 1)
# if defined (ACE_BUILD_DLL)
@@ -37,12 +42,14 @@
# define ACE_SINGLETON_DECLARATION(T)
# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
#endif /* ACE_HAS_DLL */
// Added by hand to help with ACE_OS namespace
#if defined (__TANDEM) && defined (USE_EXPLICIT_EXPORT)
#define ACE_NAMESPACE_STORAGE_CLASS ACE_EXPORT_MACRO extern
#else
#define ACE_NAMESPACE_STORAGE_CLASS extern ACE_EXPORT_MACRO
#endif
#if defined (__ACE_INLINE__)
# if defined (_MSC_VER) || defined (__MINGW32__) || defined (CYGWIN32) || \
(defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x560) || \
@@ -63,6 +70,8 @@
# define ACE_INLINE_TEMPLATE_FUNCTION
# endif
#endif
#endif /* ACE_EXPORT_H */
// End of auto generated file.
+46
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//==========================================================================
/**
* @file ARGV.h
@@ -9,17 +10,23 @@
* @author Everett Anderson <[email protected]>
*/
//==========================================================================
#ifndef ACE_ARGUMENT_VECTOR_H
#define ACE_ARGUMENT_VECTOR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Global_Macros.h"
#include "ace/Unbounded_Queue.h"
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_ARGV_Queue_Entry_T
*
@@ -32,6 +39,7 @@ public:
// = Initialization and termination.
/// Initialize a ACE_ARGV_Queue_Entry_T.
ACE_ARGV_Queue_Entry_T (void);
/**
* Initialize a ACE_ARGV_Queue_Entry_T.
*
@@ -42,24 +50,31 @@ public:
*/
ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg,
bool quote_arg);
/**
* Initialize a ACE_ARGV_Queue_Entry_T.
*
* @param entry Pointer to a queue entry
*/
ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T<CHAR_TYPE> &entry);
/// We need this destructor to keep some compilers from complaining.
/// It's just a no-op, however.
~ACE_ARGV_Queue_Entry_T (void);
/// Dump the state of this object.
void dump (void) const;
// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
/// Pointer to the argument.
const CHAR_TYPE * arg_;
/// The argument need to be quoted while adding to the vector.
bool quote_arg_;
};
/**
* @class ACE_ARGV_T
*
@@ -97,6 +112,7 @@ public:
*/
explicit ACE_ARGV_T (const CHAR_TYPE buf[],
bool substitute_env_args = true);
/**
* Initializes the argument vector from a set of arguments. Any environment
* variable references are translated (if applicable) during execution of
@@ -123,6 +139,7 @@ public:
CHAR_TYPE *argv[],
bool substitute_env_args = true,
bool quote_args = false);
/**
* Initializes the argument vector from a set of arguments. Any environment
* variable references are translated (if applicable) during execution of
@@ -145,6 +162,7 @@ public:
explicit ACE_ARGV_T (CHAR_TYPE *argv[],
bool substitute_env_args = true,
bool quote_args = false);
/**
* Initializes the argument vector from two combined argument vectors.
*
@@ -167,14 +185,17 @@ public:
CHAR_TYPE *second_argv[],
bool substitute_env_args = true,
bool quote_args = false);
/**
* Initialize this object so arguments can be added later using one
* of the add methods. This is referred to as the @i iterative method
* of adding arguments to this object.
*/
explicit ACE_ARGV_T (bool substitute_env_args = true);
/// Destructor.
~ACE_ARGV_T (void);
/** @name Accessor methods
*
* These methods access the argument vector contained in this object.
@@ -189,25 +210,32 @@ public:
* @retval 0 if @a index is out of bounds.
*/
const CHAR_TYPE *operator[] (size_t index);
/**
* Returns the current argument vector. The returned pointers are to data
* maintained internally to this class. Do not change or delete either the
* pointers or the memory to which they refer.
*/
CHAR_TYPE **argv (void);
/// Returns the current number of arguments.
int argc (void) const;
/**
* Returns a single string form of the current arguments. The returned
* pointer refers to memory maintained internally to this class. Do not
* change or delete it.
*/
const CHAR_TYPE *buf (void);
//@}
/// Dump the state of this object.
void dump (void) const;
// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
/**
* Add another argument. This only works in the iterative mode.
*
@@ -226,6 +254,7 @@ public:
* - ENOMEM: Not enough memory available to save @a next_arg.
*/
int add (const CHAR_TYPE *next_arg, bool quote_arg = false);
/**
* Add an array of arguments. This only works in the iterative mode.
*
@@ -245,44 +274,61 @@ public:
* - ENOMEM: Not enough memory available to save @a next_arg.
*/
int add (CHAR_TYPE *argv[], bool quote_args = false);
private:
/// Copy constructor not implemented.
ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T (const ACE_ARGV_T<CHAR_TYPE>&))
/// Assignment operator not implemented.
ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T operator= (const ACE_ARGV_T<CHAR_TYPE>&))
/// Creates buf_ from the queue of added args, deletes previous buf_.
int create_buf_from_queue (void);
/// Converts buf_ into the CHAR_TYPE *argv[] format.
int string_to_argv (void);
/// Replace args with environment variable values?
bool substitute_env_args_;
bool iterative_;
/// Number of arguments in the ARGV array.
int argc_;
/// The array of string arguments.
CHAR_TYPE **argv_;
/// Buffer containing the <argv> contents.
CHAR_TYPE *buf_;
/// Total length of the arguments in the queue, not counting
/// separating spaces
size_t length_;
/// Queue which keeps user supplied arguments. This is only
/// active in the "iterative" mode.
ACE_Unbounded_Queue<ACE_ARGV_Queue_Entry_T<CHAR_TYPE> > queue_;
};
typedef ACE_ARGV_Queue_Entry_T<ACE_TCHAR> ACE_ARGV_Queue_Entry;
typedef ACE_ARGV_T<ACE_TCHAR> ACE_ARGV;
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ARGV.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/ARGV.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("ARGV.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_ARGUMENT_VECTOR_H */
+20
View File
@@ -1,8 +1,11 @@
/* -*- C++ -*- */
// $Id: ARGV.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Global_Macros.h"
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <typename CHAR_TYPE> ACE_INLINE
ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::ACE_ARGV_Queue_Entry_T (void)
: arg_(0),
@@ -10,6 +13,7 @@ ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::ACE_ARGV_Queue_Entry_T (void)
{
// No-op
}
template <typename CHAR_TYPE> ACE_INLINE
ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg,
bool quote_arg)
@@ -18,6 +22,7 @@ ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg,
{
// No-op
}
template <typename CHAR_TYPE> ACE_INLINE
ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T<CHAR_TYPE> &entry)
: arg_(entry.arg_),
@@ -25,11 +30,13 @@ ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_
{
// No-op
}
template <typename CHAR_TYPE> ACE_INLINE
ACE_ARGV_Queue_Entry_T<CHAR_TYPE>::~ACE_ARGV_Queue_Entry_T (void)
{
// No-op just to keep some compilers happy...
}
// Return the number of args
template <typename CHAR_TYPE>
ACE_INLINE int
@@ -42,43 +49,56 @@ ACE_ARGV_T<CHAR_TYPE>::argc (void) const
(void) nonconst_this->argv ();
return this->argc_;
}
// Return the arguments in a space-separated string
template <typename CHAR_TYPE>
ACE_INLINE const CHAR_TYPE *
ACE_ARGV_T<CHAR_TYPE>::buf (void)
{
ACE_TRACE ("ACE_ARGV_T::buf");
if (this->buf_ == 0 && this->iterative_)
this->create_buf_from_queue ();
return (const CHAR_TYPE *) this->buf_;
}
// Return the arguments in an entry-per-argument array
template <typename CHAR_TYPE>
ACE_INLINE CHAR_TYPE **
ACE_ARGV_T<CHAR_TYPE>::argv (void)
{
ACE_TRACE ("ACE_ARGV_T::argv");
// Try to create the argv_ if it isn't there
if (this->argv_ == 0)
{
if (this->iterative_ && this->buf_ == 0)
this->create_buf_from_queue ();
// Convert buf_ to argv_
if (this->string_to_argv () == -1)
return (CHAR_TYPE **) 0;
}
return (CHAR_TYPE **) this->argv_;
}
// Subscript operator.
template <typename CHAR_TYPE>
ACE_INLINE const CHAR_TYPE *
ACE_ARGV_T<CHAR_TYPE>::operator[] (size_t i)
{
ACE_TRACE ("ACE_ARGV_T::operator[]");
// Don't go out of bounds.
if (i >= static_cast<size_t> (this->argc_))
return 0;
return (const CHAR_TYPE *) this->argv ()[i];
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
+45
View File
@@ -1,36 +1,49 @@
// $Id: ATM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ATM_Acceptor.h"
ACE_RCSID(ace, ATM_Acceptor, "$Id: ATM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if defined (ACE_HAS_ATM)
#if defined (ACE_HAS_LINUX_ATM)
#include /**/ "linux/atmdev.h"
#endif /* ACE_HAS_LINUX_ATM */
#if !defined (__ACE_INLINE__)
#include "ace/ATM_Acceptor.inl"
#endif /* __ACE_INLINE__ */
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Put the actual definitions of the ACE_ATM_Request and
// ACE_ATM_Request_Queue classes here to hide them from clients...
ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Acceptor)
ACE_ATM_Acceptor::ACE_ATM_Acceptor (void)
{
ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
}
ACE_ATM_Acceptor::~ACE_ATM_Acceptor (void)
{
ACE_TRACE ("ACE_ATM_Acceptor::~ACE_ATM_Acceptor");
}
int
ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr)
{
ACE_TRACE ("ACE_ATM_Acceptor::get_local_addr");
#if defined (ACE_HAS_FORE_ATM_WS2)
unsigned long ret = 0;
DWORD deviceID = 0;
ATM_ADDRESS addr;
struct sockaddr_atm *laddr;
if (::WSAIoctl ((int) ((ACE_SOCK_Acceptor *)this) -> get_handle (),
SIO_GET_ATM_ADDRESS,
(LPVOID) &deviceID,
@@ -44,17 +57,21 @@ ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr)
::WSAGetLastError ());
return -1;
}
laddr = (struct sockaddr_atm *)local_addr.get_addr ();
ACE_OS::memcpy ((void *)& (laddr -> satm_number),
(void *)&addr,
ATM_ADDR_SIZE - 1);
return 0;
#elif defined (ACE_HAS_FORE_ATM_XTI)
ACE_UNUSED_ARG (local_addr);
return 0;
#elif defined (ACE_HAS_LINUX_ATM)
ATM_Addr *myaddr = (ATM_Addr *)local_addr.get_addr ();
int addrlen = sizeof (myaddr->sockaddratmsvc);
if (ACE_OS::getsockname (acceptor_.get_handle (),
(struct sockaddr *) & (myaddr->sockaddratmsvc),
&addrlen) < 0) {
@@ -63,12 +80,15 @@ ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr)
errno));
return -1;
}
return (0);
#else
ACE_UNUSED_ARG (local_addr);
return 0;
#endif /* ACE_HAS_FORE_ATM_WS2 && ACE_HAS_FORE_ATM_XTI */
}
ACE_HANDLE
ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
int backlog,
@@ -87,9 +107,12 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
struct sockaddr_atm local_atm_addr;
ACE_HANDLE ret;
DWORD flags = 0;
/* Create a local endpoint of communication */
// Only leaves can listen.
flags = ACE_FLAG_MULTIPOINT_C_LEAF | ACE_FLAG_MULTIPOINT_D_LEAF;
if ((ret = ACE_OS::socket (AF_ATM,
SOCK_RAW,
ATMPROTO_AAL5,
@@ -101,7 +124,9 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
::WSAGetLastError ());
return (ret);
}
((ACE_SOCK_Acceptor *)this) -> set_handle (ret);
/* Set up the address information to become a server */
ACE_OS::memset ((void *) &local_atm_addr, 0, sizeof local_atm_addr);
local_atm_addr.satm_family = AF_ATM;
@@ -111,6 +136,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
local_atm_addr.satm_blli.Layer2Protocol = SAP_FIELD_ANY;
local_atm_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
local_atm_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
/* Associate address with endpoint */
if (ACE_OS::bind (((ACE_SOCK_Acceptor *)this) -> get_handle (),
reinterpret_cast<struct sockaddr *> (&local_atm_addr),
@@ -118,6 +144,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
ACE_OS::printf ("Acceptor (open): bind %d\n", ::WSAGetLastError ());
return (ACE_INVALID_HANDLE);
}
/* Make endpoint listen for service requests */
if (ACE_OS::listen (( (ACE_SOCK_Acceptor *)this) -> get_handle (),
backlog)
@@ -125,14 +152,17 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
ACE_OS::printf ("Acceptor (open): listen %d\n", ::WSAGetLastError ());
return (ACE_INVALID_HANDLE);
}
return 0;
#elif defined (ACE_HAS_LINUX_ATM)
//we need to set the qos before binding to the socket
//use remote_sap as local_sap
ACE_ATM_Addr local_sap;
ATM_Addr *local_sap_addr = (ATM_Addr*)local_sap.get_addr ();
ACE_ATM_QoS def_qos;
ATM_QoS qos = def_qos.get_qos ();
ACE_HANDLE handle;
if ((handle = ACE_OS::socket (params.get_protocol_family (),
params.get_type (),
@@ -147,6 +177,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
errno);
return (ACE_INVALID_HANDLE);
}
((ACE_SOCK_Acceptor *)this) -> set_handle (handle);
if (ACE_OS::setsockopt (handle,
SOL_ATM,
@@ -156,8 +187,10 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
ACE_OS::printf ("Acceptor (setsockopt): setsockopt:%d\n",
errno);
}
struct atmif_sioc req;
struct sockaddr_atmsvc aux_addr[1024];
req.number = 0;
req.arg = aux_addr;
req.length = sizeof (aux_addr);
@@ -170,6 +203,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
local_sap_addr->sockaddratmsvc = aux_addr[0];
}
local_sap.set_selector (( (ACE_ATM_Addr*)&remote_sap)->get_selector ());
if (ACE_OS::bind (handle,
reinterpret_cast<struct sockaddr *> (
&(local_sap_addr->sockaddratmsvc)),
@@ -189,6 +223,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
errno);
return -1;
}
return 0;
#else
ACE_UNUSED_ARG (remote_sap);
@@ -196,6 +231,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
ACE_UNUSED_ARG (params);
#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */
}
int
ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
ACE_Addr *remote_addr,
@@ -208,6 +244,7 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
ACE_TRACE ("ACE_ATM_Acceptor::accept");
#if defined (ACE_HAS_FORE_ATM_XTI)
ATM_QoS optbuf = qos.get_qos ();
return (acceptor_.accept (new_sap.get_stream (),
remote_addr,
timeout,
@@ -222,19 +259,24 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
struct sockaddr_atm *cli_addr
= (struct sockaddr_atm *)remote_addr -> get_addr ();
int caddr_len = sizeof (struct sockaddr_atm);
do {
n_handle = ACE_OS::accept (s_handle,
reinterpret_cast<struct sockaddr *> (cli_addr),
&caddr_len);
} while (n_handle == ACE_INVALID_HANDLE && errno == EINTR);
((ACE_ATM_Addr *)remote_addr) -> set (cli_addr,
((ACE_ATM_Addr *)remote_addr) -> get_selector ());
((ACE_IPC_SAP *)&new_sap) -> set_handle (n_handle);
return 0;
#elif defined (ACE_HAS_LINUX_ATM)
ACE_UNUSED_ARG (params);
ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle ();
struct atm_qos accept_qos = qos.get_qos ();
if (ACE_OS::setsockopt (s_handle,
SOL_ATM,
SO_ATMQOS,
@@ -242,6 +284,7 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
sizeof (accept_qos)) < 0) {
ACE_OS::printf ("Acceptor (accept): error setting Qos");
}
return (acceptor_.accept (new_sap.get_stream (),
remote_addr,
timeout,
@@ -258,8 +301,10 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
return (0);
#endif /* ACE_HAS_FORE_ATM_XTI */
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_ATM */
+26
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file ATM_Acceptor.h
@@ -9,20 +10,27 @@
*/
//=============================================================================
#ifndef ACE_ATM_ACCEPTOR_H
#define ACE_ATM_ACCEPTOR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_ATM)
#include "ace/ATM_Stream.h"
#include "ace/ATM_Params.h"
#include "ace/ATM_QoS.h"
#if defined (ACE_HAS_LINUX_ATM)
#include /**/ "atm.h"
#endif /* ACE_HAS_LINUX_ATM */
#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
#include "ace/SOCK_Acceptor.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -34,10 +42,13 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
typedef ACE_TLI_Acceptor ATM_Acceptor;
ACE_END_VERSIONED_NAMESPACE_DECL
#endif // ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declarations.
class ACE_Time_Value;
/**
* @class ACE_ATM_Acceptor
*
@@ -48,22 +59,29 @@ class ACE_Time_Value;
*/
class ACE_Export ACE_ATM_Acceptor
{
public:
// = Initialization and termination methods.
/// Default constructor.
ACE_ATM_Acceptor (void);
~ACE_ATM_Acceptor ();
/// Initiate a passive mode connection.
ACE_ATM_Acceptor (const ACE_Addr &remote_sap,
int backlog = ACE_DEFAULT_BACKLOG,
ACE_ATM_Params params = ACE_ATM_Params());
/// Initiate a passive mode socket.
ACE_HANDLE open (const ACE_Addr &remote_sap,
int backlog = ACE_DEFAULT_BACKLOG,
ACE_ATM_Params params = ACE_ATM_Params());
/// Close down the acceptor and release resources.
int close (void);
// = Passive connection acceptance method.
/// Accept a new data transfer connection. A @a timeout of 0 means
/// block forever, a @a timeout of {0, 0} means poll. @a restart == 1
/// means "restart if interrupted."
@@ -74,24 +92,32 @@ public:
int reset_new_handle = 0,
ACE_ATM_Params params = ACE_ATM_Params(),
ACE_ATM_QoS qos = ACE_ATM_QoS());
/// Get the local address currently listening on
int get_local_addr( ACE_ATM_Addr &local_addr );
// = Meta-type info
typedef ACE_ATM_Addr PEER_ADDR;
typedef ACE_ATM_Stream PEER_STREAM;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
ATM_Acceptor acceptor_;
};
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ATM_Acceptor.inl"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_ATM */
#include /**/ "ace/post.h"
#endif /* ACE_ATM_ACCEPTOR_H */
+6
View File
@@ -1,8 +1,10 @@
// -*- C++ -*-
//
// $Id: ATM_Acceptor.inl 80826 2008-03-04 14:51:23Z wotte $
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void
ACE_ATM_Acceptor::dump (void) const
{
@@ -10,12 +12,14 @@ ACE_ATM_Acceptor::dump (void) const
ACE_TRACE ("ACE_ATM_Acceptor::dump");
#endif /* ACE_HAS_DUMP */
}
ACE_INLINE
ACE_ATM_Acceptor::ACE_ATM_Acceptor (const ACE_Addr &remote_sap,
int backlog,
ACE_ATM_Params params)
{
ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
//FUZZ: disable check_for_lack_ACE_OS
if (open (remote_sap, backlog, params) < 0)
//FUZZ: enable check_for_lack_ACE_OS
@@ -23,6 +27,7 @@ ACE_ATM_Acceptor::ACE_ATM_Acceptor (const ACE_Addr &remote_sap,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_ATM_Acceptor::ACE_ATM_Acceptor")));
}
ACE_INLINE
int
ACE_ATM_Acceptor::close (void)
@@ -33,5 +38,6 @@ ACE_ATM_Acceptor::close (void)
return 0;
#endif // ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
+79
View File
@@ -1,17 +1,26 @@
// $Id: ATM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
// Defines the Internet domain address family address format.
#include "ace/ATM_Addr.h"
#if defined (ACE_HAS_ATM)
#include "ace/Log_Msg.h"
#if defined (ACE_HAS_FORE_ATM_WS2)
#include /**/ "forews2.h"
#endif /* ACE_HAS_FORE_ATM_WS2 */
#if !defined (__ACE_INLINE__)
#include "ace/ATM_Addr.inl"
#endif /* __ACE_INLINE__ */
ACE_RCSID(ace, ATM_Addr, "$Id: ATM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Addr)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
#define BHLI_MAGIC "FORE_ATM"
// This is line rate in cells/s for an OC-3 MM interface.
@@ -33,7 +42,9 @@ const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0;
const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0;
const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
// Default constructor
ACE_ATM_Addr::ACE_ATM_Addr (u_char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
: ACE_Addr (AF_ATM,
@@ -50,7 +61,9 @@ ACE_ATM_Addr::ACE_ATM_Addr (u_char selector)
sizeof this->atm_addr_);
this->init (selector);
}
// Copy constructor.
ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap,
u_char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
@@ -71,6 +84,7 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap,
this->atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE;
#endif /* ACE_HAS_LINUX_ATM */
}
ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap,
u_char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
@@ -86,6 +100,7 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap,
this->set (sap, selector);
}
ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[],
u_char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
@@ -100,16 +115,20 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[],
ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
this->set (sap, selector);
}
ACE_ATM_Addr::~ACE_ATM_Addr (void)
{
}
// Return the address.
void *
ACE_ATM_Addr::get_addr (void) const
{
ACE_TRACE ("ACE_ATM_Addr::get_addr");
return (void *) &this->atm_addr_;
}
void
ACE_ATM_Addr::init (u_char selector)
{
@@ -119,16 +138,22 @@ ACE_ATM_Addr::init (u_char selector)
// selector (i.e. address[19]) is used by the TP. The rest of the
// local address is filled in by the TP and can be obtained via the
// 'ret' parameter or with t_getname ()/t_getprotaddr ().
atm_addr_.addressType = (u_int16_t) AF_ATM;
atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr = (int8_t) T_ATM_ABSENT;
atm_addr_.sap.t_atm_sap_addr.SVE_tag_selector = (int8_t) T_ATM_PRESENT;
atm_addr_.sap.t_atm_sap_addr.address_format = (u_int8_t) T_ATM_ENDSYS_ADDR;
atm_addr_.sap.t_atm_sap_addr.address_length = ATMNSAP_ADDR_LEN;
atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector;
atm_addr_.sap.t_atm_sap_layer2.SVE_tag = (int8_t) T_ATM_ABSENT;
atm_addr_.sap.t_atm_sap_layer3.SVE_tag = (int8_t) T_ATM_ABSENT;
atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT;
atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID;
ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID,
BHLI_MAGIC,
sizeof atm_addr_.sap.t_atm_sap_appl.ID);
@@ -141,6 +166,7 @@ ACE_ATM_Addr::init (u_char selector)
atm_addr_.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT;
atm_addr_.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT;
atm_addr_.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT;
// Need to know the correspondence.
//atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT;
//atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID;
@@ -157,30 +183,38 @@ ACE_ATM_Addr::init (u_char selector)
ACE_UNUSED_ARG (selector);
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
int
ACE_ATM_Addr::set (const ACE_ATM_Addr &sap,
u_char selector)
{
ACE_TRACE ("ACE_ATM_Addr::set");
this->init (selector);
this->ACE_Addr::base_set (sap.get_type (),
sap.get_size ());
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
ACE_ASSERT (sap.get_type () == AF_ATM);
#elif defined (ACE_HAS_LINUX_ATM)
ACE_ASSERT (sap.get_type () == PF_ATMSVC);
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
(void) ACE_OS::memcpy ((void *) &this->atm_addr_,
(void *) &sap.atm_addr_,
sizeof this->atm_addr_);
return 0;
}
int
ACE_ATM_Addr::set (const ATM_Addr *sap,
u_char selector)
{
ACE_TRACE ("ACE_ATM_Addr::set");
this->init (selector);
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
this->ACE_Addr::base_set (AF_ATM,
#elif defined (ACE_HAS_LINUX_ATM)
@@ -189,31 +223,39 @@ ACE_ATM_Addr::set (const ATM_Addr *sap,
this->ACE_Addr::base_set (AF_UNSPEC,
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
sizeof (*sap));
(void) ACE_OS::memcpy ((void *) &this->atm_addr_,
(void *) sap,
sizeof this->atm_addr_);
return 0;
}
int
ACE_ATM_Addr::set (const ACE_TCHAR address[],
u_char selector)
{
ACE_TRACE ("ACE_ATM_Addr::set");
int ret;
this->init (selector);
#if defined (ACE_HAS_FORE_ATM_XTI)
atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr =
(int8_t) T_ATM_PRESENT;
#endif /* ACE_HAS_FORE_ATM_XTI */
ret = this -> string_to_addr (address);
this -> set_selector (selector);
return ret;
}
// Transform the string into the current addressing format.
int
ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
{
ACE_TRACE ("ACE_ATM_Addr::string_to_addr");
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
this->ACE_Addr::base_set (AF_ATM,
#elif defined (ACE_HAS_LINUX_ATM)
@@ -225,6 +267,7 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
#if defined (ACE_HAS_FORE_ATM_XTI)
struct hostent *entry;
struct atmnsap_addr *nsap;
// Yow, someone gave us a NULL ATM address!
if (sap == 0)
{
@@ -253,11 +296,14 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
WSAQUERYSETW qsRestrictions;
CSADDR_INFO csaBuffer;
WCHAR tmpWStr[100];
MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sap, -1, tmpWStr, 100);
csaBuffer.LocalAddr.iSockaddrLength = sizeof (struct sockaddr_atm);
csaBuffer.LocalAddr.lpSockaddr = (struct sockaddr *)&atm_addr_;
csaBuffer.RemoteAddr.iSockaddrLength = sizeof (struct sockaddr_atm);
csaBuffer.RemoteAddr.lpSockaddr = (struct sockaddr *)&atm_addr_;
qsRestrictions.dwSize = sizeof (WSAQUERYSETW);
qsRestrictions.lpszServiceInstanceName = 0;
qsRestrictions.lpServiceClassId = &FORE_NAME_CLASS;
@@ -272,13 +318,16 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
qsRestrictions.dwNumberOfCsAddrs = 1;
qsRestrictions.lpcsaBuffer = &csaBuffer;
qsRestrictions.lpBlob = 0; //&blob;
if (::WSALookupServiceBeginW (&qsRestrictions, LUP_RETURN_ALL, &hLookup)
== SOCKET_ERROR) {
ACE_OS::printf ("Error: WSALookupServiceBeginW failed! %d\n",
::WSAGetLastError ());
return -1;
}
dwValue = sizeof (WSAQUERYSETW);
if (::WSALookupServiceNextW (hLookup, 0, &dwValue, &qsRestrictions)
== SOCKET_ERROR) {
if (WSAGetLastError () != WSA_E_NO_MORE) {
@@ -287,6 +336,7 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
return -1;
}
}
if (WSALookupServiceEnd (hLookup) == SOCKET_ERROR) {
ACE_OS::printf ("Error : WSALookupServiceEnd failed! %d \n",
::WSAGetLastError ());
@@ -298,6 +348,7 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
errno = EINVAL;
return -1;
}
if (text2atm ((ACE_TCHAR *)sap,
(struct sockaddr *)& (atm_addr_.sockaddratmsvc),
sizeof (atm_addr_.sockaddratmsvc),
@@ -309,18 +360,23 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
}
#else
ACE_UNUSED_ARG (sap);
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
}
// Transform the current address into string format.
int
ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
size_t addrlen) const
{
ACE_TRACE ("ACE_ATM_Addr::addr_to_string");
#if defined (ACE_HAS_FORE_ATM_XTI)
ACE_TCHAR buffer[MAXNAMELEN + 1];
struct atmnsap_addr nsap;
@@ -330,25 +386,32 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
ACE_OS::sprintf (buffer,
ACE_TEXT ("%s"),
atmnsap_ntoa (nsap));
size_t total_len = ACE_OS::strlen (buffer) + sizeof ('\0');
if (addrlen < total_len)
return -1;
else
ACE_OS::strcpy (addr, buffer);
return 0;
#elif defined (ACE_HAS_FORE_ATM_WS2)
ACE_TCHAR buffer[MAXNAMELEN + 1];
int i;
if (addrlen < ATM_ADDR_SIZE + 1)
return -1;
for (i = 0; i < ATM_ADDR_SIZE; i++) {
buffer[ i * 3 ] = '\0';
ACE_OS::sprintf (buffer, ACE_TEXT ("%s%02x."),
buffer,
atm_addr_.satm_number.Addr[ i ]);
}
buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0';
ACE_OS::strcpy (addr, buffer);
return 0;
#elif defined (ACE_HAS_LINUX_ATM)
ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
@@ -365,6 +428,7 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
else
ACE_OS::strcpy (addr,
buffer);
return 0;
#else
ACE_UNUSED_ARG (addr);
@@ -372,21 +436,26 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
return -1;
#endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */
}
const ACE_TCHAR *
ACE_ATM_Addr::addr_to_string (void) const
{
ACE_TRACE ("ACE_ATM_Addr::addr_to_string");
static ACE_TCHAR addr[MAXHOSTNAMELEN + 1];
if (this->addr_to_string (addr,
MAXHOSTNAMELEN + 1) < 0)
return 0;
return addr;
}
// Set a pointer to the address.
void
ACE_ATM_Addr::set_addr (void *addr, int len)
{
ACE_TRACE ("ACE_ATM_Addr::set_addr");
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
this->ACE_Addr::base_set (AF_ATM,
#elif defined (ACE_HAS_LINUX_ATM)
@@ -398,18 +467,23 @@ ACE_ATM_Addr::set_addr (void *addr, int len)
ACE_OS::memcpy ((void *) &this->atm_addr_,
(void *) addr, len);
}
// Compare two addresses for inequality.
bool
ACE_ATM_Addr::operator != (const ACE_ATM_Addr &sap) const
{
ACE_TRACE ("ACE_ATM_Addr::operator !=");
return ! ((*this) == sap);
}
// Compare two addresses for equality.
bool
ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const
{
ACE_TRACE ("ACE_ATM_Addr::operator ==");
#if defined (ACE_HAS_LINUX_ATM)
return (atm_equal ((const struct sockaddr *)& (this->atm_addr_.sockaddratmsvc),
(const struct sockaddr *)& (sap.atm_addr_.sockaddratmsvc),
@@ -425,12 +499,15 @@ ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const
sizeof (ATM_Addr)) == 0;
#endif /* ACE_HAS_LINUX_ATM */
}
void
ACE_ATM_Addr::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_ATM_Addr::dump");
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACE_TCHAR s[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16];
ACE_OS::sprintf (s,
ACE_TEXT ("%s"),
@@ -439,6 +516,8 @@ ACE_ATM_Addr::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_ATM */
+36
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//==========================================================================
/**
* @file ATM_Addr.h
@@ -8,16 +9,22 @@
* @author Joe Hoffert <[email protected]>
*/
//==========================================================================
#ifndef ACE_ATM_ADDR_H
#define ACE_ATM_ADDR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_ATM)
#include /**/ "ace/ACE_export.h"
#include "ace/Addr.h"
#if defined (ACE_HAS_FORE_ATM_XTI)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
typedef ATMSAPAddress ATM_Addr;
@@ -28,9 +35,12 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
typedef struct sockaddr_atm ATM_Addr;
ACE_END_VERSIONED_NAMESPACE_DECL
#elif defined (ACE_HAS_LINUX_ATM)
#include /**/ "atm.h"
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
//pbrandao:as Linux has this 2 structs separeted we "link it" here
typedef struct _linux_atm_addr
{
@@ -40,6 +50,7 @@ typedef struct _linux_atm_addr
#else
typedef int ATM_Addr;
#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */
/**
* @class ACE_ATM_Addr
*
@@ -53,12 +64,15 @@ public:
static const int OPT_FLAGS_CPID;
static const int OPT_FLAGS_PMP;
static const int DEFAULT_SELECTOR;
// = Initialization methods.
/// Default constructor.
ACE_ATM_Addr (u_char selector = DEFAULT_SELECTOR);
/// Copy constructor.
ACE_ATM_Addr (const ACE_ATM_Addr &,
u_char selector = DEFAULT_SELECTOR);
/**
* Creates an ACE_ATM_Addr from an ATMSAPAddress structure. This
* is vendor specific (FORE systems). May need to change when other
@@ -66,6 +80,7 @@ public:
*/
ACE_ATM_Addr (const ATM_Addr *,
u_char selector = DEFAULT_SELECTOR);
/**
* Initializes an ACE_ATM_Addr from the <sap> which can be
* "atm-address" (e.g.,
@@ -74,15 +89,19 @@ public:
*/
ACE_ATM_Addr (const ACE_TCHAR sap[],
u_char selector = DEFAULT_SELECTOR);
/// Default dtor.
~ACE_ATM_Addr (void);
// = Initialization methods (useful after object construction).
/// Default initialization for non-address values (e.g.,
/// t_atm_sap_addr.SVE_tag_addr, t_atm_sap_addr.SVE_tag_selector)
void init (u_char selector = DEFAULT_SELECTOR);
/// Initializes from another ACE_ATM_Addr.
int set (const ACE_ATM_Addr &,
u_char selector = DEFAULT_SELECTOR);
/**
* Initializes an ACE_ATM_Addr from an ATMSAPAddress/sockaddr_atm
* structure. This is vendor specific (FORE systems). May need to
@@ -90,6 +109,7 @@ public:
*/
int set (const ATM_Addr *,
u_char selector = DEFAULT_SELECTOR);
/**
* Initializes an ACE_ATM_Addr from the <sap> which can be
* "atm-address" (e.g.,
@@ -98,6 +118,7 @@ public:
*/
int set (const ACE_TCHAR sap[],
u_char selector = DEFAULT_SELECTOR);
/**
* Initializes an ACE_ATM_Addr from the <sap> which can be
* "atm-address" (e.g.,
@@ -105,6 +126,7 @@ public:
* (e.g., "frisbee.cs.wustl.edu").
*/
virtual int string_to_addr (const ACE_TCHAR sap[]);
/**
* Return the character representation of the ATM address (e.g.,
* "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") storing it in
@@ -114,6 +136,7 @@ public:
*/
virtual int addr_to_string (ACE_TCHAR addr[],
size_t addrlen) const;
/**
* Return the character representation of the ATM address (e.g.,
* "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00"). Returns -1
@@ -122,40 +145,53 @@ public:
* area.)
*/
const ACE_TCHAR *addr_to_string (void) const;
/// Return a pointer to the underlying network address.
virtual void *get_addr (void) const;
/// Set a pointer to the address.
virtual void set_addr (void *, int);
/// Return the selector for network address.
u_char get_selector (void) const;
/// Set the selector for the network address.
void set_selector (u_char selector);
/**
* Compare two addresses for equality. The addresses are considered
* equal if they contain the same ATM address. Q: Is there any
* other check for equality needed for ATM?
*/
bool operator == (const ACE_ATM_Addr &SAP) const;
/// Compare two addresses for inequality.
bool operator != (const ACE_ATM_Addr &SAP) const;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
// char *construct_options (ACE_HANDLE fd,
// int qos_kb,
// int flags,
// long *optsize);
// // Construct options for ATM connections
private:
ATM_Addr atm_addr_;
};
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ATM_Addr.inl"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_ATM */
#include /**/ "ace/post.h"
#endif /* ACE_ATM_ADDR_H */
+4
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: ATM_Addr.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE u_char
ACE_ATM_Addr::get_selector (void) const
{
@@ -16,6 +18,7 @@ ACE_ATM_Addr::get_selector (void) const
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
ACE_INLINE void
ACE_ATM_Addr::set_selector (u_char selector)
{
@@ -30,4 +33,5 @@ ACE_ATM_Addr::set_selector (u_char selector)
ACE_UNUSED_ARG (selector);
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
ACE_END_VERSIONED_NAMESPACE_DECL
+22
View File
@@ -1,22 +1,31 @@
// ATM_Connector.cpp
// $Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ATM_Connector.h"
#if defined (ACE_HAS_ATM)
#include "ace/Handle_Set.h"
ACE_RCSID(ace, ATM_Connector, "$Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if !defined (__ACE_INLINE__)
#include "ace/ATM_Connector.inl"
#endif /* __ACE_INLINE__ */
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
ACE_ATM_Connector::ACE_ATM_Connector (void)
{
ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
}
// Actively connect and produce a new ACE_ATM_Stream if things go well...
// Connect the <new_stream> to the <remote_sap>, waiting up to
// <timeout> amount of time if necessary.
int
ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
const ACE_ATM_Addr &remote_sap,
@@ -45,23 +54,29 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
#elif defined (ACE_HAS_FORE_ATM_WS2)
ACE_DEBUG(LM_DEBUG,
ACE_TEXT ("ATM_Connector(connect): set QoS parameters\n" ));
ACE_HANDLE s = new_stream.get_handle();
struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
ACE_QoS cqos = options.get_qos();
ACE_QoS_Params qos_params = ACE_QoS_Params(0,
0,
&cqos,
0,
0);
ACE_DEBUG(LM_DEBUG,
ACE_TEXT ("ATM_Connector(connect): connecting...\n"));
int result = ACE_OS::connect( s,
( struct sockaddr *)saddr,
sizeof( struct sockaddr_atm ),
qos_params );
if ( result != 0 )
ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n",
::WSAGetLastError());
return result;
#elif defined (ACE_HAS_LINUX_ATM)
ACE_UNUSED_ARG (params);
@@ -69,10 +84,12 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
ACE_UNUSED_ARG (reuse_addr);
ACE_UNUSED_ARG (perms);
ACE_UNUSED_ARG (flags);
ACE_HANDLE handle = new_stream.get_handle();
ATM_QoS qos =options.get_qos();
ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
*remote_addr=(ATM_Addr*)remote_sap.get_addr();
if (ACE_OS::setsockopt(handle,
SOL_ATM,
SO_ATMSAP,
@@ -90,13 +107,16 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
errno));
return -1;
}
int result = ACE_OS::connect(handle,
(struct sockaddr *)&(remote_addr->sockaddratmsvc),
sizeof( remote_addr->sockaddratmsvc));
if ( result != 0 )
ACE_DEBUG(LM_DEBUG,
ACE_TEXT ("ATM_Connector(connect): connection failed, %d\n"),
errno);
return result;
#else
ACE_UNUSED_ARG (new_stream);
@@ -111,7 +131,9 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_ATM */
+21
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file ATM_Connector.h
@@ -8,17 +9,23 @@
* @author Joe Hoffert <[email protected]>
*/
//=============================================================================
#ifndef ACE_ATM_CONNECTOR_H
#define ACE_ATM_CONNECTOR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_ATM)
#include "ace/ATM_Stream.h"
#include "ace/ATM_Params.h"
#include "ace/ATM_QoS.h"
#if defined (ACE_WIN32) || defined (ACE_HAS_LINUX_ATM)
#include "ace/SOCK_Connector.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -31,8 +38,10 @@ typedef ACE_XTI_ATM_Mcast ATM_Connector;
// Open versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#endif
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_ATM_Connector
*
@@ -45,6 +54,7 @@ public:
// = Initialization methods.
/// Default constructor.
ACE_ATM_Connector (void);
/**
* Actively connect and produce a @a new_stream if things go well.
* The @a remote_sap is the address that we are trying to connect
@@ -74,6 +84,7 @@ public:
int flags = O_RDWR,
#endif /* ACE_WIN32 */
int perms = 0);
/**
* Actively connect and produce a @a new_stream if things go well.
* The @a remote_sap is the address that we are trying to connect
@@ -104,6 +115,7 @@ public:
int flags = O_RDWR,
#endif /* ACE_WIN32 */
int perms = 0);
/**
* Try to complete a non-blocking connection.
* If connection completion is successful then @a new_stream contains
@@ -113,6 +125,7 @@ public:
int complete (ACE_ATM_Stream &new_stream,
ACE_ATM_Addr *remote_sap,
ACE_Time_Value *tv);
/**
* Actively add a leaf to the root (i.e., point-to-multipoint). The
* @a remote_sap is the address of the leaf that we
@@ -121,23 +134,31 @@ public:
int add_leaf (ACE_ATM_Stream &current_stream,
const ACE_Addr &remote_sap,
ACE_ATM_QoS &qos);
/// Resets any event associations on this handle
int reset_new_handle (ACE_HANDLE handle);
// = Meta-type info
typedef ACE_ATM_Addr PEER_ADDR;
typedef ACE_ATM_Stream PEER_STREAM;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
ATM_Connector connector_;
};
// Open versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ATM_Connector.inl"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_ATM */
#include /**/ "ace/post.h"
#endif /* ACE_ATM_CONNECTOR_H */
+15
View File
@@ -1,8 +1,10 @@
// -*- C++ -*-
//
// $Id: ATM_Connector.inl 80826 2008-03-04 14:51:23Z wotte $
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void
ACE_ATM_Connector::dump (void) const
{
@@ -10,6 +12,7 @@ ACE_ATM_Connector::dump (void) const
ACE_TRACE ("ACE_ATM_Connector::dump");
#endif /* ACE_HAS_DUMP */
}
ACE_INLINE
ACE_ATM_Connector::ACE_ATM_Connector (ACE_ATM_Stream &new_stream,
const ACE_ATM_Addr &remote_sap,
@@ -35,7 +38,9 @@ ACE_ATM_Connector::ACE_ATM_Connector (ACE_ATM_Stream &new_stream,
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_ATM_Stream::ACE_ATM_Stream")));
}
// Try to complete a non-blocking connection.
ACE_INLINE
int
ACE_ATM_Connector::complete (ACE_ATM_Stream &new_stream,
@@ -54,6 +59,7 @@ ACE_ATM_Connector::complete (ACE_ATM_Stream &new_stream,
return 0;
#endif
}
ACE_INLINE
int
ACE_ATM_Connector::add_leaf (ACE_ATM_Stream &current_stream,
@@ -70,26 +76,33 @@ ACE_ATM_Connector::add_leaf (ACE_ATM_Stream &current_stream,
struct sockaddr_atm *saddr = (struct sockaddr_atm *)remote_sap.get_addr();
ACE_QoS cqos = qos.get_qos();
int addr_len = sizeof( struct sockaddr_atm );
ACE_QoS_Params qos_params(0,
0,
&cqos,
0,
(JL_SENDER_ONLY));
ACE_OS::printf( "ATM_Connector::add_leaf: connecting...\n" );
ACE_HANDLE result = ACE_OS::join_leaf(current_stream.get_handle(),
(struct sockaddr *)saddr,
addr_len,
qos_params);
if ( result == ACE_INVALID_HANDLE )
ACE_OS::printf( "ATM_Connector(add_leaf): connection failed, %d\n",
::WSAGetLastError());
return (result != ACE_INVALID_HANDLE);
#elif defined (ACE_HAS_LINUX_ATM)
ACE_OS::printf("ATM_Connector(add_leaf): not yet implemented in Linux \n");
ACE_UNUSED_ARG(current_stream);
ACE_UNUSED_ARG(remote_sap);
ACE_UNUSED_ARG(leaf_id);
ACE_UNUSED_ARG(timeout);
return 0;
#else
ACE_UNUSED_ARG(current_stream);
@@ -99,6 +112,7 @@ ACE_ATM_Connector::add_leaf (ACE_ATM_Stream &current_stream,
return 0;
#endif
}
ACE_INLINE
int
ACE_ATM_Connector::reset_new_handle (ACE_HANDLE handle)
@@ -113,5 +127,6 @@ ACE_ATM_Connector::reset_new_handle (ACE_HANDLE handle)
return 0;
#endif /* ACE_WIN32 */
}
// Close versioned namespace, if enabled by the user.
ACE_END_VERSIONED_NAMESPACE_DECL
+9
View File
@@ -1,12 +1,21 @@
// $Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ATM_Params.h"
#if defined (ACE_HAS_ATM)
ACE_RCSID(ace, ATM_Params, "$Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if !defined (__ACE_INLINE__)
#include "ace/ATM_Params.inl"
#endif /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Params)
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_ATM */
+50
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//==========================================================================
/**
* @file ATM_Params.h
@@ -9,15 +10,21 @@
*/
//==========================================================================
#ifndef ACE_ATM_PARAMS_H
#define ACE_ATM_PARAMS_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_ATM)
#include /**/ "ace/ACE_export.h"
#if defined (ACE_HAS_FORE_ATM_XTI)
#include "ace/TLI.h"
#define ATM_PROTOCOL_DEFAULT 0
@@ -41,7 +48,9 @@ typedef int Param_Udata;
typedef int Param_Info;
typedef int Param_Udata;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_ATM_Params
*
@@ -77,88 +86,129 @@ public:
= ACE_FLAG_MULTIPOINT_C_ROOT
| ACE_FLAG_MULTIPOINT_D_ROOT, // connector by default
int reuse_addr = 0);
/// Destructor.
~ACE_ATM_Params ();
/// Get protocol family.
int get_protocol_family (void) const;
/// Set protocol family.
void set_protocol_family (int);
/// Get protocol.
int get_protocol (void) const;
/// Set protocol.
void set_protocol (int);
/// Get type.
int get_type (void) const;
/// Set type.
void set_type (int);
/// Get protocol info.
ACE_Protocol_Info *get_protocol_info( void );
/// Set protocol info.
void set_protocol_info( ACE_Protocol_Info *);
/// Get socket group.
ACE_SOCK_GROUP get_sock_group( void );
/// Set socket group.
void set_sock_group( ACE_SOCK_GROUP );
/// Get socket flags.
u_long get_flags( void );
/// Set socket flags.
void set_flags( u_long );
/// Get reuse_addr flag.
int get_reuse_addr (void) const;
/// Set reuse_addr flag.
void set_reuse_addr (int);
/// Get device.
const char* get_device (void) const;
/// Get info.
Param_Info* get_info (void) const;
/// Set info.
void set_info (Param_Info *);
/// Get r/w flag.
int get_rw_flag (void) const;
/// Set r/w flag.
void set_rw_flag (int);
/// Get user data.
Param_Udata* get_user_data (void) const;
/// Set user data.
void set_user_data (Param_Udata*);
/// Get open flag.
int get_oflag (void) const;
/// Set open flag.
void set_oflag (int);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
/// Protocol family for sockets connections.
int protocol_family_;
/// Protocol for sockets connections.
int protocol_;
/// Type for opening sockets.
int type_;
/// Information about the protocol.
ACE_Protocol_Info *protocol_info_;
/// Socket group used (for sockets only).
ACE_SOCK_GROUP group_;
/// Flags for sockets (for sockets only).
u_long flags_;
/// Flag for reusing address for opening sockets.
int reuse_addr_;
/// Device name for XTI/ATM connections.
const char *device_;
/// Info for XTI/ATM connections.
Param_Info *info_;
/// R/W flag for XTI/ATM connections.
int rw_flag_;
/// User data for XTI/ATM connections.
Param_Udata *udata_;
/// Open flag for XTI/ATM connections.
int oflag_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ATM_Params.inl"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_ATM */
#include /**/ "ace/post.h"
#endif /* ACE_ATM_PARAMS_H */
+28
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: ATM_Params.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void
ACE_ATM_Params::dump (void) const
{
@@ -9,6 +11,7 @@ ACE_ATM_Params::dump (void) const
ACE_TRACE ("ACE_ATM_Params::dump");
#endif /* ACE_HAS_DUMP */
}
ACE_INLINE
ACE_ATM_Params::ACE_ATM_Params (int rw_flag,
const char device[],
@@ -37,12 +40,14 @@ ACE_ATM_Params::ACE_ATM_Params (int rw_flag,
{
ACE_TRACE ("ACE_ATM_Params::ACE_ATM_Params");
}
// Default dtor.
ACE_INLINE
ACE_ATM_Params::~ACE_ATM_Params (void)
{
ACE_TRACE ("ACE_ATM_Params::~ACE_ATM_Params");
}
ACE_INLINE
int
ACE_ATM_Params::get_protocol_family (void) const
@@ -50,6 +55,7 @@ ACE_ATM_Params::get_protocol_family (void) const
ACE_TRACE ("ACE_ATM_Params::get_protocol_family");
return protocol_family_;
}
ACE_INLINE
void
ACE_ATM_Params::set_protocol_family (int family)
@@ -57,6 +63,7 @@ ACE_ATM_Params::set_protocol_family (int family)
ACE_TRACE ("ACE_ATM_Params::set_protocol_family");
protocol_family_ = family;
}
ACE_INLINE
int
ACE_ATM_Params::get_protocol (void) const
@@ -64,6 +71,7 @@ ACE_ATM_Params::get_protocol (void) const
ACE_TRACE ("ACE_ATM_Params::get_protocol");
return protocol_;
}
ACE_INLINE
void
ACE_ATM_Params::set_protocol (int protocol)
@@ -71,6 +79,7 @@ ACE_ATM_Params::set_protocol (int protocol)
ACE_TRACE ("ACE_ATM_Params::set_protocol");
protocol_ = protocol;
}
ACE_INLINE
int
ACE_ATM_Params::get_type (void) const
@@ -78,6 +87,7 @@ ACE_ATM_Params::get_type (void) const
ACE_TRACE ("ACE_ATM_Params::get_type");
return type_;
}
ACE_INLINE
void
ACE_ATM_Params::set_type (int type)
@@ -85,6 +95,7 @@ ACE_ATM_Params::set_type (int type)
ACE_TRACE ("ACE_ATM_Params::set_type");
type_ = type;
}
ACE_INLINE
ACE_Protocol_Info*
ACE_ATM_Params::get_protocol_info( void )
@@ -92,6 +103,7 @@ ACE_ATM_Params::get_protocol_info( void )
ACE_TRACE ("ACE_ATM_Params::get_protocol_info");
return protocol_info_;
}
ACE_INLINE
void
ACE_ATM_Params::set_protocol_info( ACE_Protocol_Info *protocol_info )
@@ -99,6 +111,7 @@ ACE_ATM_Params::set_protocol_info( ACE_Protocol_Info *protocol_info )
ACE_TRACE ("ACE_ATM_Params::set_protocol_info");
protocol_info_ = protocol_info;
}
ACE_INLINE
ACE_SOCK_GROUP
ACE_ATM_Params::get_sock_group( void )
@@ -106,6 +119,7 @@ ACE_ATM_Params::get_sock_group( void )
ACE_TRACE ("ACE_ATM_Params::get_sock_group");
return group_;
}
ACE_INLINE
void
ACE_ATM_Params::set_sock_group( ACE_SOCK_GROUP g )
@@ -113,6 +127,7 @@ ACE_ATM_Params::set_sock_group( ACE_SOCK_GROUP g )
ACE_TRACE ("ACE_ATM_Params::set_sock_group");
group_ = g;
}
ACE_INLINE
u_long
ACE_ATM_Params::get_flags( void )
@@ -120,6 +135,7 @@ ACE_ATM_Params::get_flags( void )
ACE_TRACE ("ACE_ATM_Params::get_flags");
return flags_;
}
ACE_INLINE
void
ACE_ATM_Params::set_flags( u_long flags)
@@ -127,6 +143,7 @@ ACE_ATM_Params::set_flags( u_long flags)
ACE_TRACE ("ACE_ATM_Params::set_flags");
flags_ = flags;
}
ACE_INLINE
int
ACE_ATM_Params::get_reuse_addr (void) const
@@ -134,6 +151,7 @@ ACE_ATM_Params::get_reuse_addr (void) const
ACE_TRACE ("ACE_ATM_Params::get_reuse_addr");
return reuse_addr_;
}
ACE_INLINE
void
ACE_ATM_Params::set_reuse_addr (int reuse_addr)
@@ -141,6 +159,7 @@ ACE_ATM_Params::set_reuse_addr (int reuse_addr)
ACE_TRACE ("ACE_ATM_Params::set_reuse_addr");
reuse_addr_ = reuse_addr;
}
ACE_INLINE
const char*
ACE_ATM_Params::get_device (void) const
@@ -148,6 +167,7 @@ ACE_ATM_Params::get_device (void) const
ACE_TRACE ("ACE_ATM_Params::get_device");
return device_;
}
ACE_INLINE
Param_Info*
ACE_ATM_Params::get_info (void) const
@@ -155,6 +175,7 @@ ACE_ATM_Params::get_info (void) const
ACE_TRACE ("ACE_ATM_Params::get_info");
return info_;
}
ACE_INLINE
void
ACE_ATM_Params::set_info (Param_Info* info)
@@ -162,6 +183,7 @@ ACE_ATM_Params::set_info (Param_Info* info)
ACE_TRACE ("ACE_ATM_Params::set_info");
info_ = info;
}
ACE_INLINE
int
ACE_ATM_Params::get_rw_flag (void) const
@@ -169,6 +191,7 @@ ACE_ATM_Params::get_rw_flag (void) const
ACE_TRACE ("ACE_ATM_Params::get_rw_flag");
return rw_flag_;
}
ACE_INLINE
void
ACE_ATM_Params::set_rw_flag (int rw_flag)
@@ -176,6 +199,7 @@ ACE_ATM_Params::set_rw_flag (int rw_flag)
ACE_TRACE ("ACE_ATM_Params::set_rw_flag");
rw_flag_ = rw_flag;
}
ACE_INLINE
Param_Udata*
ACE_ATM_Params::get_user_data (void) const
@@ -183,6 +207,7 @@ ACE_ATM_Params::get_user_data (void) const
ACE_TRACE ("ACE_ATM_Params::get_user_data");
return udata_;
}
ACE_INLINE
void
ACE_ATM_Params::set_user_data (Param_Udata *udata)
@@ -190,6 +215,7 @@ ACE_ATM_Params::set_user_data (Param_Udata *udata)
ACE_TRACE ("ACE_ATM_Params::set_user_data");
udata_ = udata;
}
ACE_INLINE
int
ACE_ATM_Params::get_oflag (void) const
@@ -197,6 +223,7 @@ ACE_ATM_Params::get_oflag (void) const
ACE_TRACE ("ACE_ATM_Params::get_oflag");
return oflag_;
}
ACE_INLINE
void
ACE_ATM_Params::set_oflag (int oflag)
@@ -204,4 +231,5 @@ ACE_ATM_Params::set_oflag (int oflag)
ACE_TRACE ("ACE_ATM_Params::set_oflag");
oflag_ = oflag;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+93
View File
@@ -1,11 +1,17 @@
// $Id: ATM_QoS.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ATM_QoS.h"
ACE_RCSID(ace, ATM_QoS, "$Id: ATM_QoS.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if defined (ACE_HAS_ATM)
#if !defined (__ACE_INLINE__)
#include "ace/ATM_QoS.inl"
#endif /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
#define BHLI_MAGIC "FORE_ATM"
// This is line rate in cells/s for an OC-3 MM interface.
@@ -30,7 +36,9 @@ const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0;
const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x0;
const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS)
ACE_ATM_QoS::ACE_ATM_QoS (int pktSize)
{
ACE_TRACE ("ACE_ATM_QoS::ACE_ATM_QoS");
@@ -45,6 +53,7 @@ ACE_ATM_QoS::ACE_ATM_QoS (int pktSize)
ACE_UNUSED_ARG (pktSize);
#endif /* ACE_HAS_LINUX_ATM */
}
ACE_ATM_QoS::ACE_ATM_QoS(int rate,
int pktSize)
{
@@ -56,6 +65,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
ATM_QOS_CLASS_IE ie_qos;
Q2931_IE *ie_ptr;
int size;
// Setting up cbr parameters ...
ie_aalparams.AALType = AALTYPE_5;
ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize
@@ -64,7 +74,9 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
= pktSize; // was 1516;
ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE);
ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
ie_td.Forward.PeakCellRate_CLP01 = rate;
ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
@@ -72,6 +84,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
ie_td.Forward.Tagging = SAP_FIELD_ABSENT;
ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
ie_td.Backward.PeakCellRate_CLP01 = rate;
ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
@@ -79,22 +92,29 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
ie_td.Backward.Tagging = SAP_FIELD_ABSENT;
ie_td.BestEffort = 0; // Note: this must be set to zero for CBR.
size += sizeof( Q2931_IE_TYPE )
+ sizeof( ULONG )
+ sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
ie_bbc.BearerClass = BCOB_X;
ie_bbc.TrafficType = TT_CBR;
ie_bbc.TimingRequirements = TR_END_TO_END;
ie_bbc.ClippingSusceptability = CLIP_NOT;
ie_bbc.UserPlaneConnectionConfig = UP_P2P;
size += sizeof( Q2931_IE_TYPE )
+ sizeof( ULONG )
+ sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE );
ie_qos.QOSClassForward = QOS_CLASS1;
ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used
// since we do only simplex data xfer.
size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
if (qos_.ProviderSpecific.buf == 0) {
ACE_ERROR((LM_ERROR,
@@ -104,18 +124,21 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
}
qos_.ProviderSpecific.len = size;
ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf;
ie_ptr->IEType = IE_AALParameters;
ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ sizeof( ULONG )
+ sizeof( AAL_PARAMETERS_IE );
ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE));
ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
ie_ptr->IEType = IE_TrafficDescriptor;
ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ sizeof( ULONG )
+ sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE));
ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
ie_ptr->IEType = IE_BroadbandBearerCapability;
ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
@@ -124,12 +147,14 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
ACE_OS::memcpy(ie_ptr->IE,
&ie_bbc,
sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE));
ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
ie_ptr->IEType = IE_QOSClass;
ie_ptr->IELength = sizeof( Q2931_IE_TYPE )
+ sizeof( ULONG )
+ sizeof( ATM_QOS_CLASS_IE );
ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE));
// qos_.SendingFlowspec.TokenRate = 0xffffffff;
// qos_.SendingFlowspec.TokenBucketSize = 0xffffffff;
// qos_.SendingFlowspec.PeakBandwidth = 0xffffffff;
@@ -139,6 +164,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
// This will most probably be ignored by the service provider.
// qos_.SendingFlowspec.MaxSduSize = 0xffffffff;
// qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff;
// qos_.ReceivingFlowspec.TokenRate = 0xffffffff;
// qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff;
// qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff;
@@ -148,6 +174,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
// This will most probably be ignored by the service provider.
// qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff;
// qos_.ReceivingFlowspec.MinimumPolicedSize = 0;
ACE_Flow_Spec send_fspec( 0xffffffff,
0xffffffff,
0xffffffff,
@@ -170,6 +197,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
0,
15,
ACE_DEFAULT_THREAD_PRIORITY );
qos_.sending_flowspec (send_fspec);
qos_.receiving_flowspec (recv_fspec);
#elif defined (ACE_HAS_FORE_ATM_XTI)
@@ -181,6 +209,7 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
sizeof(qos_));
qos_.aal = ATM_PROTOCOL_DEFAULT;
qos_.rxtp.max_sdu = pktSize;
if (rate > 0) {
qos_.rxtp.pcr = rate;
qos_.rxtp.traffic_class = ATM_CBR;
@@ -191,11 +220,13 @@ ACE_ATM_QoS::ACE_ATM_QoS(int rate,
qos_.rxtp.traffic_class = ATM_UBR;
qos_.txtp.traffic_class = ATM_UBR;
}
qos_.txtp.max_sdu = pktSize;
#else
ACE_UNUSED_ARG (rate);
#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
}
void
ACE_ATM_QoS::set_cbr_rate (int rate,
int pktSize)
@@ -210,7 +241,9 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
Q2931_IE *ie_ptr;
int size;
*/
ACE_OS::printf( "ATM_QoS(set_cbr_rate): set rate to %d c/s\n", rate );
// Setting up cbr parameters ...
/*
FORE has changed this - we no longer specify QoS this way
@@ -221,7 +254,9 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
= pktSize; // was 1516;
ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE);
ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
ie_td.Forward.PeakCellRate_CLP01 = rate;
ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
@@ -229,6 +264,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
ie_td.Forward.Tagging = SAP_FIELD_ABSENT;
ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT;
ie_td.Backward.PeakCellRate_CLP01 = rate;
ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT;
@@ -236,22 +272,29 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT;
ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT;
ie_td.Backward.Tagging = SAP_FIELD_ABSENT;
ie_td.BestEffort = 0; // Note: this must be set to zero for CBR.
size += sizeof( Q2931_IE_TYPE ) +
sizeof( ULONG ) +
sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
ie_bbc.BearerClass = BCOB_X;
ie_bbc.TrafficType = TT_CBR;
ie_bbc.TimingRequirements = TR_END_TO_END;
ie_bbc.ClippingSusceptability = CLIP_NOT;
ie_bbc.UserPlaneConnectionConfig = UP_P2P;
size += sizeof(Q2931_IE_TYPE) +
sizeof(ULONG) +
sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE);
ie_qos.QOSClassForward = QOS_CLASS1;
ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used
// since we only simplex data xfer.
size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
if (qos_.ProviderSpecific.buf == 0) {
ACE_ERROR((LM_ERROR,
@@ -261,18 +304,21 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
}
qos_.ProviderSpecific.len = size;
ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf;
ie_ptr->IEType = IE_AALParameters;
ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
sizeof( ULONG ) +
sizeof( AAL_PARAMETERS_IE );
ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE));
ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
ie_ptr->IEType = IE_TrafficDescriptor;
ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
sizeof( ULONG ) +
sizeof( ATM_TRAFFIC_DESCRIPTOR_IE );
ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE));
ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
ie_ptr->IEType = IE_BroadbandBearerCapability;
ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) +
@@ -281,12 +327,14 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
ACE_OS::memcpy( ie_ptr->IE,
&ie_bbc,
sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ));
ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength);
ie_ptr->IEType = IE_QOSClass;
ie_ptr->IELength = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) +
sizeof(ATM_QOS_CLASS_IE);
ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE));
*/
const int BYTES_PER_ATM_CELL = 53;
ACE_OS::memset(&qos_, 0, sizeof(ATM_QoS));
// Setting the token rate sets the minimum rate. 3 Mbits/sec seems too high.
@@ -306,6 +354,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
qos_.ProviderSpecific.buf=0;
qos_.ProviderSpecific.len=0;
// unidirectional P2MP; we don't need to setup the Receiving flowspec
//qos_.SendingFlowspec.TokenRate = 0xffffffff;
//qos_.SendingFlowspec.TokenBucketSize = 0xffffffff;
//qos_.SendingFlowspec.PeakBandwidth = 0xffffffff;
@@ -315,6 +364,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
// This will most probably be ignored by the service provider.
//qos_.SendingFlowspec.MaxSduSize = 0xffffffff;
//qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff;
//qos_.ReceivingFlowspec.TokenRate = 0xffffffff;
//qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff;
//qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff;
@@ -324,6 +374,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
// This will most probably be ignored by the service provider.
//qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff;
//qos_.ReceivingFlowspec.MinimumPolicedSize = 0;
/*
ACE_Flow_Spec send_fspec( 0xffffffff,
0xffffffff,
@@ -347,6 +398,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
0,
15,
ACE_DEFAULT_THREAD_PRIORITY );
qos_.sending_flowspec( send_fspec );
qos_.receiving_flowspec( recv_fspec );
*/
@@ -355,6 +407,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
ACE_UNUSED_ARG (pktSize);
#elif defined (ACE_HAS_LINUX_ATM)
ACE_UNUSED_ARG (pktSize);
qos_.rxtp.traffic_class = ATM_CBR;
qos_.rxtp.pcr = rate;
qos_.txtp.traffic_class = ATM_CBR;
@@ -363,6 +416,7 @@ ACE_ATM_QoS::set_cbr_rate (int rate,
ACE_UNUSED_ARG (rate);
#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
}
void
ACE_ATM_QoS::set_rate (ACE_HANDLE fd,
int rate,
@@ -371,6 +425,7 @@ ACE_ATM_QoS::set_rate (ACE_HANDLE fd,
ACE_TRACE ("ACE_ATM_QoS::set_rate");
#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
set_cbr_rate( rate );
ACE_UNUSED_ARG( fd );
ACE_UNUSED_ARG( flags );
#elif defined (ACE_HAS_FORE_ATM_XTI)
@@ -384,6 +439,7 @@ ACE_ATM_QoS::set_rate (ACE_HANDLE fd,
ACE_UNUSED_ARG (rate);
#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM || ACE_HAS_FORE_ATM_XTI */
}
char*
ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
int rate,
@@ -401,35 +457,46 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
char *buf;
int qos_cells;
struct t_info info;
if (ACE_OS::t_getinfo (fd, &info) == -1)
{
ACE_OS::t_error ("t_getinfo");
return 0;
}
buf = (char *) ACE_OS::malloc (info.options);
if (buf == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Unable to allocate %d bytes for options\n"),
info.options),
0);
popt = (struct t_opthdr *) buf;
if (flags & OPT_FLAGS_CPID)
{
// This constructs the T_ATM_ORIG_ADDR option, which is used to
// signal the UNI 3.1 Calling Party ID Information Element.
t_atm_addr *source_addr;
popt->len = sizeof (struct t_opthdr) + sizeof (t_atm_addr);
popt->level = T_ATM_SIGNALING;
popt->name = T_ATM_ORIG_ADDR;
popt->status = 0;
source_addr =
(t_atm_addr *)((char *) popt + sizeof (struct t_opthdr));
source_addr->address_format = T_ATM_ENDSYS_ADDR;
source_addr->address_length = ATMNSAP_ADDR_LEN;
ATMSAPAddress local_addr;
struct t_bind boundaddr;
boundaddr.addr.maxlen = sizeof(local_addr);
boundaddr.addr.buf = (char *) &local_addr;
//if (ACE_OS::t_getprotaddr(fd, &boundaddr, 0) < 0) {
if (ACE_OS::t_getname(fd,
&boundaddr.addr,
@@ -441,30 +508,39 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
ACE_OS::free (buf);
return 0;
}
ACE_OS::memcpy(source_addr->address,
local_addr.sap.t_atm_sap_addr.address,
ATMNSAP_ADDR_LEN);
popt = T_OPT_NEXTHDR (buf, info.options , popt);
}
// This constructs all options necessary (bearer cap., QoS, and
// Traffic Descriptor) to signal for a CBR connection with the
// specified QoS in kbit/sec., and/or specify a PMP connection.
// For FORE 200e cards, the adapter shapes traffic to CBR with rate
// equal to PCR CLP=0+1 (traffic.forward.PCR_all_traffic)
qos_cells = (rate * 1000) / (48*8);
if ((qos_cells > 0 && qos_cells < LINE_RATE)
|| (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)))
{
struct t_atm_bearer *bearer;
struct t_atm_traffic *traffic;
// T_ATM_BEARER_CAP: Broadband bearer capability
popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_bearer);
popt->level = T_ATM_SIGNALING;
popt->name = T_ATM_BEARER_CAP;
popt->status = 0;
bearer = (struct t_atm_bearer *)((char *) popt +
sizeof (struct t_opthdr));
bearer->bearer_class = T_ATM_CLASS_X;
if (qos_cells)
{
bearer->traffic_type = T_ATM_CBR;
@@ -476,18 +552,23 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
bearer->timing_requirements = 0;
}
bearer->clipping_susceptibility = T_ATM_NULL;
if (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
bearer->connection_configuration = T_ATM_1_TO_MANY;
else
bearer->connection_configuration = T_ATM_1_TO_1;
popt = T_OPT_NEXTHDR (buf, info.options, popt);
// T_ATM_TRAFFIC: traffic descriptor
popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_traffic);
popt->level = T_ATM_SIGNALING;
popt->name = T_ATM_TRAFFIC;
popt->status = 0;
traffic = (struct t_atm_traffic *)((char *) popt +
sizeof (struct t_opthdr));
traffic->forward.PCR_high_priority = T_ATM_ABSENT;
traffic->forward.PCR_all_traffic = qos_cells ? qos_cells : LINE_RATE;
traffic->forward.SCR_high_priority = T_ATM_ABSENT;
@@ -495,6 +576,7 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
traffic->forward.MBS_high_priority = T_ATM_ABSENT;
traffic->forward.MBS_all_traffic = T_ATM_ABSENT;
traffic->forward.tagging = T_NO;
traffic->backward.PCR_high_priority = T_ATM_ABSENT;
traffic->backward.PCR_all_traffic =
(ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
@@ -504,27 +586,35 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
traffic->backward.MBS_high_priority = T_ATM_ABSENT;
traffic->backward.MBS_all_traffic = T_ATM_ABSENT;
traffic->backward.tagging = T_NO;
traffic->best_effort = qos_cells ? T_NO : T_YES;
popt = T_OPT_NEXTHDR (buf,
info.options,
popt);
}
if (qos_cells > 0 && qos_cells < LINE_RATE)
{
struct t_atm_qos *qos;
// T_ATM_QOS: Quality of Service
popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_qos);
popt->level = T_ATM_SIGNALING;
popt->name = T_ATM_QOS;
popt->status = 0;
qos = (struct t_atm_qos *)((char *) popt + sizeof (struct t_opthdr));
qos->coding_standard = T_ATM_ITU_CODING;
qos->forward.qos_class = T_ATM_QOS_CLASS_1;
qos->backward.qos_class = T_ATM_QOS_CLASS_1;
popt = T_OPT_NEXTHDR (buf, info.options, popt);
}
// Return actual size of options and option buffer to user.
*len = (char *) popt - buf;
return buf;
#else
ACE_UNUSED_ARG (fd);
@@ -534,6 +624,9 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
return (0);
#endif /* ACE_HAS_FORE_ATM_WS2 */
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_ATM */
+21
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//==========================================================================
/**
* @file ATM_QoS.h
@@ -9,14 +10,19 @@
*/
//==========================================================================
#ifndef ACE_ATM_QoS_H
#define ACE_ATM_QoS_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined(ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_ATM)
#if defined (ACE_HAS_FORE_ATM_WS2)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// just map to WS2 GQOS struct
@@ -37,7 +43,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
typedef int ATM_QoS;
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_ATM_QoS
*
@@ -56,39 +64,52 @@ public:
static const int OPT_FLAGS_PMP;
static const int DEFAULT_SELECTOR;
static const int DEFAULT_PKT_SIZE;
// = Initializattion and termination methods.
/// Default constructor.
ACE_ATM_QoS(int = DEFAULT_PKT_SIZE);
/// Constructor with a CBR rate.
ACE_ATM_QoS(int,
int = DEFAULT_PKT_SIZE);
~ACE_ATM_QoS ();
/// Set the rate.
void set_rate (ACE_HANDLE,
int,
int);
/// Set CBR rate in cells per second.
void set_cbr_rate (int,
int = DEFAULT_PKT_SIZE);
/// Get ATM_QoS struct.
ATM_QoS get_qos (void);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
/// Construct QoS options.
char* construct_options(ACE_HANDLE,
int,
int,
long*);
private:
ATM_QoS qos_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ATM_QoS.inl"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_ATM */
#include /**/ "ace/post.h"
#endif /* ACE_ATM_QoS_H */
+5
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: ATM_QoS.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void
ACE_ATM_QoS::dump (void) const
{
@@ -9,11 +11,13 @@ ACE_ATM_QoS::dump (void) const
ACE_TRACE ("ACE_ATM_QoS::dump");
#endif /* ACE_HAS_DUMP */
}
ACE_INLINE
ACE_ATM_QoS::~ACE_ATM_QoS ()
{
ACE_TRACE ("ACE_ATM_QoS::~ACE_ATM_QoS");
}
ACE_INLINE
ATM_QoS
ACE_ATM_QoS::get_qos (void)
@@ -21,4 +25,5 @@ ACE_ATM_QoS::get_qos (void)
ACE_TRACE ("ACE_ATM_QoS::get_qos");
return qos_;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+42
View File
@@ -1,12 +1,19 @@
// $Id: ATM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ATM_Stream.h"
ACE_RCSID (ace, ATM_Stream, "$Id: ATM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if defined (ACE_HAS_ATM)
#if !defined (__ACE_INLINE__)
#include "ace/ATM_Stream.inl"
#endif /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE (ACE_ATM_Stream)
char*
ACE_ATM_Stream::get_peer_name (void) const
{
@@ -24,6 +31,7 @@ ACE_ATM_Stream::get_peer_name (void) const
// ::t_getprotaddr (get_handle (),
// localaddr,
// peeraddr);
// char* connected_name = (char*) ACE_OS::malloc (peeraddr->addr.len + 1);
// ACE_OS::strcpy (connected_name,
// peeraddr->addr.buf);
@@ -32,8 +40,10 @@ ACE_ATM_Stream::get_peer_name (void) const
// ACE_OS::t_free ((char *) peeraddr,
// T_BIND);
// return (connected_name);
#error "This doesn't seem to work. May need to jimmy-rig something with the"
#error "/etc/xti_hosts file - Ugh!"
ACE_ATM_Addr sa;
struct netbuf name;
name.maxlen = sa.get_size ();
@@ -43,16 +53,19 @@ ACE_ATM_Stream::get_peer_name (void) const
// TI_GETPEERNAME,
// &name);
return (name.buf);
#elif defined (ACE_HAS_FORE_ATM_WS2)
// Use getpeername for WinSock2.
struct sockaddr_atm name;
ACE_OS::memset (&name, 0, sizeof (name));
int nameSize = sizeof (name);
if (ACE_OS::getpeername (this->get_handle (),
(struct sockaddr *) &name,
&nameSize) != 0) {
return 0;
}
char buffer[256];
for (unsigned int index = 0; index < ATM_ADDR_SIZE - 1; index++) {
buffer[ index * 3 ] = '\0';
@@ -63,8 +76,10 @@ ACE_ATM_Stream::get_peer_name (void) const
buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0';
for (index = 0; index < ACE_OS::strlen (buffer); ++index)
buffer[index] = ACE_OS::ace_tolower (buffer[index]);
ifstream atm_hosts ("C:/WINNT/atmhosts");
assert (atm_hosts.is_open ());
// Find the host address in the ATM hosts file and return the
// host name
char line[256];
@@ -85,16 +100,19 @@ ACE_ATM_Stream::get_peer_name (void) const
break;
}
}
return host_name;
#elif defined (ACE_HAS_LINUX_ATM)
ATM_Addr name;
int nameSize = sizeof (name.sockaddratmsvc);
if (ACE_OS::getpeername (this->get_handle (),
(struct sockaddr *) & (name.sockaddratmsvc),
&nameSize) < 0) {
ACE_OS::perror ("ACE_ATM_Stream (get_peer_name) : ");
return 0;
}
static ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
int total_len;
if ((total_len = atm2text (buffer,sizeof buffer,
@@ -103,11 +121,13 @@ ACE_ATM_Stream::get_peer_name (void) const
ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("ACE_ATM_Stream (get_peer_name) :%d"),errno));
return 0;
}
return (char*) buffer;
#else
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
ACE_HANDLE
ACE_ATM_Stream::get_handle (void) const
{
@@ -118,6 +138,7 @@ ACE_ATM_Stream::get_handle (void) const
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
int
ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
ACE_UINT16 &vci) const
@@ -129,12 +150,14 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
int opt_size = sizeof (t_atm_conn_prop);
struct t_info info;
struct t_optmgmt opt_req, opt_ret;
if (ACE_OS::t_getinfo (stream_.get_handle (),
&info) < 0)
{
ACE_OS::t_error ("t_getinfo");
return -1;
}
char *buf_req = (char *) ACE_OS::malloc (info.options);
if (buf_req == 0)
{
@@ -143,6 +166,7 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
info.options);
return -1;
}
char *buf_ret = (char *) ACE_OS::malloc (info.options);
if (buf_ret == 0)
{
@@ -151,41 +175,52 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
info.options);
return -1;
}
ACE_OS::memset (&opt_req, 0, sizeof (opt_req));
ACE_OS::memset (&opt_ret, 0, sizeof (opt_ret));
struct t_opthdr *popt = (struct t_opthdr *) buf_req;
struct t_opthdr *popt_ret = (struct t_opthdr *) buf_ret;
popt->len= sizeof (struct t_opthdr) + opt_size;
// We are only concerned with SVCs so no other check or values are needed
// here.
popt->level = T_ATM_SIGNALING;
popt->name = T_ATM_CONN_PROP;
popt->status = 0;
opt_req.opt.len = popt->len;
opt_req.opt.buf = (char *) popt;
opt_req.flags = T_CURRENT;
popt = T_OPT_NEXTHDR (buf_req,
info.options,
popt);
opt_ret.opt.maxlen = info.options;
opt_ret.opt.buf = (char *) popt_ret;
if (ACE_OS::t_optmgmt (stream_.get_handle (),
&opt_req,
&opt_ret) < 0) {
ACE_OS::t_error ("t_optmgmt");
return -1;
}
ACE_OS::memcpy (connect_opts,
(char *) popt_ret + sizeof (struct t_opthdr),
opt_size);
ACE_OS::free (buf_ret);
ACE_OS::free (buf_req);
vpi = conn_prop.vpi;
vci = conn_prop.vci;
return (0);
#elif defined (ACE_HAS_FORE_ATM_WS2)
ATM_CONNECTION_ID connID;
DWORD bytes = 0;
if (::WSAIoctl ((int) this -> get_handle (),
SIO_GET_ATM_CONNECTION_ID,
0,
@@ -198,8 +233,10 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
== SOCKET_ERROR) {
ACE_OS::printf ("Error: WSAIoctl %d\n", WSAGetLastError ());
}
vpi = (ACE_UINT16) connID.VPI;
vci = (ACE_UINT16) connID.VCI;
return 0;
#elif defined (ACE_HAS_LINUX_ATM)
#if defined (SO_ATMPVC) /* atm version>=0.62 */
@@ -217,6 +254,7 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
}
vpi = (ACE_UINT16) mypvcaddr.sap_addr.vpi;
vci = (ACE_UINT16) mypvcaddr.sap_addr.vci;
return 0;
#elif defined (SO_VCID) /* patch for atm version 0.59 */
struct atm_vcid mypvcid;
@@ -232,18 +270,22 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
}
vpi = (ACE_UINT16) mypvcid.vpi;
vci = (ACE_UINT16) mypvcid.vci;
return 0;
#else
ACE_DEBUG (LM_DEBUG,
ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: Not implemented in this ATM version. Update to >= 0.62\n Or patch 0.59"));
ACE_UNUSED_ARG (vci);
ACE_UNUSED_ARG (vpi);
return (-1);
#endif /* SO_ATMPVC || SO_VCID */
#else
return (-1);
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_ATM */
+24
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file ATM_Stream.h
@@ -9,16 +10,22 @@
*/
//=============================================================================
#ifndef ACE_ATM_STREAM_H
#define ACE_ATM_STREAM_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_ATM)
#include "ace/ATM_Addr.h"
#include "ace/ATM_Params.h"
#if defined (ACE_WIN32)
#include "ace/SOCK_Stream.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -30,7 +37,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
typedef ACE_TLI_Stream ATM_Stream;
ACE_END_VERSIONED_NAMESPACE_DECL
#endif
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_ATM_Stream
*
@@ -42,42 +51,57 @@ public:
// = Initialization and termination methods.
/// Default constructor.
ACE_ATM_Stream (void);
// = ATM-specific open and shutdown operations.
/// open the stream.
int open (ACE_ATM_Params params = ACE_ATM_Params());
/// Close down and release resources.
int close (void);
/// Get the underlying handle.
ACE_HANDLE get_handle (void) const;
/// Get the underlying stream.
ATM_Stream& get_stream (void);
/// Get the name of the connected host.
char* get_peer_name (void) const;
/// Get the VPI and VCI of the stream.
int get_vpi_vci (ACE_UINT16 &vpi,
ACE_UINT16 &vci) const;
/// Recv an n byte buffer from the connected transport mechanism.
ssize_t recv (void *buf,
size_t n,
int *flags = 0) const;
/// Send exactly n bytes to the connected transport mechanism.
ssize_t send_n (const void *buf,
size_t n,
int flags) const;
// = Meta-type info
typedef ACE_ATM_Addr PEER_ADDR;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
/// Typedef'd to the appropriate stream mechanism above.
ATM_Stream stream_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/ATM_Stream.inl"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_ATM */
#include /**/ "ace/post.h"
#endif /* ACE_ATM_STREAM_H */
+13
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: ATM_Stream.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void
ACE_ATM_Stream::dump (void) const
{
@@ -9,11 +11,13 @@ ACE_ATM_Stream::dump (void) const
ACE_TRACE ("ACE_ATM_Stream::dump");
#endif /* ACE_HAS_DUMP */
}
ACE_INLINE
ACE_ATM_Stream::ACE_ATM_Stream (void)
{
ACE_TRACE ("ACE_ATM_Stream::ACE_ATM_Stream");
}
ACE_INLINE
int
ACE_ATM_Stream::open (ACE_ATM_Params params)
@@ -26,6 +30,7 @@ ACE_ATM_Stream::open (ACE_ATM_Params params)
return (handle == ACE_INVALID_HANDLE ? -1 : 0);
#elif defined (ACE_HAS_FORE_ATM_WS2)
params.set_flags( ACE_FLAG_MULTIPOINT_C_ROOT | ACE_FLAG_MULTIPOINT_D_ROOT );
int retval = stream_.open (params.get_type(),
params.get_protocol_family(),
params.get_protocol(),
@@ -35,7 +40,9 @@ ACE_ATM_Stream::open (ACE_ATM_Params params)
params.get_reuse_addr());
if (retval == -1)
return -1;
struct sockaddr_atm sock_addr;
ACE_OS::memset(&sock_addr, 0, sizeof(struct sockaddr_atm));
sock_addr.satm_family = AF_ATM;
sock_addr.satm_number.AddressType=ADDR_ANY;
@@ -50,12 +57,14 @@ ACE_ATM_Stream::open (ACE_ATM_Params params)
ACE_OS::printf("Error binding local address: %d",WSAGetLastError());
return -1;
}
return 0;
#else
ACE_UNUSED_ARG(params);
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI */
}
ACE_INLINE
int
ACE_ATM_Stream::close (void)
@@ -67,6 +76,7 @@ ACE_ATM_Stream::close (void)
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
}
ACE_INLINE
ATM_Stream&
ACE_ATM_Stream::get_stream (void)
@@ -74,6 +84,7 @@ ACE_ATM_Stream::get_stream (void)
ACE_TRACE ("ACE_ATM_Stream::get_stream");
return stream_;
}
ACE_INLINE
ssize_t
ACE_ATM_Stream::recv (void *buf,
@@ -95,6 +106,7 @@ ACE_ATM_Stream::recv (void *buf,
return (0);
#endif /* ACE_HAS_FORE_ATM_XTI */
}
ACE_INLINE
ssize_t
ACE_ATM_Stream::send_n (const void *buf,
@@ -117,4 +129,5 @@ ACE_ATM_Stream::send_n (const void *buf,
return (0);
#endif /* ACE_HAS_FORE_ATM_XTI */
}
ACE_END_VERSIONED_NAMESPACE_DECL
+111
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Acceptor.h
@@ -8,16 +9,23 @@
* @author Douglas C. Schmidt <[email protected]>
*/
//=============================================================================
#ifndef ACE_ACCEPTOR_H
#define ACE_ACCEPTOR_H
#include /**/ "ace/pre.h"
#include "ace/Service_Object.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Strategies_T.h"
#include "ace/Synch_Options.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Acceptor
*
@@ -45,14 +53,17 @@ template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Acceptor : public ACE_Service_Object
{
public:
// Useful STL-style traits.
typedef ACE_PEER_ACCEPTOR_ADDR addr_type;
typedef ACE_PEER_ACCEPTOR acceptor_type;
typedef SVC_HANDLER handler_type;
typedef typename SVC_HANDLER::stream_type stream_type;
/// "Do-nothing" constructor.
ACE_Acceptor (ACE_Reactor * = 0,
int use_select = 1);
/**
* Open the contained @c PEER_ACCEPTOR object to begin listening, and
* register with the specified reactor for accept events. An
@@ -91,6 +102,7 @@ public:
int flags = 0,
int use_select = 1,
int reuse_addr = 1);
/**
* Open the contained @c PEER_ACCEPTOR object to begin listening, and
* register with the specified reactor for accept events. An
@@ -132,27 +144,37 @@ public:
int flags = 0,
int use_select = 1,
int reuse_addr = 1);
/// Close down the Acceptor's resources.
virtual ~ACE_Acceptor (void);
/// Return the underlying PEER_ACCEPTOR object.
virtual operator ACE_PEER_ACCEPTOR &() const;
/// Return the underlying PEER_ACCEPTOR object.
virtual ACE_PEER_ACCEPTOR &acceptor (void) const;
/// Returns the listening acceptor's {ACE_HANDLE}.
virtual ACE_HANDLE get_handle (void) const;
/// Close down the Acceptor
virtual int close (void);
/// In the event that an accept fails, this method will be called and
/// the return value will be returned from handle_input().
virtual int handle_accept_error (void);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
// = The following three methods define the Acceptor's strategies
// for creating, accepting, and activating SVC_HANDLER's,
// respectively.
/**
* Bridge method for creating a SVC_HANDLER. The default is to
* create a new {SVC_HANDLER} if {sh} == 0, else {sh} is unchanged.
@@ -162,12 +184,14 @@ protected:
* linking the handler, etc.). Returns -1 on failure, else 0.
*/
virtual int make_svc_handler (SVC_HANDLER *&sh);
/**
* Bridge method for accepting the new connection into the
* <svc_handler>. The default behavior delegates to the
* PEER_ACCEPTOR::accept.
*/
virtual int accept_svc_handler (SVC_HANDLER *svc_handler);
/**
* Bridge method for activating a {svc_handler} with the appropriate
* concurrency strategy. The default behavior of this method is to
@@ -179,33 +203,43 @@ protected:
* multi-processing).
*/
virtual int activate_svc_handler (SVC_HANDLER *svc_handler);
// = Demultiplexing hooks.
/// Perform termination activities when {this} is removed from the
/// {reactor}.
virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
/// Accepts all pending connections from clients, and creates and
/// activates SVC_HANDLERs.
virtual int handle_input (ACE_HANDLE);
// = Dynamic linking hooks.
/// Default version does no work and returns -1. Must be overloaded
/// by application developer to do anything meaningful.
virtual int init (int argc, ACE_TCHAR *argv[]);
/// Calls {handle_close}.
virtual int fini (void);
/// Default version returns address info in {buf}.
virtual int info (ACE_TCHAR **buf, size_t) const;
public:
// = Service management hooks.
/// This method calls {Reactor::suspend}.
virtual int suspend (void);
/// This method calls {Reactor::resume}.
virtual int resume (void);
protected:
/// Concrete factory for accepting connections from clients...
ACE_PEER_ACCEPTOR peer_acceptor_;
/// Needed to reopen the socket if {accept} fails.
ACE_PEER_ACCEPTOR_ADDR peer_acceptor_addr_;
/**
* Flags that indicate how {SVC_HANDLER}'s should be initialized
* prior to being activated. Right now, the only flag that is
@@ -213,12 +247,15 @@ protected:
* the {SVC_HANDLER} when it is opened.
*/
int flags_;
/// Flag that indicates whether it shall use {select} in the
/// {accept}-loop.
int use_select_;
/// Needed to reopen the socket if {accept} fails.
int reuse_addr_;
};
/**
* @class ACE_Strategy_Acceptor
*
@@ -238,6 +275,7 @@ class ACE_Strategy_Acceptor
: public ACE_Acceptor <SVC_HANDLER, ACE_PEER_ACCEPTOR_2>
{
public:
// Useful STL-style traits.
typedef ACE_Creation_Strategy<SVC_HANDLER>
creation_strategy_type;
@@ -248,17 +286,21 @@ public:
typedef ACE_Scheduling_Strategy<SVC_HANDLER> scheduling_strategy_type;
typedef ACE_Acceptor <SVC_HANDLER, ACE_PEER_ACCEPTOR_2>
base_type;
// = Define some useful (old style) traits.
typedef ACE_Creation_Strategy<SVC_HANDLER> CREATION_STRATEGY;
typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACCEPT_STRATEGY;
typedef ACE_Concurrency_Strategy<SVC_HANDLER> CONCURRENCY_STRATEGY;
typedef ACE_Scheduling_Strategy<SVC_HANDLER> SCHEDULING_STRATEGY;
/// Default constructor.
ACE_Strategy_Acceptor (const ACE_TCHAR service_name[] = 0,
const ACE_TCHAR service_description[] = 0,
int use_select = 1,
int reuse_addr = 1);
/**
* Initialize the appropriate strategies for creation, passive
* connection acceptance, and concurrency, and then register {this}
@@ -275,6 +317,7 @@ public:
const ACE_TCHAR service_description[] = 0,
int use_select = 1,
int reuse_addr = 1);
/**
* Open the contained @c PEER_ACCEPTOR object to begin listening, and
* register with the specified reactor for accept events.
@@ -314,6 +357,7 @@ public:
int flags = 0,
int use_select = 1,
int reuse_addr = 1);
/**
* Initialize the appropriate strategies for creation, passive
* connection acceptance, and concurrency, and then register {this}
@@ -330,33 +374,47 @@ public:
const ACE_TCHAR *service_description = 0,
int use_select = 1,
int reuse_addr = 1);
/// Close down the Strategy_Acceptor's resources.
virtual ~ACE_Strategy_Acceptor (void);
/// Return the underlying PEER_ACCEPTOR object.
virtual operator ACE_PEER_ACCEPTOR &() const;
/// Return the underlying PEER_ACCEPTOR object.
virtual ACE_PEER_ACCEPTOR &acceptor (void) const;
/// Returns the listening acceptor's {ACE_HANDLE}.
virtual ACE_HANDLE get_handle (void) const;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
// = Service management hooks.
/// This method delegates to the {Scheduling_Strategy}'s {suspend}
/// method.
virtual int suspend (void);
/// This method delegates to the {Scheduling_Strategy}'s {resume}
/// method.
virtual int resume (void);
protected:
/// Calls {handle_close} when dynamically unlinked.
virtual int fini (void);
/// Default version returns address info in {buf}.
virtual int info (ACE_TCHAR **buf, size_t) const;
// = The following three methods define the {Acceptor}'s strategies
// for creating, accepting, and activating {SVC_HANDLER}'s,
// respectively.
/**
* Bridge method for creating a {SVC_HANDLER}. The strategy for
* creating a {SVC_HANDLER} are configured into the Acceptor via
@@ -368,12 +426,14 @@ protected:
* linking the handler, etc.). Returns -1 on failure, else 0.
*/
virtual int make_svc_handler (SVC_HANDLER *&);
/**
* Bridge method for accepting the new connection into the
* {SVC_HANDLER}. The default behavior delegates to the
* {PEER_ACCEPTOR::accept} in the {Acceptor_Strategy}.
*/
virtual int accept_svc_handler (SVC_HANDLER *svc_handler);
/**
* Bridge method for activating a {SVC_HANDLER} with the appropriate
* concurrency strategy. The default behavior of this method is to
@@ -385,45 +445,62 @@ protected:
* multi-processing).
*/
virtual int activate_svc_handler (SVC_HANDLER *svc_handler);
// = Demultiplexing hooks.
/// Perform termination activities when {this} is removed from the
/// {Reactor}.
virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
/// Handle SIGINT.
virtual int handle_signal (int signum, siginfo_t *, ucontext_t *);
// = These data members are "logically private" but are put in the
// protected part in case subclasses want to access them.
// = Strategy objects.
/// Creation strategy for an Acceptor.
CREATION_STRATEGY *creation_strategy_;
/// true if {Acceptor} created the creation strategy and thus should
/// delete it, else false.
bool delete_creation_strategy_;
/// Accept strategy for an {Acceptor}.
ACCEPT_STRATEGY *accept_strategy_;
/// true if {Acceptor} created the accept strategy and thus should delete
/// it, else false.
bool delete_accept_strategy_;
/// Concurrency strategy for an {Acceptor}.
CONCURRENCY_STRATEGY *concurrency_strategy_;
/// true if {Acceptor} created the concurrency strategy and thus should
/// delete it, else false.
bool delete_concurrency_strategy_;
/// Scheduling strategy for an {Acceptor}.
SCHEDULING_STRATEGY *scheduling_strategy_;
/// true if {Acceptor} created the scheduling strategy and thus should
/// delete it, else false.
bool delete_scheduling_strategy_;
// = Service information objects.
/// Name of the service.
ACE_TCHAR *service_name_;
/// Description of the service.
ACE_TCHAR *service_description_;
/// Address that the {Strategy_Acceptor} uses to listen for
/// connections.
ACE_PEER_ACCEPTOR_ADDR service_addr_;
};
/**
* @class ACE_Oneshot_Acceptor
*
@@ -448,13 +525,16 @@ template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Oneshot_Acceptor : public ACE_Service_Object
{
public:
// Useful STL-style traits.
typedef ACE_PEER_ACCEPTOR_ADDR addr_type;
typedef ACE_PEER_ACCEPTOR acceptor_type;
typedef SVC_HANDLER handler_type;
typedef typename SVC_HANDLER::stream_type stream_type;
/// Constructor.
ACE_Oneshot_Acceptor (void);
/**
* Initialize the appropriate strategies for concurrency and then
* open the {peer_acceptor} at the designated {local_addr}. Note
@@ -466,6 +546,7 @@ public:
ACE_Oneshot_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
ACE_Reactor *reactor = ACE_Reactor::instance (),
ACE_Concurrency_Strategy<SVC_HANDLER> * = 0);
/**
* Initialize the appropriate strategies for concurrency and then
* open the {peer_acceptor} at the designated {local_addr}. Note
@@ -477,8 +558,10 @@ public:
int open (const ACE_PEER_ACCEPTOR_ADDR &,
ACE_Reactor *reactor = ACE_Reactor::instance (),
ACE_Concurrency_Strategy<SVC_HANDLER> * = 0);
/// Close down the {Oneshot_Acceptor}.
virtual ~ACE_Oneshot_Acceptor (void);
// = Explicit factory operation.
/// Create a {SVC_HANDLER}, accept the connection into the
/// {SVC_HANDLER}, and activate the {SVC_HANDLER}.
@@ -487,18 +570,25 @@ public:
const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults,
int restart = 1,
int reset_new_handle = 0);
/// Cancel a oneshot acceptor that was started asynchronously.
virtual int cancel (void);
/// Return the underlying {PEER_ACCEPTOR} object.
virtual operator ACE_PEER_ACCEPTOR &() const;
/// Return the underlying {PEER_ACCEPTOR} object.
virtual ACE_PEER_ACCEPTOR &acceptor (void) const;
/// Close down the {Oneshot_Acceptor}.
virtual int close (void);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
/**
* Bridge method for activating a {svc_handler} with the appropriate
@@ -509,6 +599,7 @@ protected:
* object" via multi-threading or multi-processing).
*/
virtual int activate_svc_handler (SVC_HANDLER *svc_handler);
/// Factors out the code shared between the {accept} and
/// {handle_input} methods.
int shared_accept (SVC_HANDLER *svc_handler,
@@ -516,35 +607,45 @@ protected:
ACE_Time_Value *timeout,
int restart,
int reset_new_handle);
// = Demultiplexing hooks.
/// Returns the listening acceptor's {ACE_HANDLE}.
virtual ACE_HANDLE get_handle (void) const;
/// Perform termination activities when {this} is removed from the
/// {reactor}.
virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
/// Accept one connection from a client and activates the
/// SVC_HANDLER.
virtual int handle_input (ACE_HANDLE);
/// Called when an acceptor times out...
virtual int handle_timeout (const ACE_Time_Value &tv,
const void *arg);
// = Dynamic linking hooks.
/// Default version does no work and returns -1. Must be overloaded
/// by application developer to do anything meaningful.
virtual int init (int argc, ACE_TCHAR *argv[]);
/// Default version does no work and returns -1. Must be overloaded
/// by application developer to do anything meaningful.
virtual int fini (void);
/// Default version returns address info in {buf}.
virtual int info (ACE_TCHAR **, size_t) const;
// = Service management hooks.
/// Default version does no work and returns -1. Must be overloaded
/// by application developer to do anything meaningful.
virtual int suspend (void);
/// Default version does no work and returns -1. Must be overloaded
/// by application developer to do anything meaningful.
virtual int resume (void);
private:
/**
* Insert ourselves into the {ACE_Reactor} so that we can continue
@@ -554,25 +655,35 @@ private:
int register_handler (SVC_HANDLER *svc_handler,
const ACE_Synch_Options &options,
int restart);
/// Hold the svc_handler_ across asynchrony boundaries.
SVC_HANDLER *svc_handler_;
/// Hold the restart flag across asynchrony boundaries.
int restart_;
/// Factory that establishes connections passively.
ACE_PEER_ACCEPTOR peer_acceptor_;
/// Concurrency strategy for an Acceptor.
ACE_Concurrency_Strategy<SVC_HANDLER> *concurrency_strategy_;
/// true if Acceptor created the concurrency strategy and thus should
/// delete it, else false.
bool delete_concurrency_strategy_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Acceptor.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Acceptor.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_ACCEPTOR_H */
+20
View File
@@ -1,15 +1,20 @@
#include "ace/Activation_Queue.h"
#if !defined (__ACE_INLINE__)
#include "ace/Activation_Queue.inl"
#endif /* __ACE_INLINE__ */
#include "ace/Log_Msg.h"
#include "ace/Method_Request.h"
#include "ace/Malloc_Base.h"
#include "ace/Time_Value.h"
ACE_RCSID (ace,
Activation_Queue,
"$Id: Activation_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
ACE_Activation_Queue::dump (void) const
{
@@ -25,9 +30,11 @@ ACE_Activation_Queue::dump (void) const
//FUZZ: disable check_for_NULL
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(NULL)\n")));
//FUZZ: enable check_for_NULL
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue<ACE_SYNCH> *new_queue,
ACE_Allocator *alloc,
ACE_Allocator *db_alloc)
@@ -37,6 +44,7 @@ ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue<ACE_SYNCH> *new_qu
{
if (this->allocator_ == 0)
this->allocator_ = ACE_Allocator::instance ();
if (new_queue)
this->queue_ = new_queue;
else
@@ -46,6 +54,7 @@ ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue<ACE_SYNCH> *new_qu
this->delete_queue_ = true;
}
}
void
ACE_Activation_Queue::queue (ACE_Message_Queue<ACE_SYNCH> *q)
{
@@ -54,6 +63,7 @@ ACE_Activation_Queue::queue (ACE_Message_Queue<ACE_SYNCH> *q)
{
// Destroy the current queue.
delete this->queue_;
// Set the flag to false. NOTE that the delete_queue_ flag is a
// flag used to only indicate whether or not if an internal
// ACE_Message_Queue has been created, therefore, it will not
@@ -62,17 +72,21 @@ ACE_Activation_Queue::queue (ACE_Message_Queue<ACE_SYNCH> *q)
// function.
this->delete_queue_ = false;
}
queue_ = q;
}
ACE_Activation_Queue::~ACE_Activation_Queue (void)
{
if (this->delete_queue_)
delete this->queue_;
}
ACE_Method_Request *
ACE_Activation_Queue::dequeue (ACE_Time_Value *tv)
{
ACE_Message_Block *mb = 0;
// Dequeue the message.
if (this->queue_->dequeue_head (mb, tv) != -1)
{
@@ -86,11 +100,13 @@ ACE_Activation_Queue::dequeue (ACE_Time_Value *tv)
else
return 0;
}
int
ACE_Activation_Queue::enqueue (ACE_Method_Request *mr,
ACE_Time_Value *tv)
{
ACE_Message_Block *mb = 0;
// We pass sizeof (*mr) here so that flow control will work
// correctly. Since we also pass <mr> note that no unnecessary
// memory is actually allocated -- just the size field is set.
@@ -108,12 +124,16 @@ ACE_Activation_Queue::enqueue (ACE_Method_Request *mr,
this->data_block_allocator_, // data_block allocator
this->allocator_), // message_block allocator
-1);
// Enqueue in priority order.
int const result = this->queue_->enqueue_prio (mb, tv);
// Free ACE_Message_Block if enqueue_prio failed.
if (result == -1)
ACE_DES_FREE (mb, this->allocator_->free, ACE_Message_Block);
return result;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+33
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Activation_Queue.h
@@ -9,19 +10,28 @@
* @author Douglas C. Schmidt <[email protected]>
*/
//=============================================================================
#ifndef ACE_ACTIVATION_QUEUE_H
#define ACE_ACTIVATION_QUEUE_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Message_Queue.h"
#include "ace/Condition_Thread_Mutex.h"
/// Define to be compatible with the terminology in the POSA2 book!
#define ACE_Activation_List ACE_Activation_Queue
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Method_Request;
/**
* @class ACE_Activation_Queue
*
@@ -66,9 +76,12 @@ public:
ACE_Activation_Queue (ACE_Message_Queue<ACE_SYNCH> *new_queue = 0,
ACE_Allocator *alloc = 0,
ACE_Allocator *db_alloc = 0);
/// Destructor.
virtual ~ACE_Activation_Queue (void);
// = Activate Queue operations.
/// Dequeue the next available ACE_Method_Request.
/**
* @param tv If 0, the method will block until a method request is
@@ -82,6 +95,7 @@ public:
* the specified timeout elapses, errno will be @c EWOULDBLOCK.
*/
ACE_Method_Request *dequeue (ACE_Time_Value *tv = 0);
/// Enqueue the ACE_Method_Request in priority order.
/**
* The priority of the method request is obtained via the @c priority()
@@ -103,39 +117,58 @@ public:
* the specified timeout elapses, errno will be @c EWOULDBLOCK.
*/
int enqueue (ACE_Method_Request *new_method_request, ACE_Time_Value *tv = 0);
/// Get the current number of method objects in the queue.
size_t method_count (void) const;
/// Returns 1 if the queue is empty, 0 otherwise.
int is_empty (void) const;
/// Returns 1 if the queue is full, 0 otherwise.
int is_full (void) const;
/// Dump the state of an request.
void dump (void) const;
/// Get a pointer to the underlying queue.
ACE_Message_Queue<ACE_SYNCH> *queue (void) const;
/// Set the pointer to the underlying queue.
void queue (ACE_Message_Queue<ACE_SYNCH> *q);
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
// = Prevent copying and assignment.
ACE_Activation_Queue (const ACE_Activation_Queue &);
void operator= (const ACE_Activation_Queue &);
protected:
/// Stores the Method_Requests.
ACE_Message_Queue<ACE_SYNCH> *queue_;
/// Keeps track of whether we need to delete the queue.
bool delete_queue_;
private:
/// Allocation strategy of the queue.
ACE_Allocator *allocator_;
/// Allocation strategy of the message blocks.
ACE_Allocator *data_block_allocator_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Activation_Queue.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_ACTIVATION_QUEUE_H */
@@ -1,25 +1,31 @@
// -*- C++ -*-
//
// $Id: Activation_Queue.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE size_t
ACE_Activation_Queue::method_count (void) const
{
return queue_->message_count ();
}
ACE_INLINE int
ACE_Activation_Queue::is_full (void) const
{
return queue_->is_full ();
}
ACE_INLINE int
ACE_Activation_Queue::is_empty (void) const
{
return queue_->is_empty ();
}
ACE_INLINE ACE_Message_Queue<ACE_SYNCH> *
ACE_Activation_Queue::queue (void) const
{
return queue_;
}
ACE_END_VERSIONED_NAMESPACE_DECL
@@ -1,6 +1,9 @@
// $Id: Active_Map_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Active_Map_Manager.h"
ACE_RCSID(ace, Active_Map_Manager, "$Id: Active_Map_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if !defined (__ACE_INLINE__)
#include "ace/Active_Map_Manager.inl"
#endif /* __ACE_INLINE__ */
+26
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file Active_Map_Manager.h
@@ -9,15 +10,21 @@
*/
//=============================================================================
#ifndef ACE_ACTIVE_MAP_MANAGER_H
#define ACE_ACTIVE_MAP_MANAGER_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Basic_Types.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Active_Map_Manager_Key
*
@@ -32,6 +39,7 @@ class ACE_Export ACE_Active_Map_Manager_Key
public:
/// Default constructor.
ACE_Active_Map_Manager_Key (void);
/**
* Constructor given the @a slot_index and @a slot_generation number.
* This is useful once the user has somehow recovered the
@@ -39,30 +47,42 @@ public:
*/
ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index,
ACE_UINT32 slot_generation);
/// Get the slot_index.
ACE_UINT32 slot_index (void) const;
/// Set the slot_index.
void slot_index (ACE_UINT32 i);
/// Get the slot_generation number.
ACE_UINT32 slot_generation (void) const;
/// Set the slot_generation number.
void slot_generation (ACE_UINT32 g);
/// Size required to store information about active key.
static size_t size (void);
/// Recover state of active key from @a data. User must make sure
/// that @a data encoded using the encode() method.
void decode (const void *data);
/// Encode state of the active key into @a data. @a data must be as
/// big as the value returned from <size>.
void encode (void *data) const;
/// Compare keys.
bool operator== (const ACE_Active_Map_Manager_Key &rhs) const;
bool operator!= (const ACE_Active_Map_Manager_Key &rhs) const;
// = This really should be protected but because of template
// friends, they are not.
/// Increment the <slot_generation> number.
void increment_slot_generation_count (void);
private:
/**
* @brief Data for the Active Object Map Key.
*
@@ -74,18 +94,24 @@ private:
{
/// Slot index in the active map.
ACE_UINT32 slot_index_;
/// Slot generation number of <slot_index_> slot in the active map.
ACE_UINT32 slot_generation_;
};
/// Data for the Active Object Map Key.
key_data key_data_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Active_Map_Manager.inl"
#endif /* __ACE_INLINE__ */
// Include the templates here.
#include "ace/Active_Map_Manager_T.h"
#include /**/ "ace/post.h"
#endif /* ACE_ACTIVE_MAP_MANAGER_H */
@@ -1,8 +1,11 @@
// -*- C++ -*-
//
// $Id: Active_Map_Manager.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/OS_NS_string.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (void)
{
@@ -11,6 +14,7 @@ ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (void)
this->key_data_.slot_index_ = (ACE_UINT32) ~0;
this->key_data_.slot_generation_ = 0;
}
ACE_INLINE
ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index,
ACE_UINT32 slot_generation)
@@ -18,16 +22,19 @@ ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index,
this->key_data_.slot_index_ = slot_index;
this->key_data_.slot_generation_ = slot_generation;
}
ACE_INLINE ACE_UINT32
ACE_Active_Map_Manager_Key::slot_index (void) const
{
return this->key_data_.slot_index_;
}
ACE_INLINE ACE_UINT32
ACE_Active_Map_Manager_Key::slot_generation (void) const
{
return this->key_data_.slot_generation_;
}
ACE_INLINE bool
ACE_Active_Map_Manager_Key::operator== (const ACE_Active_Map_Manager_Key &rhs) const
{
@@ -35,32 +42,38 @@ ACE_Active_Map_Manager_Key::operator== (const ACE_Active_Map_Manager_Key &rhs) c
this->key_data_.slot_index_ == rhs.key_data_.slot_index_ &&
this->key_data_.slot_generation_ == rhs.key_data_.slot_generation_;
}
ACE_INLINE bool
ACE_Active_Map_Manager_Key::operator!= (const ACE_Active_Map_Manager_Key &rhs) const
{
return !this->operator== (rhs);
}
ACE_INLINE void
ACE_Active_Map_Manager_Key::slot_index (ACE_UINT32 i)
{
this->key_data_.slot_index_ = i;
}
ACE_INLINE void
ACE_Active_Map_Manager_Key::slot_generation (ACE_UINT32 g)
{
this->key_data_.slot_generation_ = g;
}
ACE_INLINE void
ACE_Active_Map_Manager_Key::increment_slot_generation_count (void)
{
++this->key_data_.slot_generation_;
}
/* static */
ACE_INLINE size_t
ACE_Active_Map_Manager_Key::size (void)
{
return sizeof (ACE_UINT32) + sizeof (ACE_UINT32);
}
ACE_INLINE void
ACE_Active_Map_Manager_Key::decode (const void *data)
{
@@ -69,6 +82,7 @@ ACE_Active_Map_Manager_Key::decode (const void *data)
data,
sizeof this->key_data_);
}
ACE_INLINE void
ACE_Active_Map_Manager_Key::encode (void *data) const
{
@@ -77,4 +91,5 @@ ACE_Active_Map_Manager_Key::encode (void *data) const
&this->key_data_,
sizeof this->key_data_);
}
ACE_END_VERSIONED_NAMESPACE_DECL
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file Active_Map_Manager_T.h
@@ -9,16 +10,22 @@
*/
//=============================================================================
#ifndef ACE_ACTIVE_MAP_MANAGER_T_H
#define ACE_ACTIVE_MAP_MANAGER_T_H
#include /**/ "ace/pre.h"
#include "ace/Map_Manager.h"
#include "ace/Active_Map_Manager.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Null_Mutex.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Active_Map_Manager
*
@@ -32,37 +39,48 @@ template <class T>
class ACE_Active_Map_Manager : public ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
{
public:
// = Traits.
typedef ACE_Active_Map_Manager_Key key_type;
typedef T mapped_type;
typedef ACE_Map_Entry<ACE_Active_Map_Manager_Key, T> ENTRY;
typedef ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ITERATOR;
typedef ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> REVERSE_ITERATOR;
typedef ENTRY entry;
typedef ITERATOR iterator;
typedef REVERSE_ITERATOR reverse_iterator;
// = Initialization and termination methods.
/// Initialize a <Active_Map_Manager> with the ACE_DEFAULT_MAP_SIZE.
ACE_Active_Map_Manager (ACE_Allocator *alloc = 0);
/// Initialize a <Active_Map_Manager> with @a size entries.
ACE_Active_Map_Manager (size_t size,
ACE_Allocator *alloc = 0);
/// Close down a <Active_Map_Manager> and release dynamically
/// allocated resources.
~ACE_Active_Map_Manager (void);
/// Initialize a <Active_Map_Manager> with size @a length.
int open (size_t length = ACE_DEFAULT_MAP_SIZE,
ACE_Allocator *alloc = 0);
/// Close down a <Active_Map_Manager> and release dynamically
/// allocated resources.
int close (void);
/// Add @a value to the map, and the corresponding key produced by the
/// Active_Map_Manager is returned through @a key.
int bind (const T &value,
ACE_Active_Map_Manager_Key &key);
/// Add @a value to the map. The user does not care about the
/// corresponding key produced by the Active_Map_Manager.
int bind (const T &value);
/**
* Reserves a slot in the internal structure and returns the key and
* a pointer to the value. User should place their @a value into
@@ -74,10 +92,12 @@ public:
*/
int bind (ACE_Active_Map_Manager_Key &key,
T *&internal_value);
/// Reassociate @a key with @a value. The function fails if @a key is
/// not in the map.
int rebind (const ACE_Active_Map_Manager_Key &key,
const T &value);
/**
* Reassociate @a key with @a value, storing the old value into the
* "out" parameter @a old_value. The function fails if @a key is not
@@ -86,6 +106,7 @@ public:
int rebind (const ACE_Active_Map_Manager_Key &key,
const T &value,
T &old_value);
/**
* Reassociate @a key with @a value, storing the old key and value
* into the "out" parameter @a old_key and @a old_value. The function
@@ -95,11 +116,14 @@ public:
const T &value,
ACE_Active_Map_Manager_Key &old_key,
T &old_value);
/// Locate @a value associated with @a key.
int find (const ACE_Active_Map_Manager_Key &key,
T &value) const;
/// Is @a key in the map?
int find (const ACE_Active_Map_Manager_Key &key) const;
/**
* Locate @a value associated with @a key. The value is returned via
* <internal_value> and hence a copy is saved. Note that
@@ -109,15 +133,19 @@ public:
*/
int find (const ACE_Active_Map_Manager_Key &key,
T *&internal_value) const;
// Creates a key. User should place their @a value into
// <*internal_value>. This method is useful in reducing the number
// of copies required in some cases.
/// Remove @a key from the map.
int unbind (const ACE_Active_Map_Manager_Key &key);
/// Remove @a key from the map, and return the @a value associated with
/// @a key.
int unbind (const ACE_Active_Map_Manager_Key &key,
T &value);
/**
* Locate @a value associated with @a key. The value is returned via
* <internal_value> and hence a copy is saved. Note that
@@ -127,41 +155,58 @@ public:
*/
int unbind (const ACE_Active_Map_Manager_Key &key,
T *&internal_value);
/// Return the current size of the map.
size_t current_size (void) const;
/// Return the total size of the map.
size_t total_size (void) const;
/// Returns a key that cannot be found in the map.
static const ACE_Active_Map_Manager_Key npos (void);
/// Dump the state of an object.
void dump (void) const;
// = STL styled iterator factory functions.
/// Return forward iterator.
ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> begin (void);
ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> end (void);
/// Return reverse iterator.
ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> rbegin (void);
ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> rend (void);
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
/// Private base class
typedef ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_AMM_BASE;
private:
// = Disallow these operations.
ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Active_Map_Manager<T> &))
ACE_UNIMPLEMENTED_FUNC (ACE_Active_Map_Manager (const ACE_Active_Map_Manager<T> &))
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Active_Map_Manager_T.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Active_Map_Manager_T.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Active_Map_Manager_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_ACTIVE_MAP_MANAGER_T_H */
@@ -1,29 +1,38 @@
// -*- C++ -*-
//
// $Id: Active_Map_Manager_T.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::bind (ACE_Active_Map_Manager_Key &key,
T *&internal_value)
{
ACE_UINT32 slot_index;
int result = this->next_free (slot_index);
if (result == 0)
{
// Move from free list to occupied list
this->move_from_free_list_to_occupied_list (slot_index);
// Reset the key.
this->search_structure_[slot_index].ext_id_.increment_slot_generation_count ();
this->search_structure_[slot_index].ext_id_.slot_index (slot_index);
// Copy the key for the user.
key = this->search_structure_[slot_index].ext_id_;
// This is where the user should place the value.
internal_value = &this->search_structure_[slot_index].int_id_;
// Update the current size.
++this->cur_size_;
}
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::bind (const T &value,
ACE_Active_Map_Manager_Key &key)
@@ -31,25 +40,30 @@ ACE_Active_Map_Manager<T>::bind (const T &value,
T *internal_value = 0;
int result = this->bind (key,
internal_value);
if (result == 0)
{
// Store new value.
*internal_value = value;
}
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::bind (const T &value)
{
ACE_Active_Map_Manager_Key key;
return this->bind (value, key);
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key,
T *&internal_value) const
{
ACE_UINT32 slot_index = key.slot_index ();
ACE_UINT32 slot_generation = key.slot_generation ();
if (slot_index > this->total_size_ ||
#if defined (ACE_HAS_LAZY_MAP_MANAGER)
this->search_structure_[slot_index].free_ ||
@@ -65,8 +79,10 @@ ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key,
// This is where the user value is.
internal_value = &this->search_structure_[slot_index].int_id_;
}
return 0;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key) const
{
@@ -74,6 +90,7 @@ ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key) const
return this->find (key,
internal_value);
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key,
T &value) const
@@ -81,37 +98,47 @@ ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key,
T *internal_value = 0;
int result = this->find (key,
internal_value);
if (result == 0)
value = *internal_value;
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::rebind (const ACE_Active_Map_Manager_Key &key,
const T &value)
{
int result = this->find (key);
if (result == 0)
{
// Store new value.
this->search_structure_[key.slot_index ()].int_id_ = value;
}
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::rebind (const ACE_Active_Map_Manager_Key &key,
const T &value,
T &old_value)
{
int result = this->find (key);
if (result == 0)
{
// Copy old value.
old_value = this->search_structure_[key.slot_index ()].int_id_;
// Store new value.
this->search_structure_[key.slot_index ()].int_id_ = value;
}
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::rebind (const ACE_Active_Map_Manager_Key &key,
const T &value,
@@ -119,44 +146,60 @@ ACE_Active_Map_Manager<T>::rebind (const ACE_Active_Map_Manager_Key &key,
T &old_value)
{
int result = this->find (key);
if (result == 0)
{
// Copy old key.
old_key = this->search_structure_[key.slot_index ()].ext_id_;
// Copy old value.
old_value = this->search_structure_[key.slot_index ()].int_id_;
// Store new value.
this->search_structure_[key.slot_index ()].int_id_ = value;
}
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key,
T *&internal_value)
{
int result = this->find (key,
internal_value);
if (result == 0)
{
ACE_UINT32 slot_index = key.slot_index ();
#if defined (ACE_HAS_LAZY_MAP_MANAGER)
//
// In the case of lazy map managers, the movement of free slots
// from the occupied list to the free list is delayed until we
// run out of free slots in the free list.
//
this->search_structure_[slot_index].free_ = 1;
#else
// Move from occupied list to free list.
this->move_from_occupied_list_to_free_list (slot_index);
#endif /* ACE_HAS_LAZY_MAP_MANAGER */
// Reset the slot_index. This will tell us that this entry is free.
this->search_structure_[slot_index].ext_id_.slot_index (this->free_list_id ());
// Update the current size.
--this->cur_size_;
}
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key,
T &value)
@@ -164,13 +207,16 @@ ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key,
T *internal_value;
int result = this->unbind (key,
internal_value);
if (result == 0)
{
// Copy old value.
value = *internal_value;
}
return result;
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key)
{
@@ -178,11 +224,13 @@ ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key)
return this->unbind (key,
internal_value);
}
template <class T> ACE_INLINE
ACE_Active_Map_Manager<T>::ACE_Active_Map_Manager (ACE_Allocator *alloc)
: ACE_AMM_BASE (alloc)
{
}
template <class T> ACE_INLINE
ACE_Active_Map_Manager<T>::ACE_Active_Map_Manager (size_t size,
ACE_Allocator *alloc)
@@ -190,37 +238,44 @@ ACE_Active_Map_Manager<T>::ACE_Active_Map_Manager (size_t size,
alloc)
{
}
template <class T> ACE_INLINE
ACE_Active_Map_Manager<T>::~ACE_Active_Map_Manager (void)
{
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::open (size_t length,
ACE_Allocator *alloc)
{
return ACE_AMM_BASE::open (length, alloc);
}
template <class T> ACE_INLINE int
ACE_Active_Map_Manager<T>::close (void)
{
return ACE_AMM_BASE::close ();
}
template <class T> ACE_INLINE size_t
ACE_Active_Map_Manager<T>::current_size (void) const
{
return ACE_AMM_BASE::current_size ();
}
template <class T> ACE_INLINE size_t
ACE_Active_Map_Manager<T>::total_size (void) const
{
return ACE_AMM_BASE::total_size ();
}
/* static */
template <class T> ACE_INLINE const ACE_Active_Map_Manager_Key
ACE_Active_Map_Manager<T>::npos (void)
{
return ACE_Active_Map_Manager_Key (~0, ~0);
}
template <class T> ACE_INLINE void
ACE_Active_Map_Manager<T>::dump (void) const
{
@@ -228,24 +283,29 @@ ACE_Active_Map_Manager<T>::dump (void) const
ACE_AMM_BASE::dump ();
#endif /* ACE_HAS_DUMP */
}
template <class T> ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
ACE_Active_Map_Manager<T>::begin (void)
{
return ACE_AMM_BASE::begin ();
}
template <class T> ACE_INLINE ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
ACE_Active_Map_Manager<T>::end (void)
{
return ACE_AMM_BASE::end ();
}
template <class T> ACE_INLINE ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
ACE_Active_Map_Manager<T>::rbegin (void)
{
return ACE_AMM_BASE::rbegin ();
}
template <class T> ACE_INLINE ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
ACE_Active_Map_Manager<T>::rend (void)
{
return ACE_AMM_BASE::rend ();
}
ACE_END_VERSIONED_NAMESPACE_DECL
+17
View File
@@ -1,57 +1,74 @@
// $Id: Addr.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Addr.h"
ACE_RCSID (ace,
Addr,
"$Id: Addr.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if !defined (__ACE_INLINE__)
#include "ace/Addr.inl"
#endif /* __ACE_INLINE__ */
#include "ace/Log_Msg.h"
#include "ace/os_include/sys/os_socket.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Note: this object requires static construction and destruction.
/* static */
const ACE_Addr ACE_Addr::sap_any (AF_ANY, -1);
ACE_ALLOC_HOOK_DEFINE(ACE_Addr)
// Initializes instance variables. Note that 0 is an unspecified
// protocol family type...
ACE_Addr::ACE_Addr (int type, int size) :
addr_type_ (type),
addr_size_ (size)
{
}
ACE_Addr::~ACE_Addr (void)
{
}
void *
ACE_Addr::get_addr (void) const
{
return 0;
}
void
ACE_Addr::set_addr (void *, int)
{
}
// Initializes instance variables.
void
ACE_Addr::base_set (int type, int size)
{
this->addr_type_ = type;
this->addr_size_ = size;
}
void
ACE_Addr::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Addr::dump");
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("addr_type_ = %d"), this->addr_type_));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\naddr_size_ = %d"), this->addr_size_));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
ACE_END_VERSIONED_NAMESPACE_DECL
+29
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Addr.h
@@ -8,14 +9,20 @@
* @author Douglas C. Schmidt <[email protected]>
*/
//=============================================================================
#ifndef ACE_ADDR_H
#define ACE_ADDR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Addr
*
@@ -28,48 +35,70 @@ public:
// = Initialization and termination methods.
/// Initializes instance variables.
ACE_Addr (int type = -1, int size = -1);
/// Destructor.
virtual ~ACE_Addr (void);
// = Get/set the size of the address.
/// Return the size of the address.
int get_size (void) const;
/// Sets the size of the address.
void set_size (int size);
// = Get/set the type of the address.
/// Get the type of the address.
int get_type (void) const;
/// Set the type of the address.
void set_type (int type);
/// Return a pointer to the address.
virtual void *get_addr (void) const;
/// Set a pointer to the address.
virtual void set_addr (void *, int len);
// = Equality/inequality tests
/// Check for address equality.
bool operator == (const ACE_Addr &sap) const;
/// Check for address inequality.
bool operator != (const ACE_Addr &sap) const;
/// Initializes instance variables.
void base_set (int type, int size);
/// Wild-card address.
static const ACE_Addr sap_any;
/// Returns a hash value. This should be overwritten by a subclass
/// that can produce a better hash value.
virtual unsigned long hash (void) const;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
/// e.g., AF_UNIX, AF_INET, AF_SPIPE, etc.
int addr_type_;
/// Number of bytes in the address.
int addr_size_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Addr.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_ADDR_H */
+14
View File
@@ -1,47 +1,61 @@
// -*- C++ -*-
//
// $Id: Addr.inl 80826 2008-03-04 14:51:23Z wotte $
// Return the address of the address.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE bool
ACE_Addr::operator == (const ACE_Addr &sap) const
{
return (sap.addr_type_ == this->addr_type_ &&
sap.addr_size_ == this->addr_size_ );
}
ACE_INLINE bool
ACE_Addr::operator != (const ACE_Addr &sap) const
{
return (sap.addr_type_ != this->addr_type_ ||
sap.addr_size_ != this->addr_size_ );
}
// Return the size of the address.
ACE_INLINE int
ACE_Addr::get_size (void) const
{
return this->addr_size_;
}
// Sets the size of the address.
ACE_INLINE void
ACE_Addr::set_size (int size)
{
this->addr_size_ = size;
}
// Return the type of the address.
ACE_INLINE int
ACE_Addr::get_type (void) const
{
return this->addr_type_;
}
// Set the type of the address.
ACE_INLINE void
ACE_Addr::set_type (int type)
{
this->addr_type_ = type;
}
ACE_INLINE unsigned long
ACE_Addr::hash (void) const
{
return 0;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+35
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Arg_Shifter.h
@@ -8,15 +9,22 @@
* @author Seth Widoff
*/
//=============================================================================
#ifndef ACE_ARG_SHIFTER_H
#define ACE_ARG_SHIFTER_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Global_Macros.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Arg_Shifter_T
*
@@ -62,15 +70,19 @@ public:
ACE_Arg_Shifter_T (int& argc,
const CHAR_TYPE **argv,
const CHAR_TYPE **temp = 0);
/// Same behavior as the preceding constructor, but without the
/// "const" qualifier.
ACE_Arg_Shifter_T (int& argc,
CHAR_TYPE **argv,
CHAR_TYPE **temp = 0);
/// Destructor.
~ACE_Arg_Shifter_T (void);
/// Get the current head of the vector.
const CHAR_TYPE *get_current (void) const;
/**
* If the @a flag matches the current_arg of arg shifter
* this method will attempt to return the associated
@@ -104,6 +116,7 @@ public:
* and the cur arg is left pointing to the entire flag/value pair
*/
const CHAR_TYPE *get_the_parameter (const CHAR_TYPE* flag);
/**
* Check if the current argument matches (case insensitive) <flag>
*
@@ -134,54 +147,76 @@ public:
* then -1 is returned
*/
int cur_arg_strncasecmp (const CHAR_TYPE *flag);
/// Consume @a number argument(s) by sticking them/it on the end of
/// the vector.
int consume_arg (int number = 1);
/// Place @a number arguments in the same relative order ahead of the
/// known arguments in the vector.
int ignore_arg (int number = 1);
/// Returns the number of args left to see in the vector.
int is_anything_left (void) const;
/// Returns 1 if there's a next item in the vector and it begins with
/// '-'.
int is_option_next (void) const;
/// Returns 1 if there's a next item in the vector and it doesn't
/// begin with '-'.
int is_parameter_next (void) const;
/// Returns the number of irrelevant args seen.
int num_ignored_args (void) const;
private:
/// Copy Constructor should not be used.
ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T (const ACE_Arg_Shifter_T<CHAR_TYPE>&))
/// Assignment '=' operator should not be used.
ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T operator= (const ACE_Arg_Shifter_T<CHAR_TYPE>&))
/// Refactor the constructor logic.
void init (void);
/// The size of the argument vector.
int& argc_;
/// The size of argv_.
int total_size_;
/// The temporary array over which we traverse.
const CHAR_TYPE **temp_;
/// The array in which the arguments are reordered.
const CHAR_TYPE **argv_;
/// The element in <temp_> we're currently examining.
int current_index_;
/// The index of <argv_> in which we'll stick the next unknown
/// argument.
int back_;
/// The index of <argv_> in which we'll stick the next known
/// argument.
int front_;
};
typedef ACE_Arg_Shifter_T<ACE_TCHAR> ACE_Arg_Shifter;
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Arg_Shifter.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Arg_Shifter.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_ARG_SHIFTER_H */
@@ -1,14 +1,20 @@
// $Id: Argv_Type_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Argv_Type_Converter.h"
#if !defined (__ACE_INLINE__)
#include "ace/Argv_Type_Converter.inl"
#endif /* __ACE_INLINE__ */
ACE_RCSID (ace,
Argv_Type_Converter,
"$Id: Argv_Type_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $")
#include "ace/OS_NS_string.h"
#include "ace/OS_Errno.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (ACE_USES_WCHAR)
ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, wchar_t** argv)
: saved_argc_ (argc),
@@ -20,11 +26,13 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, wchar_t** argv)
char_passed_ (false)
{
this->initialize ();
for (int i = 0; i < argc; ++i)
this->char_argv_[i] = ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR (argv[i]));
}
#endif // ACE_USES_WCHAR
ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv)
: saved_argc_(argc),
char_argv_(argv)
@@ -36,6 +44,7 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv)
char_passed_(false)
{
this->initialize();
for (int i = 0; i < argc; ++i)
this->wchar_argv_[i] = ACE_OS::strdup (ACE_TEXT_ANTI_TO_TCHAR (argv[i]));
}
@@ -43,6 +52,7 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv)
{
}
#endif // ACE_USES_WCHAR
ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void)
{
#if defined (ACE_USES_WCHAR)
@@ -52,8 +62,10 @@ ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void)
// if original type is wchar_t
if (this->char_passed_)
this->align_wchar_with_char ();
for (int i = 0; i < this->before_pass_argc_; ++i)
ACE_OS::free (this->char_argv_[i]);
delete [] this->char_argv_;
}
else
@@ -61,12 +73,15 @@ ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void)
// if original type is char
if (this->wchar_passed_)
this->align_char_with_wchar ();
for (int i = 0; i < this->before_pass_argc_; ++i)
ACE_OS::free (this->wchar_argv_[i]);
delete [] this->wchar_argv_;
}
#endif // ACE_USES_WCHAR
}
#if defined (ACE_USES_WCHAR)
void
ACE_Argv_Type_Converter::initialize (void)
@@ -89,11 +104,13 @@ ACE_Argv_Type_Converter::initialize (void)
}
}
void
ACE_Argv_Type_Converter::align_char_with_wchar (void)
{
int wchar_argv_index = 0;
wchar_t* match_argv = this->wchar_argv_[0]; // pick the initial entry
while (wchar_argv_index < this->saved_argc_)
{
// if n'th entries of both argv lists are different
@@ -115,16 +132,20 @@ ACE_Argv_Type_Converter::align_char_with_wchar (void)
}
}
}
// move to the next wchar argv list entry
match_argv = this->wchar_argv_[++wchar_argv_index];
}
this->cleanup ();
}
void
ACE_Argv_Type_Converter::align_wchar_with_char (void)
{
int char_argv_index = 0;
char* match_argv = this->char_argv_[0]; // pick the initial entry
while (char_argv_index < saved_argc_)
{
// if n'th entries of both argv lists are different
@@ -147,11 +168,14 @@ ACE_Argv_Type_Converter::align_wchar_with_char (void)
}
}
}
// move to the next wchar argv list entry
match_argv = this->char_argv_[++char_argv_index];
}
this->cleanup();
}
void
ACE_Argv_Type_Converter::cleanup (void)
{
@@ -169,10 +193,13 @@ ACE_Argv_Type_Converter::cleanup (void)
this->wchar_argv_[i] = 0;
}
}
this->before_pass_argc_ = this->saved_argc_;
this->wchar_passed_ = false;
this->char_passed_ = false;
}
#endif // ACE_USES_WCHAR
ACE_END_VERSIONED_NAMESPACE_DECL
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Argv_Type_Converter.h
@@ -8,15 +9,21 @@
* @author Si Mong Park <[email protected]>
*/
//=============================================================================
#ifndef ACE_ARGV_TYPE_CONVERTER_H
#define ACE_ARGV_TYPE_CONVERTER_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#include "ace/OS_Memory.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Argv_Type_Converter
*
@@ -32,57 +39,82 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Export ACE_Argv_Type_Converter
{
public:
ACE_Argv_Type_Converter (int &argc, char** argv);
#if defined (ACE_USES_WCHAR)
ACE_Argv_Type_Converter (int &argc, wchar_t** argv);
#endif // ACE_USES_WCHAR
~ACE_Argv_Type_Converter (void);
/// Returns the pointer of converted command line.
ACE_TCHAR** get_TCHAR_argv (void);
/// Returns the pointer of ASCII (char) command line.
char** get_ASCII_argv (void);
/// Returns the number of sub paramters (argc).
int& get_argc (void);
private:
/// Copy Constructor should not be used.
ACE_Argv_Type_Converter (const ACE_Argv_Type_Converter&);
/// Assignment '=' operator should not be used.
ACE_Argv_Type_Converter operator= (const ACE_Argv_Type_Converter&);
#if defined (ACE_USES_WCHAR)
/// Perform common initialization for two Ctor's.
void initialize (void);
/// Align all entries in the char type argv list with wchar_t type
/// argv list.
void align_char_with_wchar (void);
/// Align all entries in the wchar_t type argv list with char type
/// argv list.
void align_wchar_with_char (void);
/// Clean up removed (comsumed) argv entries and reset the pass flags.
void cleanup (void);
#endif // ACE_USES_WCHAR
private:
/// Original number of input paramter, same as 'argc'.
int &saved_argc_;
/// Data member pointer that contains converted argv in ACE_ANTI_TCHAR.
char** char_argv_;
#if defined (ACE_USES_WCHAR)
/// Data member pointer that contains converted argv in ACE_TCHAR.
wchar_t** wchar_argv_;
/// argc value before any argv has been passed.
int before_pass_argc_;
/// false represents original argv passed in is char, and true
/// represents wchar_t.
bool const original_type_;
/// true indicates wchar_t type argv has been passed.
bool wchar_passed_;
/// true indicates char type argv has been passed.
bool char_passed_;
#endif /* ACE_USES_WCHAR */
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Argv_Type_Converter.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_ARGV_TYPE_CONVERTER_H */
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: Argv_Type_Converter.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE ACE_TCHAR**
ACE_Argv_Type_Converter::get_TCHAR_argv (void)
{
@@ -10,12 +12,14 @@ ACE_Argv_Type_Converter::get_TCHAR_argv (void)
{
this->align_wchar_with_char ();
}
this->wchar_passed_ = true;
return this->wchar_argv_;
#else
return this->char_argv_;
#endif // ACE_USES_WCHAR
}
ACE_INLINE char**
ACE_Argv_Type_Converter::get_ASCII_argv (void)
{
@@ -24,13 +28,17 @@ ACE_Argv_Type_Converter::get_ASCII_argv (void)
{
this->align_char_with_wchar ();
}
this->char_passed_ = true;
#endif // ACE_USES_WCHAR
return this->char_argv_;
}
ACE_INLINE int&
ACE_Argv_Type_Converter::get_argc (void)
{
return this->saved_argc_;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+5
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file Array.h
@@ -13,13 +14,17 @@
* @author Douglas C. Schmidt <[email protected]>
*/
//=============================================================================
#ifndef ACE_ARRAY_H
#define ACE_ARRAY_H
#include /**/ "ace/pre.h"
#include "ace/Containers_T.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include /**/ "ace/post.h"
#endif /* ACE_ARRAY_H */
+53
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Array_Base.h
@@ -8,19 +9,27 @@
* @author Douglas C. Schmidt <[email protected]>
*/
//=============================================================================
#ifndef ACE_ARRAY_BASE_H
#define ACE_ARRAY_BASE_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Global_Macros.h"
#include "ace/Malloc_Base.h"
#include <iterator> /* For reverse_iterator adapters */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declaration.
template <class T> class ACE_Array_Iterator;
/**
* @class ACE_Array_Base
*
@@ -34,9 +43,11 @@ template<class T>
class ACE_Array_Base
{
public:
// Old/ACE-style traits.
typedef T TYPE;
typedef ACE_Array_Iterator<T> ITERATOR;
// STL-style typedefs/traits.
typedef T value_type;
typedef value_type * iterator;
@@ -47,21 +58,27 @@ public:
typedef value_type const * const_pointer;
typedef ptrdiff_t difference_type;
typedef ACE_Allocator::size_type size_type;
ACE_DECLARE_STL_REVERSE_ITERATORS
// = Initialization and termination methods.
/// Dynamically create an uninitialized array.
ACE_Array_Base (size_type size = 0,
ACE_Allocator * the_allocator = 0);
/// Dynamically initialize the entire array to the <default_value>.
ACE_Array_Base (size_type size,
T const & default_value,
ACE_Allocator * the_allocator = 0);
/**
* The copy constructor performs initialization by making an exact
* copy of the contents of parameter <s>, i.e., *this == s will
* return true.
*/
ACE_Array_Base (ACE_Array_Base<T> const & s);
/**
* Assignment operator performs an assignment by making an exact
* copy of the contents of parameter <s>, i.e., *this == s will
@@ -71,18 +88,24 @@ public:
* reallocate a new <array_>, and then copy the contents of <s>.
*/
void operator= (ACE_Array_Base<T> const & s);
/// Clean up the array (e.g., delete dynamically allocated memory).
~ACE_Array_Base (void);
// = Set/get methods.
/// Set item in the array at location @a slot. Doesn't
/// perform range checking.
T & operator[] (size_type slot);
/// Get item in the array at location @a slot. Doesn't
/// perform range checking.
T const & operator[] (size_type slot) const;
/// Set an item in the array at location @a slot. Returns
/// -1 if @a slot is not in range, else returns 0.
int set (T const & new_item, size_type slot);
/**
* Get an item in the array at location @a slot. Returns -1 if
* @a slot is not in range, else returns 0. Note that this function
@@ -90,16 +113,20 @@ public:
* the const operator [], but then you'll be responsible for range checking.
*/
int get (T & item, size_type slot) const;
/// Returns the <cur_size_> of the array.
size_type size (void) const;
/**
* Changes the size of the array to match <new_size>.
* It copies the old contents into the new array.
* Return -1 on failure.
*/
int size (size_type new_size);
/// Returns the <max_size_> of the array.
size_type max_size (void) const;
/**
* Changes the size of the array to match <new_size>.
* It copies the old contents into the new array.
@@ -107,6 +134,7 @@ public:
* It does not affect new_size
*/
int max_size (size_type new_size);
/**
* @name Forward Iterator Accessors
*
@@ -118,6 +146,7 @@ public:
const_iterator begin (void) const;
const_iterator end (void) const;
//@}
/**
* @name Reverse Iterator Accessors
*
@@ -129,16 +158,21 @@ public:
const_reverse_iterator rbegin (void) const;
const_reverse_iterator rend (void) const;
//@}
/// Swap the contents of this array with the given @a array in
/// an exception-safe manner.
void swap (ACE_Array_Base<T> & array);
protected:
/// Returns 1 if @a slot is within range, i.e., 0 >= @a slot <
/// <cur_size_>, else returns 0.
bool in_range (size_type slot) const;
/// Maximum size of the array, i.e., the total number of <T> elements
/// in <array_>.
size_type max_size_;
/**
* Current size of the array. This starts out being == to
* <max_size_>. However, if we are assigned a smaller array, then
@@ -147,13 +181,18 @@ protected:
* don't have to.
*/
size_type cur_size_;
/// Pointer to the array's storage buffer.
value_type * array_;
/// Allocation strategy of the ACE_Array_Base.
ACE_Allocator * allocator_;
friend class ACE_Array_Iterator<T>;
};
// ****************************************************************
/**
* @class ACE_Array_Iterator
*
@@ -170,35 +209,49 @@ class ACE_Array_Iterator
public:
// = Initialization method.
ACE_Array_Iterator (ACE_Array_Base<T> &);
// = Iteration methods.
/// Pass back the <next_item> that hasn't been seen in the Array.
/// Returns 0 when all items have been seen, else 1.
int next (T *&next_item);
/// Move forward by one element in the Array. Returns 0 when all the
/// items in the Array have been seen, else 1.
int advance (void);
/// Returns 1 when all items have been seen, else 0.
int done (void) const;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
/// Pointer to the current item in the iteration.
size_t current_;
/// Pointer to the Array we're iterating over.
ACE_Array_Base<T> &array_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Array_Base.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Array_Base.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Array_Base.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_ARRAY_BASE_H */
+23
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: Array_Base.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Clean up the array (e.g., delete dynamically allocated memory).
template <class T> ACE_INLINE
ACE_Array_Base<T>::~ACE_Array_Base (void)
@@ -11,80 +13,95 @@ ACE_Array_Base<T>::~ACE_Array_Base (void)
this->allocator_->free,
T);
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::iterator
ACE_Array_Base<T>::begin (void)
{
return this->array_;
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::iterator
ACE_Array_Base<T>::end (void)
{
return this->array_ + this->cur_size_;
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::const_iterator
ACE_Array_Base<T>::begin (void) const
{
return this->array_;
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::const_iterator
ACE_Array_Base<T>::end (void) const
{
return this->array_ + this->cur_size_;
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::reverse_iterator
ACE_Array_Base<T>::rbegin (void)
{
return reverse_iterator (this->end ());
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::reverse_iterator
ACE_Array_Base<T>::rend (void)
{
return reverse_iterator (this->begin ());
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::const_reverse_iterator
ACE_Array_Base<T>::rbegin (void) const
{
return const_reverse_iterator (this->end ());
}
template <class T>
ACE_INLINE typename ACE_Array_Base<T>::const_reverse_iterator
ACE_Array_Base<T>::rend (void) const
{
return const_reverse_iterator (this->begin ());
}
template <class T> ACE_INLINE typename ACE_Array_Base<T>::size_type
ACE_Array_Base<T>::size (void) const
{
return this->cur_size_;
}
template <class T> ACE_INLINE typename ACE_Array_Base<T>::size_type
ACE_Array_Base<T>::max_size (void) const
{
return this->max_size_;
}
template <class T> ACE_INLINE bool
ACE_Array_Base<T>::in_range (typename ACE_Array_Base<T>::size_type index) const
{
return index < this->cur_size_;
}
template <class T> ACE_INLINE T &
ACE_Array_Base<T>::operator[] (typename ACE_Array_Base<T>::size_type index)
{
return this->array_[index];
}
template <class T> ACE_INLINE const T &
ACE_Array_Base<T>::operator[] (typename ACE_Array_Base<T>::size_type index) const
{
return this->array_[index];
}
// ****************************************************************
template <class T> ACE_INLINE void
ACE_Array_Iterator<T>::dump (void) const
{
@@ -92,6 +109,7 @@ ACE_Array_Iterator<T>::dump (void) const
// ACE_TRACE ("ACE_Array_Iterator<T>::dump");
#endif /* ACE_HAS_DUMP */
}
template <class T> ACE_INLINE
ACE_Array_Iterator<T>::ACE_Array_Iterator (ACE_Array_Base<T> &a)
: current_ (0),
@@ -99,10 +117,12 @@ ACE_Array_Iterator<T>::ACE_Array_Iterator (ACE_Array_Base<T> &a)
{
// ACE_TRACE ("ACE_Array_Iterator<T>::ACE_Array_Iterator");
}
template <class T> ACE_INLINE int
ACE_Array_Iterator<T>::advance (void)
{
// ACE_TRACE ("ACE_Array_Iterator<T>::advance");
if (this->current_ < array_.size ())
{
++this->current_;
@@ -114,10 +134,13 @@ ACE_Array_Iterator<T>::advance (void)
return 0;
}
}
template <class T> ACE_INLINE int
ACE_Array_Iterator<T>::done (void) const
{
ACE_TRACE ("ACE_Array_Iterator<T>::done");
return this->current_ >= array_.size ();
}
ACE_END_VERSIONED_NAMESPACE_DECL
+48
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Array_Map.h
@@ -15,17 +16,24 @@
*/
//=============================================================================
#ifndef ACE_ARRAY_MAP_H
#define ACE_ARRAY_MAP_H
#include /**/ "ace/pre.h"
#include "ace/config-lite.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include <utility>
#include <iterator>
#include <functional>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Array_Map
*
@@ -80,6 +88,7 @@ template<typename Key, typename Value, class EqualTo = std::equal_to<Key> >
class ACE_Array_Map
{
public:
// STL-style typedefs/traits.
typedef Key key_type;
typedef Value data_type;
@@ -92,22 +101,28 @@ public:
typedef value_type const * const_pointer;
typedef ptrdiff_t difference_type;
typedef size_t size_type;
ACE_DECLARE_STL_REVERSE_ITERATORS
/// Default Constructor.
/**
* Create an empty map with a preallocated buffer of size @a s.
*/
ACE_Array_Map (size_type s = 0);
#ifndef ACE_LACKS_MEMBER_TEMPLATES
template<typename InputIterator>
ACE_Array_Map (InputIterator f, InputIterator l);
#else
ACE_Array_Map (const_iterator f, const_iterator l);
#endif /* !ACE_LACKS_MEMBER_TEMPLATES */
ACE_Array_Map (ACE_Array_Map const & map);
ACE_Array_Map & operator= (ACE_Array_Map const & map);
/// Destructor.
~ACE_Array_Map (void);
/**
* @name Forward Iterator Accessors
*
@@ -119,6 +134,7 @@ public:
const_iterator begin (void) const;
const_iterator end (void) const;
//@}
/**
* @name Reverse Iterator Accessors
*
@@ -130,24 +146,30 @@ public:
const_reverse_iterator rbegin (void) const;
const_reverse_iterator rend (void) const;
//@}
/// Return current size of map.
/**
* @return The number of elements in the map.
*/
size_type size (void) const;
/// Maximum number of elements the map can hold.
size_type max_size (void) const;
/// Return @c true if the map is empty, else @c false.
bool is_empty (void) const; // ACE style
/**
* Return @c true if the map is empty, else @c false. We recommend
* using @c is_empty() instead since it's more consistent with the
* ACE container naming conventions.
*/
bool empty (void) const; // STL style
/// Swap the contents of this map with the given @a map in an
/// exception-safe manner.
void swap (ACE_Array_Map & map);
/// Insert the value @a x into the map.
/**
* STL-style map insertion method.
@@ -158,6 +180,7 @@ public:
* contains a value with the same key as @a x.
*/
std::pair<iterator, bool> insert (value_type const & x);
#ifndef ACE_LACKS_MEMBER_TEMPLATES
/// Insert range of elements into map.
template<typename InputIterator>
@@ -166,23 +189,28 @@ public:
/// Insert range of elements into map.
void insert (const_iterator f, const_iterator l);
#endif /* ACE_LACKS_MEMBER_TEMPLATES */
/// Remove element at position @a pos from the map.
void erase (iterator pos);
/// Remove element corresponding to key @a k from the map.
/**
* @return Number of elements that were erased.
*/
size_type erase (key_type const & k);
/// Remove range of elements [@a first, @a last) from the map.
/**
* @note [@a first, @a last) must be valid range within the map.
*/
void erase (iterator first, iterator last);
/// Clear contents of map.
/**
* @note This a constant time (O(1)) operation.
*/
void clear (void);
/**
* @name Search Operations
*
@@ -194,18 +222,21 @@ public:
* map.
*/
iterator find (key_type const & k);
/**
* @return @c end() if data corresponding to key @a k is not in the
* map.
*/
const_iterator find (key_type const & k) const;
//@}
/// Count the number of elements corresponding to key @a k.
/**
* @return In the case of this map, the count will always be one if
* such exists in the map.
*/
size_type count (key_type const & k);
/// Convenience array index operator.
/**
* Array index operator that allows insertion and retrieval of
@@ -214,40 +245,57 @@ public:
* map["Foo"] = 12;
*/
data_type & operator[] (key_type const & k);
private:
/// Increase size of underlying buffer by @a s.
void grow (size_type s);
private:
/// Number of elements in the map.
size_type size_;
/// Current size of underlying array.
/**
* @note @c capacity_ is always greater than or equal to @c size_;
*/
size_type capacity_;
/// Underlying array containing keys and data.
value_type * nodes_;
};
// --------------------------------------------------------------
/// @c ACE_Array_Map equality operator.
template <typename Key, typename Value, class EqualTo>
bool operator== (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
ACE_Array_Map<Key, Value, EqualTo> const & rhs);
/// @c ACE_Array_Map lexicographical comparison operator.
template <typename Key, typename Value, class EqualTo>
bool operator< (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
ACE_Array_Map<Key, Value, EqualTo> const & rhs);
// --------------------------------------------------------------
ACE_END_VERSIONED_NAMESPACE_DECL
#ifdef __ACE_INLINE__
# include "ace/Array_Map.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
# include "ace/Array_Map.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Array_Map.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_ARRAY_MAP_H */
+20
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: Array_Map.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template<typename Key, typename Value, class EqualTo>
ACE_INLINE
ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (
@@ -11,89 +13,105 @@ ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (
, nodes_ (s == 0 ? 0 : new value_type[s])
{
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE ACE_Array_Map<Key, Value, EqualTo> &
ACE_Array_Map<Key, Value, EqualTo>::operator= (
ACE_Array_Map<Key, Value, EqualTo> const & map)
{
// Strongly exception-safe assignment.
ACE_Array_Map<Key, Value, EqualTo> temp (map);
this->swap (temp);
return *this;
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::iterator
ACE_Array_Map<Key, Value, EqualTo>::begin (void)
{
return this->nodes_;
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::iterator
ACE_Array_Map<Key, Value, EqualTo>::end (void)
{
return this->nodes_ + this->size_;
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator
ACE_Array_Map<Key, Value, EqualTo>::begin (void) const
{
return this->nodes_;
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator
ACE_Array_Map<Key, Value, EqualTo>::end (void) const
{
return this->nodes_ + this->size_;
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::reverse_iterator
ACE_Array_Map<Key, Value, EqualTo>::rbegin (void)
{
return reverse_iterator (this->end ());
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::reverse_iterator
ACE_Array_Map<Key, Value, EqualTo>::rend (void)
{
return reverse_iterator (this->begin ());
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_reverse_iterator
ACE_Array_Map<Key, Value, EqualTo>::rbegin (void) const
{
return const_reverse_iterator (this->end ());
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_reverse_iterator
ACE_Array_Map<Key, Value, EqualTo>::rend (void) const
{
return const_reverse_iterator (this->begin ());
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::size_type
ACE_Array_Map<Key, Value, EqualTo>::size (void) const
{
return this->size_;
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::size_type
ACE_Array_Map<Key, Value, EqualTo>::max_size (void) const
{
return size_type (-1) / sizeof (value_type);
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE bool
ACE_Array_Map<Key, Value, EqualTo>::is_empty (void) const
{
return this->size_ == 0;
}
// The following method is deprecated.
template<typename Key, typename Value, class EqualTo>
ACE_INLINE bool
ACE_Array_Map<Key, Value, EqualTo>::empty (void) const
{
return this->is_empty ();
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::size_type
ACE_Array_Map<Key, Value, EqualTo>::count (
@@ -102,6 +120,7 @@ ACE_Array_Map<Key, Value, EqualTo>::count (
return
(this->find (k) == this->end () ? 0 : 1); // Only one datum per key.
}
template<typename Key, typename Value, class EqualTo>
ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::data_type &
ACE_Array_Map<Key, Value, EqualTo>::operator[] (
@@ -110,4 +129,5 @@ ACE_Array_Map<Key, Value, EqualTo>::operator[] (
iterator i = (this->insert (value_type (k, data_type ()))).first;
return (*i).second;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+7
View File
@@ -1,8 +1,12 @@
// $Id: Assert.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Assert.h"
#include "ace/Log_Msg.h"
ACE_RCSID(ace, Assert, "$Id: Assert.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// The following ASSERT macro is courtesy of Alexandre Karev
// <[email protected]>.
void
@@ -10,9 +14,12 @@ __ace_assert(const char *file, int line, const ACE_TCHAR *expression)
{
int error = ACE_Log_Msg::last_error_adapter ();
ACE_Log_Msg *log = ACE_Log_Msg::instance ();
log->set (file, line, -1, error, log->restart (),
log->msg_ostream (), log->msg_callback ());
log->log (LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1);
}
ACE_END_VERSIONED_NAMESPACE_DECL
+9
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Assert.h
@@ -8,14 +9,20 @@
* @author Douglas C. Schmidt <[email protected]>
*/
//=============================================================================
#ifndef ACE_ASSERT_H
#define ACE_ASSERT_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#include /**/ "ace/config-all.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Export void __ace_assert(const char *file, int line, const ACE_TCHAR *expression);
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (ACE_NDEBUG)
#define ACE_ASSERT(x) \
(static_cast<void>(0))
@@ -25,6 +32,8 @@ ACE_END_VERSIONED_NAMESPACE_DECL
? static_cast<void>(0) \
: ACE_VERSIONED_NAMESPACE_NAME::__ace_assert(__FILE__, __LINE__, ACE_TEXT_CHAR_TO_TCHAR (#X)))
#endif /* ACE_NDEBUG */
#include /**/ "ace/post.h"
#endif /* ACE_ASSERT */
+44
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file Asynch_Acceptor.h
@@ -8,21 +9,29 @@
* @author Irfan Pyarali ([email protected])
*/
//=============================================================================
#ifndef ACE_ASYNCH_ACCEPTOR_H
#define ACE_ASYNCH_ACCEPTOR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
// This only works on platforms that support async i/o.
#include "ace/Default_Constants.h"
#include "ace/Asynch_IO.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declarations
class ACE_Message_Block;
class ACE_INET_Addr;
/**
* @class ACE_Asynch_Acceptor
*
@@ -39,8 +48,10 @@ class ACE_Asynch_Acceptor : public ACE_Handler
public:
/// A do nothing constructor.
ACE_Asynch_Acceptor (void);
/// Virtual destruction
virtual ~ACE_Asynch_Acceptor (void);
/**
* @c open starts one or more asynchronous accept requests on a
* @a address. Each accept operation may optionally read an
@@ -104,8 +115,10 @@ public:
bool validate_new_connection = false,
int reissue_accept = 1,
int number_of_initial_accepts = -1);
/// Get the underlying handle.
virtual ACE_HANDLE get_handle (void) const;
/**
* Set the underlying listen handle. It is the user's responsibility
* to make sure that the old listen handle has been appropriately
@@ -113,12 +126,14 @@ public:
* either completed or have been canceled on the old listen handle.
*/
virtual int set_handle (ACE_HANDLE handle);
/// This initiates a new asynchronous accept operation.
/**
* You need only call this method if the @a reissue_accept argument
* passed to @c open() was 0.
*/
virtual int accept (size_t bytes_to_read = 0, const void *act = 0);
/**
* Cancels all pending accepts operations issued by this object.
*
@@ -126,6 +141,7 @@ public:
* are canceled.
*/
virtual int cancel (void);
/**
* Template method to validate peer before service is opened.
* This method is called after a new connection is accepted if the
@@ -149,6 +165,7 @@ public:
virtual int validate_connection (const ACE_Asynch_Accept::Result& result,
const ACE_INET_Addr &remote,
const ACE_INET_Addr& local);
/**
* Template method for deciding whether to reissue accept.
*
@@ -161,77 +178,104 @@ public:
* be changed using the @c reissue_accept() method.
*/
virtual int should_reissue_accept (void);
//
// These are low level tweaking methods
//
/// Get flag that indicates if parsing and passing of addresses to
/// the service_handler is necessary.
virtual bool pass_addresses (void) const;
/// Set flag that indicates if parsing and passing of addresses to
/// the service_handler is necessary.
virtual void pass_addresses (bool new_value);
/// Get flag that indicates if address validation is required.
virtual bool validate_new_connection (void) const;
/// Set flag that indicates if address validation is required.
virtual void validate_new_connection (bool new_value);
/// Get flag that indicates if a new accept should be reissued when a accept
/// completes.
virtual int reissue_accept (void) const;
/// Set flag that indicates if a new accept should be reissued when a accept
/// completes.
virtual void reissue_accept (int new_value);
/// Get bytes to be read with the <accept> call.
virtual size_t bytes_to_read (void) const;
/// Set bytes to be read with the <accept> call.
virtual void bytes_to_read (size_t new_value);
/// @deprecated address_size() assumes IPv4 use, so is not always valid.
/// This method will be removed after ACE 5.5. Internal uses have been
/// changes to base needed sizes on the addr_family_ member.
static size_t address_size (void);
protected:
/// This is called when an outstanding accept completes.
virtual void handle_accept (const ACE_Asynch_Accept::Result &result);
/// Return the listen handle.
ACE_HANDLE handle (void) const;
/// Set the listen handle.
void handle (ACE_HANDLE h);
/// This parses the address from read buffer.
void parse_address (const ACE_Asynch_Accept::Result &result,
ACE_INET_Addr &remote_address,
ACE_INET_Addr &local_address);
/// Return the asynch accept object.
ACE_Asynch_Accept &asynch_accept (void);
/**
* This is the template method used to create new handler.
* Subclasses must overwrite this method if a new handler creation
* strategy is required.
*/
virtual HANDLER *make_handler (void);
private:
/// Handle used to listen for new connections.
ACE_HANDLE listen_handle_;
/// Asynch_Accept used to make life easier :-)
ACE_Asynch_Accept asynch_accept_;
/// Flag that indicates if parsing of addresses is necessary.
bool pass_addresses_;
/// Flag that indicates if address validation is required.
bool validate_new_connection_;
/// Flag that indicates if a new accept should be reissued when a
/// accept completes.
int reissue_accept_;
/// Bytes to be read with the <accept> call.
size_t bytes_to_read_;
/// Address family used to open this object. Obtained from @a address passed
/// to @c open().
int addr_family_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Asynch_Acceptor.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Asynch_Acceptor.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
#include /**/ "ace/post.h"
#endif /* ACE_ASYNCH_ACCEPTOR_H */
+31
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file Asynch_Connector.h
@@ -8,20 +9,28 @@
* @author Alexander Libman <[email protected]>
*/
//=============================================================================
#ifndef ACE_ASYNCH_CONNECTOR_H
#define ACE_ASYNCH_CONNECTOR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if (defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS)) && !defined(ACE_HAS_WINCE)
// This only works on platforms that support async i/o.
#include "ace/Asynch_IO.h"
#include "ace/INET_Addr.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declarations
class ACE_Message_Block;
/**
* @class ACE_Asynch_Connector
*
@@ -32,26 +41,31 @@ class ACE_Message_Block;
* Unlike the ACE_Connector, however, this class is designed to
* be used asynchronously with the ACE Proactor framework.
*/
template <class HANDLER>
class ACE_Asynch_Connector : public ACE_Handler
{
public:
/// A do nothing constructor.
ACE_Asynch_Connector (void);
/// Virtual destruction
virtual ~ACE_Asynch_Connector (void);
/**
* This opens asynch connector
*/
virtual int open (bool pass_addresses = false,
ACE_Proactor *proactor = 0,
bool validate_new_connection = true);
/// This initiates a new asynchronous connect
virtual int connect (const ACE_INET_Addr &remote_sap,
const ACE_INET_Addr &local_sap =
(const ACE_INET_Addr &)ACE_Addr::sap_any,
int reuse_addr = 1,
const void *act = 0);
/**
* This cancels all pending accepts operations that were issued by
* the calling thread.
@@ -63,6 +77,7 @@ public:
*/
virtual int cancel (void);
/**
* Template method to validate peer before service is opened.
* This method is called when the connection attempt completes,
@@ -93,48 +108,64 @@ public:
virtual int validate_connection (const ACE_Asynch_Connect::Result& result,
const ACE_INET_Addr &remote,
const ACE_INET_Addr& local);
//
// These are low level tweaking methods
//
/// Set and get flag that indicates if parsing and passing of
/// addresses to the service_handler is necessary.
virtual bool pass_addresses (void) const;
virtual void pass_addresses (bool new_value);
/// Set and get flag that indicates if address validation is
/// required.
virtual bool validate_new_connection (void) const;
virtual void validate_new_connection (bool new_value);
protected:
/// This is called when an outstanding accept completes.
virtual void handle_connect (const ACE_Asynch_Connect::Result &result);
/// This parses the address from read buffer.
void parse_address (const ACE_Asynch_Connect::Result &result,
ACE_INET_Addr &remote_address,
ACE_INET_Addr &local_address);
/// Return the asynch Connect object.
ACE_Asynch_Connect & asynch_connect (void);
/**
* This is the template method used to create new handler.
* Subclasses must overwrite this method if a new handler creation
* strategy is required.
*/
virtual HANDLER *make_handler (void);
private:
/// Asynch_Connect used to make life easier :-)
ACE_Asynch_Connect asynch_connect_;
/// Flag that indicates if parsing of addresses is necessary.
bool pass_addresses_;
/// Flag that indicates if address validation is required.
bool validate_new_connection_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Asynch_Connector.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Asynch_Connector.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */
#include /**/ "ace/post.h"
#endif /* ACE_ASYNCH_CONNECTOR_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+32
View File
@@ -1,86 +1,118 @@
// $Id: Asynch_IO_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Asynch_IO_Impl.h"
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
// This only works on Win32 platforms and on Unix platforms supporting
// aio calls.
#if !defined (__ACE_INLINE__)
#include "ace/Asynch_IO_Impl.inl"
#endif /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Asynch_Result_Impl::~ACE_Asynch_Result_Impl (void)
{
}
ACE_Asynch_Operation_Impl::~ACE_Asynch_Operation_Impl (void)
{
}
ACE_Asynch_Read_Stream_Impl::~ACE_Asynch_Read_Stream_Impl (void)
{
}
ACE_Asynch_Read_Stream_Result_Impl::~ACE_Asynch_Read_Stream_Result_Impl (void)
{
}
ACE_Asynch_Write_Stream_Impl::~ACE_Asynch_Write_Stream_Impl (void)
{
}
ACE_Asynch_Write_Stream_Result_Impl::~ACE_Asynch_Write_Stream_Result_Impl (void)
{
}
ACE_Asynch_Read_File_Impl::~ACE_Asynch_Read_File_Impl (void)
{
}
ACE_Asynch_Write_File_Impl::~ACE_Asynch_Write_File_Impl (void)
{
}
ACE_Asynch_Read_File_Result_Impl::~ACE_Asynch_Read_File_Result_Impl (void)
{
}
ACE_Asynch_Write_File_Result_Impl::~ACE_Asynch_Write_File_Result_Impl (void)
{
}
ACE_Asynch_Accept_Result_Impl::~ACE_Asynch_Accept_Result_Impl (void)
{
}
ACE_Asynch_Connect_Result_Impl::~ACE_Asynch_Connect_Result_Impl (void)
{
}
ACE_Asynch_Accept_Impl::~ACE_Asynch_Accept_Impl (void)
{
}
ACE_Asynch_Connect_Impl::~ACE_Asynch_Connect_Impl (void)
{
}
ACE_Asynch_Transmit_File_Impl::~ACE_Asynch_Transmit_File_Impl (void)
{
}
ACE_Asynch_Transmit_File_Result_Impl::~ACE_Asynch_Transmit_File_Result_Impl (void)
{
}
ACE_Asynch_Read_Dgram_Impl::~ACE_Asynch_Read_Dgram_Impl (void)
{
}
ACE_Asynch_Read_Dgram_Impl::ACE_Asynch_Read_Dgram_Impl (void)
{
}
ACE_Asynch_Write_Dgram_Impl::~ACE_Asynch_Write_Dgram_Impl (void)
{
}
ACE_Asynch_Write_Dgram_Impl::ACE_Asynch_Write_Dgram_Impl (void)
{
}
//***********************************************
ACE_Asynch_Read_Dgram_Result_Impl::~ACE_Asynch_Read_Dgram_Result_Impl (void)
{
}
ACE_Asynch_Read_Dgram_Result_Impl::ACE_Asynch_Read_Dgram_Result_Impl (void)
{
}
//***********************************************
ACE_Asynch_Write_Dgram_Result_Impl::~ACE_Asynch_Write_Dgram_Result_Impl (void)
{
}
ACE_Asynch_Write_Dgram_Result_Impl::ACE_Asynch_Write_Dgram_Result_Impl (void)
{
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
+109
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file Asynch_IO_Impl.h
@@ -18,20 +19,28 @@
* @author Alexander Libman <[email protected]>
*/
//=============================================================================
#ifndef ACE_ASYNCH_IO_IMPL_H
#define ACE_ASYNCH_IO_IMPL_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
// This only works on Win32 platforms and on Unix platforms supporting
// aio calls.
#include "ace/Asynch_IO.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declaration.
class ACE_Proactor_Impl;
/**
* @class ACE_Asynch_Result_Impl
*
@@ -43,24 +52,33 @@ class ACE_Export ACE_Asynch_Result_Impl
{
public:
virtual ~ACE_Asynch_Result_Impl (void);
/// Number of bytes transferred by the operation.
virtual size_t bytes_transferred (void) const = 0;
/// ACT associated with the operation.
virtual const void *act (void) const = 0;
/// Did the operation succeed?
virtual int success (void) const = 0;
/// This ACT is not the same as the ACT associated with the
/// asynchronous operation.
virtual const void *completion_key (void) const = 0;
/// Error value if the operation fail.
virtual u_long error (void) const = 0;
/// Event associated with the OVERLAPPED structure.
virtual ACE_HANDLE event (void) const = 0;
/// This really make sense only when doing file I/O.
virtual u_long offset (void) const = 0;
virtual u_long offset_high (void) const = 0;
/// Priority of the operation.
virtual int priority (void) const = 0;
/**
* POSIX4 real-time signal number to be used for the
* operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By
@@ -68,6 +86,7 @@ public:
* on non-POSIX4 systems and returns 0.
*/
virtual int signal_number (void) const = 0;
// protected:
//
// These two should really be protected. But sometimes it
@@ -77,12 +96,15 @@ public:
int success,
const void *completion_key,
u_long error = 0) = 0;
/// Post @c this to the Proactor's completion port.
virtual int post_completion (ACE_Proactor_Impl *proactor) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Result_Impl (void);
};
/**
* @class ACE_Asynch_Operation_Impl
*
@@ -94,6 +116,7 @@ class ACE_Export ACE_Asynch_Operation_Impl
{
public:
virtual ~ACE_Asynch_Operation_Impl (void);
/**
* Initializes the factory with information which will be used with
* each asynchronous call. If @a handle == ACE_INVALID_HANDLE,
@@ -104,19 +127,24 @@ public:
ACE_HANDLE handle,
const void *completion_key,
ACE_Proactor *proactor) = 0;
/**
* This cancels all pending accepts operations that were issued by
* the calling thread. The function does not cancel asynchronous
* operations issued by other threads.
*/
virtual int cancel (void) = 0;
// = Access methods.
/// Return the underlying proactor.
virtual ACE_Proactor* proactor (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Operation_Impl (void);
};
/**
* @class ACE_Asynch_Read_Stream_Impl
*
@@ -129,6 +157,7 @@ class ACE_Export ACE_Asynch_Read_Stream_Impl : public virtual ACE_Asynch_Operati
{
public:
virtual ~ACE_Asynch_Read_Stream_Impl (void);
/// This starts off an asynchronous read. Upto @a bytes_to_read will
/// be read and stored in the @a message_block.
virtual int read (ACE_Message_Block &message_block,
@@ -136,6 +165,7 @@ public:
const void *act,
int priority,
int signal_number) = 0;
#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
/**
* Same as above but with scatter support, through chaining of composite
@@ -147,10 +177,12 @@ public:
int priority,
int signal_number) = 0;
#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_Stream_Impl (void);
};
/**
* @class ACE_Asynch_Read_Stream_Result_Impl
*
@@ -163,17 +195,22 @@ class ACE_Export ACE_Asynch_Read_Stream_Result_Impl : public virtual ACE_Asynch_
{
public:
virtual ~ACE_Asynch_Read_Stream_Result_Impl (void);
/// The number of bytes which were requested at the start of the
/// asynchronous read.
virtual size_t bytes_to_read (void) const = 0;
/// Message block which contains the read data.
virtual ACE_Message_Block &message_block (void) const = 0;
/// I/O handle used for reading.
virtual ACE_HANDLE handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_Stream_Result_Impl (void);
};
/**
* @class ACE_Asynch_Write_Stream_Impl
*
@@ -186,6 +223,7 @@ class ACE_Export ACE_Asynch_Write_Stream_Impl : public virtual ACE_Asynch_Operat
{
public:
virtual ~ACE_Asynch_Write_Stream_Impl (void);
/// This starts off an asynchronous write. Upto @a bytes_to_write
/// will be written from the @a message_block.
virtual int write (ACE_Message_Block &message_block,
@@ -193,6 +231,7 @@ public:
const void *act,
int priority,
int signal_number) = 0;
#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
/**
* Same as above but with gather support, through chaining of composite
@@ -204,10 +243,12 @@ public:
int priority,
int signal_number) = 0;
#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_Stream_Impl (void);
};
/**
* @class ACE_Asynch_Write_Stream_Result_Impl
*
@@ -220,17 +261,22 @@ class ACE_Export ACE_Asynch_Write_Stream_Result_Impl : public virtual ACE_Asynch
{
public:
virtual ~ACE_Asynch_Write_Stream_Result_Impl (void);
/// The number of bytes which were requested at the start of the
/// asynchronous write.
virtual size_t bytes_to_write (void) const = 0;
/// Message block that contains the data to be written.
virtual ACE_Message_Block &message_block (void) const = 0;
/// I/O handle used for writing.
virtual ACE_HANDLE handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_Stream_Result_Impl (void);
};
/**
* @class ACE_Asynch_Read_File_Impl
*
@@ -243,6 +289,7 @@ class ACE_Export ACE_Asynch_Read_File_Impl : public virtual ACE_Asynch_Read_Stre
{
public:
virtual ~ACE_Asynch_Read_File_Impl (void);
/**
* This starts off an asynchronous read. Upto @a bytes_to_read will
* be read and stored in the @a message_block. The read will start
@@ -255,6 +302,7 @@ public:
const void *act,
int priority,
int signal_number) = 0;
#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
/**
* Same as above but with scatter support, through chaining of composite
@@ -270,6 +318,7 @@ public:
int priority,
int signal_number) = 0;
#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
/// This starts off an asynchronous read. Upto @a bytes_to_read will
/// be read and stored in the @a message_block.
virtual int read (ACE_Message_Block &message_block,
@@ -277,6 +326,7 @@ public:
const void *act,
int priority,
int signal_number) = 0;
#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
/**
* Same as above but with scatter support, through chaining of composite
@@ -288,10 +338,12 @@ public:
int priority,
int signal_number) = 0;
#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_File_Impl (void);
};
/**
* @class ACE_Asynch_Read_File_Result_Impl
*
@@ -304,10 +356,12 @@ class ACE_Export ACE_Asynch_Read_File_Result_Impl : public virtual ACE_Asynch_Re
public:
/// Destructor.
virtual ~ACE_Asynch_Read_File_Result_Impl (void);
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_File_Result_Impl (void);
};
/**
* @class ACE_Asynch_Write_File_Impl
*
@@ -320,6 +374,7 @@ class ACE_Export ACE_Asynch_Write_File_Impl : public virtual ACE_Asynch_Write_St
{
public:
virtual ~ACE_Asynch_Write_File_Impl (void);
/**
* This starts off an asynchronous write. Upto @a bytes_to_write
* will be write and stored in the @a message_block. The write will
@@ -332,6 +387,7 @@ public:
const void *act,
int priority,
int signal_number) = 0;
#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
/**
* Same as above but with gather support, through chaining of composite
@@ -347,6 +403,7 @@ public:
int priority,
int signal_number) = 0;
#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
/// This starts off an asynchronous write. Upto @a bytes_to_write
/// will be written from the @a message_block.
virtual int write (ACE_Message_Block &message_block,
@@ -354,6 +411,7 @@ public:
const void *act,
int priority,
int signal_number) = 0;
#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
/**
* Same as above but with gather support, through chaining of composite
@@ -365,10 +423,12 @@ public:
int priority,
int signal_number) = 0;
#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_File_Impl (void);
};
/**
* @class ACE_Asynch_Write_File_Result_Impl
*
@@ -381,10 +441,12 @@ class ACE_Export ACE_Asynch_Write_File_Result_Impl : public virtual ACE_Asynch_W
{
public:
virtual ~ACE_Asynch_Write_File_Result_Impl (void);
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_File_Result_Impl (void);
};
/**
* @class ACE_Asynch_Accept_Impl
*
@@ -397,6 +459,7 @@ class ACE_Export ACE_Asynch_Accept_Impl : public virtual ACE_Asynch_Operation_Im
{
public:
virtual ~ACE_Asynch_Accept_Impl (void);
/**
* This starts off an asynchronous accept. The asynchronous accept
* call also allows any initial data to be returned to the
@@ -415,10 +478,12 @@ public:
int priority,
int signal_number,
int addr_family) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Accept_Impl (void);
};
/**
* @class ACE_Asynch_Accept_Result_Impl
*
@@ -431,20 +496,26 @@ class ACE_Export ACE_Asynch_Accept_Result_Impl : public virtual ACE_Asynch_Resul
{
public:
virtual ~ACE_Asynch_Accept_Result_Impl (void);
/// The number of bytes which were requested at the start of the
/// asynchronous accept.
virtual size_t bytes_to_read (void) const = 0;
/// Message block which contains the read data.
virtual ACE_Message_Block &message_block (void) const = 0;
/// I/O handle used for accepting new connections.
virtual ACE_HANDLE listen_handle (void) const = 0;
/// I/O handle for the new connection.
virtual ACE_HANDLE accept_handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Accept_Result_Impl (void);
};
/**
* @class ACE_Asynch_Connect_Impl
*
@@ -457,6 +528,7 @@ class ACE_Export ACE_Asynch_Connect_Impl : public virtual ACE_Asynch_Operation_I
{
public:
virtual ~ACE_Asynch_Connect_Impl (void);
/**
* This starts off an asynchronous connect
*/
@@ -467,10 +539,12 @@ public:
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Connect_Impl (void);
};
/**
* @class ACE_Asynch_Connect_Result_Impl
*
@@ -483,13 +557,16 @@ class ACE_Export ACE_Asynch_Connect_Result_Impl : public virtual ACE_Asynch_Resu
{
public:
virtual ~ACE_Asynch_Connect_Result_Impl (void);
/// I/O handle for the connection.
virtual ACE_HANDLE connect_handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Connect_Result_Impl (void);
};
/**
* @class ACE_Asynch_Transmit_File_Impl
*
@@ -502,6 +579,7 @@ class ACE_Asynch_Transmit_File_Impl : public virtual ACE_Asynch_Operation_Impl
{
public:
virtual ~ACE_Asynch_Transmit_File_Impl (void);
/// This starts off an asynchronous transmit file.
virtual int transmit_file (ACE_HANDLE file,
ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
@@ -513,10 +591,12 @@ public:
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Transmit_File_Impl (void);
};
/**
* @class ACE_Asynch_Transmit_File_Result_Impl
*
@@ -529,25 +609,33 @@ class ACE_Export ACE_Asynch_Transmit_File_Result_Impl : public virtual ACE_Async
{
public:
virtual ~ACE_Asynch_Transmit_File_Result_Impl (void);
/// Socket used for transmitting the file.
virtual ACE_HANDLE socket (void) const = 0;
/// File from which the data is read.
virtual ACE_HANDLE file (void) const = 0;
/// Header and trailer data associated with this transmit file.
virtual ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer (void) const = 0;
/// The number of bytes which were requested at the start of the
/// asynchronous transmit file.
virtual size_t bytes_to_write (void) const = 0;
/// Number of bytes per send requested at the start of the transmit
/// file.
virtual size_t bytes_per_send (void) const = 0;
/// Flags which were passed into transmit file.
virtual u_long flags (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Transmit_File_Result_Impl (void);
};
/**
* @class ACE_Asynch_Read_Dgram_Impl
*
@@ -560,6 +648,7 @@ class ACE_Export ACE_Asynch_Read_Dgram_Impl : public virtual ACE_Asynch_Operatio
{
public:
virtual ~ACE_Asynch_Read_Dgram_Impl (void);
/** This starts off an asynchronous read. Upto
* <message_block->total_size()> will be read and stored in the
* @a message_block. @a message_block's <wr_ptr> will be updated to reflect
@@ -593,10 +682,12 @@ public:
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_Dgram_Impl (void);
};
/**
* @class ACE_Asynch_Read_Dgram_Result_Impl
*
@@ -609,21 +700,28 @@ class ACE_Export ACE_Asynch_Read_Dgram_Result_Impl : public virtual ACE_Asynch_R
{
public:
virtual ~ACE_Asynch_Read_Dgram_Result_Impl (void);
/// Message block which contains the read data
virtual ACE_Message_Block *message_block (void) const = 0;
/// The number of bytes which were requested at the start of the
/// asynchronous read.
virtual size_t bytes_to_read (void) const = 0;
/// The address of where the packet came from
virtual int remote_address (ACE_Addr& addr) const = 0;
/// The flags used in the read
virtual int flags (void) const = 0;
/// I/O handle used for reading.
virtual ACE_HANDLE handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_Dgram_Result_Impl (void);
};
/**
* @class ACE_Asynch_Write_Dgram_Impl
*
@@ -636,6 +734,7 @@ class ACE_Export ACE_Asynch_Write_Dgram_Impl : public virtual ACE_Asynch_Operati
{
public:
virtual ~ACE_Asynch_Write_Dgram_Impl (void);
/** This starts off an asynchronous send. Upto
* <message_block->total_length()> will be sent. @a message_block's
* <rd_ptr> will be updated to reflect the sent bytes if the send operation
@@ -669,10 +768,12 @@ public:
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_Dgram_Impl (void);
};
/**
* @class ACE_Asynch_Write_Dgram_Result_Impl
*
@@ -685,23 +786,31 @@ class ACE_Export ACE_Asynch_Write_Dgram_Result_Impl : public virtual ACE_Asynch_
{
public:
virtual ~ACE_Asynch_Write_Dgram_Result_Impl (void);
/// The number of bytes which were requested at the start of the
/// asynchronous write.
virtual size_t bytes_to_write (void) const = 0;
/// Message block which contains the sent data
virtual ACE_Message_Block *message_block (void) const = 0;
/// The flags using in the write
virtual int flags (void) const = 0;
/// I/O handle used for writing.
virtual ACE_HANDLE handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_Dgram_Result_Impl (void);
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Asynch_IO_Impl.inl"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
#include /**/ "ace/post.h"
#endif /* ACE_ASYNCH_IO_IMPL_H */
+18
View File
@@ -1,88 +1,106 @@
// -*- C++ -*-
//
// $Id: Asynch_IO_Impl.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Asynch_Result_Impl::ACE_Asynch_Result_Impl (void)
{
}
ACE_INLINE
ACE_Asynch_Operation_Impl::ACE_Asynch_Operation_Impl (void)
{
}
ACE_INLINE
ACE_Asynch_Read_Stream_Impl::ACE_Asynch_Read_Stream_Impl (void)
: ACE_Asynch_Operation_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Read_Stream_Result_Impl::ACE_Asynch_Read_Stream_Result_Impl (void)
: ACE_Asynch_Result_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Write_Stream_Impl::ACE_Asynch_Write_Stream_Impl (void)
: ACE_Asynch_Operation_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Write_Stream_Result_Impl::ACE_Asynch_Write_Stream_Result_Impl (void)
: ACE_Asynch_Result_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Read_File_Impl::ACE_Asynch_Read_File_Impl (void)
: ACE_Asynch_Operation_Impl (),
ACE_Asynch_Read_Stream_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Read_File_Result_Impl::ACE_Asynch_Read_File_Result_Impl (void)
: ACE_Asynch_Result_Impl (),
ACE_Asynch_Read_Stream_Result_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Write_File_Impl::ACE_Asynch_Write_File_Impl (void)
: ACE_Asynch_Operation_Impl (),
ACE_Asynch_Write_Stream_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Write_File_Result_Impl::ACE_Asynch_Write_File_Result_Impl (void)
: ACE_Asynch_Result_Impl (),
ACE_Asynch_Write_Stream_Result_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Accept_Impl::ACE_Asynch_Accept_Impl (void)
: ACE_Asynch_Operation_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Accept_Result_Impl::ACE_Asynch_Accept_Result_Impl (void)
: ACE_Asynch_Result_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Connect_Impl::ACE_Asynch_Connect_Impl (void)
: ACE_Asynch_Operation_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Connect_Result_Impl::ACE_Asynch_Connect_Result_Impl (void)
: ACE_Asynch_Result_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Transmit_File_Impl::ACE_Asynch_Transmit_File_Impl (void)
: ACE_Asynch_Operation_Impl ()
{
}
ACE_INLINE
ACE_Asynch_Transmit_File_Result_Impl::ACE_Asynch_Transmit_File_Result_Impl (void)
: ACE_Asynch_Result_Impl ()
{
}
ACE_END_VERSIONED_NAMESPACE_DECL
@@ -1,18 +1,25 @@
// $Id: Asynch_Pseudo_Task.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Asynch_Pseudo_Task.h"
#include "ace/OS_NS_errno.h"
#include "ace/OS_NS_signal.h"
ACE_RCSID(ace, Asynch_Pseudo_Task, "$Id: Asynch_Pseudo_Task.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task ()
: select_reactor_ (), // should be initialized before reactor_
reactor_ (&select_reactor_, 0) // don't delete implementation
{
}
ACE_Asynch_Pseudo_Task::~ACE_Asynch_Pseudo_Task ()
{
this->stop ();
}
int
ACE_Asynch_Pseudo_Task::start (void)
{
@@ -21,37 +28,49 @@ ACE_Asynch_Pseudo_Task::start (void)
ACE_TEXT ("%N:%l:%p\n"),
ACE_TEXT ("start reactor is not initialized")),
-1);
return this->activate () == -1 ? -1 : 0; // If started, return 0
}
int
ACE_Asynch_Pseudo_Task::stop (void)
{
if (this->thr_count () == 0) // already stopped
return 0;
if (this->reactor_.end_reactor_event_loop () == -1)
return -1;
this->wait ();
this->reactor_.close ();
return 0;
}
int
ACE_Asynch_Pseudo_Task::svc (void)
{
#if !defined (ACE_WIN32)
sigset_t RT_signals;
sigemptyset (&RT_signals);
for (int si = ACE_SIGRTMIN; si <= ACE_SIGRTMAX; si++)
sigaddset (&RT_signals, si);
if (ACE_OS::pthread_sigmask (SIG_BLOCK, &RT_signals, 0) != 0)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Error:(%P | %t):%p\n"),
ACE_TEXT ("pthread_sigmask")));
#endif
reactor_.owner (ACE_Thread::self ());
reactor_.run_reactor_event_loop ();
return 0;
}
int
ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle,
ACE_Event_Handler *handler,
@@ -61,8 +80,10 @@ ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle,
// Register the handler with the reactor.
if (-1 == this->reactor_.register_handler (handle, handler, mask))
return -1;
if (flg_suspend == 0)
return 0;
// Suspend the handle now. Enable only when the accept is issued
// by the application.
if (this->reactor_.suspend_handler (handle) == -1)
@@ -75,8 +96,10 @@ ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle,
| ACE_Event_Handler::DONT_CALL);
return -1;
}
return 0;
}
int
ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE handle)
{
@@ -84,21 +107,25 @@ ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE handle)
ACE_Event_Handler::ALL_EVENTS_MASK
| ACE_Event_Handler::DONT_CALL);
}
int
ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_Handle_Set &set)
{
return this->reactor_.remove_handler (set, ACE_Event_Handler::ALL_EVENTS_MASK
| ACE_Event_Handler::DONT_CALL);
}
int
ACE_Asynch_Pseudo_Task::suspend_io_handler (ACE_HANDLE handle)
{
return this->reactor_.suspend_handler (handle);
}
int
ACE_Asynch_Pseudo_Task::resume_io_handler (ACE_HANDLE handle)
{
return this->reactor_.resume_handler (handle);
}
ACE_END_VERSIONED_NAMESPACE_DECL
+18
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Asynch_Pseudo_Task.h
@@ -8,23 +9,31 @@
* @author Alexander Libman <alibman@ihug.com.au>
*/
//=============================================================================
#ifndef ACE_ASYNCH_PSEUDO_TASK_H
#define ACE_ASYNCH_PSEUDO_TASK_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Reactor.h"
#include "ace/Select_Reactor.h"
#include "ace/Task.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/*
* Specialization hook to replace the Reactor with the
* concrete Reactor implementation, e.g., select_st,
* select_mt etc.
*/
//@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
/**
* @class ACE_Asynch_Pseudo_Task
*
@@ -34,23 +43,32 @@ class ACE_Export ACE_Asynch_Pseudo_Task : public ACE_Task<ACE_NULL_SYNCH>
public:
ACE_Asynch_Pseudo_Task();
virtual ~ACE_Asynch_Pseudo_Task();
int start (void);
int stop (void);
int register_io_handler (ACE_HANDLE handle,
ACE_Event_Handler *handler,
ACE_Reactor_Mask mask,
int flg_suspend);
int remove_io_handler (ACE_HANDLE handle);
int remove_io_handler (ACE_Handle_Set &set);
int resume_io_handler (ACE_HANDLE handle);
int suspend_io_handler (ACE_HANDLE handle);
protected:
virtual int svc (void);
/// Should be initialized before reactor_
ACE_Select_Reactor select_reactor_;
ACE_Reactor reactor_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif /* ACE_ASYNCH_PSEUDO_TASK_H */
+26
View File
@@ -1,23 +1,31 @@
// $Id: Atomic_Op.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Atomic_Op.h"
#include "ace/OS_NS_unistd.h"
ACE_RCSID (ace,
Atomic_Op,
"$Id: Atomic_Op.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if !defined (__ACE_INLINE__)
#include "ace/Atomic_Op.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_HAS_BUILTIN_ATOMIC_OP)
#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC)
# include "ace/Atomic_Op_Sparc.h"
#endif /* ACE_INCLUDE_ATOMIC_OP_SPARC */
namespace {
#if defined (_MSC_VER)
// Disable "no return value" warning, as we will be putting
// the return values directly into the EAX register.
#pragma warning (push)
#pragma warning (disable: 4035)
#endif /* _MSC_VER */
long
single_cpu_increment (volatile long *value)
{
@@ -41,6 +49,7 @@ single_cpu_increment (volatile long *value)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
long
single_cpu_decrement (volatile long *value)
{
@@ -64,6 +73,7 @@ single_cpu_decrement (volatile long *value)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
long
single_cpu_exchange (volatile long *value, long rhs)
{
@@ -86,6 +96,7 @@ single_cpu_exchange (volatile long *value, long rhs)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
long
single_cpu_exchange_add (volatile long *value, long rhs)
{
@@ -127,6 +138,7 @@ single_cpu_exchange_add (volatile long *value, long rhs)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
long
multi_cpu_increment (volatile long *value)
{
@@ -144,6 +156,7 @@ multi_cpu_increment (volatile long *value)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
long
multi_cpu_decrement (volatile long *value)
{
@@ -161,6 +174,7 @@ multi_cpu_decrement (volatile long *value)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
long
multi_cpu_exchange (volatile long *value, long rhs)
{
@@ -179,6 +193,7 @@ multi_cpu_exchange (volatile long *value, long rhs)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
long
multi_cpu_exchange_add (volatile long *value, long rhs)
{
@@ -215,15 +230,20 @@ multi_cpu_exchange_add (volatile long *value, long rhs)
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_INTEL_ASSEMBLY*/
}
#if defined (_MSC_VER)
#pragma warning (pop)
#endif /* _MSC_VER */
} // end namespace
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::increment_fn_) (volatile long *) = multi_cpu_increment;
long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::decrement_fn_) (volatile long *) = multi_cpu_decrement;
long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange_fn_) (volatile long *, long) = multi_cpu_exchange;
long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add;
void
ACE_Atomic_Op<ACE_Thread_Mutex, long>::init_functions (void)
{
@@ -242,6 +262,7 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::init_functions (void)
exchange_add_fn_ = multi_cpu_exchange_add;
}
}
void
ACE_Atomic_Op<ACE_Thread_Mutex, long>::dump (void) const
{
@@ -250,10 +271,12 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::increment_fn_) (volatile long *) = multi_cpu_increment;
long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::decrement_fn_) (volatile long *) = multi_cpu_decrement;
long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::exchange_fn_) (volatile long *, long) = multi_cpu_exchange;
long (*ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add;
void
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::init_functions (void)
{
@@ -272,6 +295,7 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::init_functions (void)
exchange_add_fn_ = multi_cpu_exchange_add;
}
}
void
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::dump (void) const
{
@@ -280,6 +304,8 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */
+67
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Atomic_Op.h
@@ -8,16 +9,22 @@
* @author Douglas C. Schmidt <schmidt@uci.edu>
*/
//=============================================================================
#ifndef ACE_ATOMIC_OP_H
#define ACE_ATOMIC_OP_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Thread_Mutex.h"
// Include the templates here.
#include "ace/Atomic_Op_T.h"
// Determine whether builtin atomic op support is
// available on this platform.
#if defined (ACE_HAS_THREADS)
@@ -38,8 +45,11 @@
# define ACE_HAS_BUILTIN_ATOMIC_OP
# endif /* WIN32 */
#endif /* ACE_HAS_THREADS */
#if defined (ACE_HAS_BUILTIN_ATOMIC_OP)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Atomic_Op<ACE_Thread_Mutex, long>
*
@@ -55,63 +65,90 @@ class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, long>
public:
/// Initialize <value_> to 0.
ACE_Atomic_Op (void);
/// Initialize <value_> to c.
ACE_Atomic_Op (long c);
/// Manage copying...
ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, long> &c);
/// Atomically pre-increment <value_>.
long operator++ (void);
/// Atomically post-increment <value_>.
long operator++ (int);
/// Atomically increment <value_> by rhs.
long operator+= (long rhs);
/// Atomically pre-decrement <value_>.
long operator-- (void);
/// Atomically post-decrement <value_>.
long operator-- (int);
/// Atomically decrement <value_> by rhs.
long operator-= (long rhs);
/// Atomically compare <value_> with rhs.
bool operator== (long rhs) const;
/// Atomically compare <value_> with rhs.
bool operator!= (long rhs) const;
/// Atomically check if <value_> greater than or equal to rhs.
bool operator>= (long rhs) const;
/// Atomically check if <value_> greater than rhs.
bool operator> (long rhs) const;
/// Atomically check if <value_> less than or equal to rhs.
bool operator<= (long rhs) const;
/// Atomically check if <value_> less than rhs.
bool operator< (long rhs) const;
/// Atomically assign rhs to <value_>.
ACE_Atomic_Op<ACE_Thread_Mutex, long> &operator= (long rhs);
/// Atomically assign <rhs> to <value_>.
ACE_Atomic_Op<ACE_Thread_Mutex, long> &operator= (const ACE_Atomic_Op<ACE_Thread_Mutex, long> &rhs);
/// Explicitly return <value_>.
long value (void) const;
/// Dump the state of an object.
void dump (void) const;
/// Explicitly return <value_> (by reference).
volatile long &value_i (void);
// ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
/// Used during ACE object manager initialization to optimize the fast
/// atomic op implementation according to the number of CPUs.
static void init_functions (void);
private:
// This function cannot be supported by this template specialization.
// If you need access to an underlying lock, use the ACE_Atomic_Op_Ex
// template instead.
ACE_Thread_Mutex &mutex (void);
private:
/// Current object decorated by the atomic op.
volatile long value_;
// Pointers to selected atomic op implementations.
static long (*increment_fn_) (volatile long *);
static long (*decrement_fn_) (volatile long *);
static long (*exchange_fn_) (volatile long *, long);
static long (*exchange_add_fn_) (volatile long *, long);
};
/**
* @class ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>
*
@@ -127,68 +164,98 @@ class ACE_Export ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>
public:
/// Initialize <value_> to 0.
ACE_Atomic_Op (void);
/// Initialize <value_> to c.
ACE_Atomic_Op (unsigned long c);
/// Manage copying...
ACE_Atomic_Op (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &c);
/// Atomically pre-increment <value_>.
unsigned long operator++ (void);
/// Atomically post-increment <value_>.
unsigned long operator++ (int);
/// Atomically increment <value_> by rhs.
unsigned long operator+= (unsigned long rhs);
/// Atomically pre-decrement <value_>.
unsigned long operator-- (void);
/// Atomically post-decrement <value_>.
unsigned long operator-- (int);
/// Atomically decrement <value_> by rhs.
unsigned long operator-= (unsigned long rhs);
/// Atomically compare <value_> with rhs.
bool operator== (unsigned long rhs) const;
/// Atomically compare <value_> with rhs.
bool operator!= (unsigned long rhs) const;
/// Atomically check if <value_> greater than or equal to rhs.
bool operator>= (unsigned long rhs) const;
/// Atomically check if <value_> greater than rhs.
bool operator> (unsigned long rhs) const;
/// Atomically check if <value_> less than or equal to rhs.
bool operator<= (unsigned long rhs) const;
/// Atomically check if <value_> less than rhs.
bool operator< (unsigned long rhs) const;
/// Atomically assign rhs to <value_>.
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &operator= (unsigned long rhs);
/// Atomically assign <rhs> to <value_>.
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &operator= (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &rhs);
/// Explicitly return <value_>.
unsigned long value (void) const;
/// Dump the state of an object.
void dump (void) const;
/// Explicitly return <value_> (by reference).
volatile unsigned long &value_i (void);
// ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
/// Used during ACE object manager initialization to optimize the fast
/// atomic op implementation according to the number of CPUs.
static void init_functions (void);
private:
// This function cannot be supported by this template specialization.
// If you need access to an underlying lock, use the ACE_Atomic_Op_Ex
// template instead.
ACE_Thread_Mutex &mutex (void);
private:
/// Current object decorated by the atomic op.
volatile unsigned long value_;
// Pointers to selected atomic op implementations.
static long (*increment_fn_) (volatile long *);
static long (*decrement_fn_) (volatile long *);
static long (*exchange_fn_) (volatile long *, long);
static long (*exchange_add_fn_) (volatile long *, long);
};
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */
#if defined (__ACE_INLINE__)
#include "ace/Atomic_Op.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /*ACE_ATOMIC_OP_H*/
+44
View File
@@ -1,28 +1,36 @@
// -*- C++ -*-
//
// $Id: Atomic_Op.inl 80826 2008-03-04 14:51:23Z wotte $
#if defined (ACE_HAS_BUILTIN_ATOMIC_OP)
#if defined (ACE_HAS_INTRINSIC_INTERLOCKED)
# include "ace/os_include/os_intrin.h"
#pragma intrinsic (_InterlockedExchange, _InterlockedExchangeAdd, _InterlockedIncrement, _InterlockedDecrement)
#endif /* ACE_HAS_INTRINSIC_INTERLOCKED */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Atomic_Op<ACE_Thread_Mutex, long>::ACE_Atomic_Op (void)
: value_ (0)
{
}
ACE_INLINE
ACE_Atomic_Op<ACE_Thread_Mutex, long>::ACE_Atomic_Op (long c)
: value_ (c)
{
}
ACE_INLINE
ACE_Atomic_Op<ACE_Thread_Mutex, long>::ACE_Atomic_Op (
const ACE_Atomic_Op<ACE_Thread_Mutex, long> &rhs)
: value_ (rhs.value_)
{
}
ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator++ (void)
{
@@ -34,11 +42,13 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator++ (void)
return (*increment_fn_) (&this->value_);
#endif /* WIN32 */
}
ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator++ (int)
{
return ++*this - 1;
}
ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator-- (void)
{
@@ -50,11 +60,13 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator-- (void)
return (*decrement_fn_) (&this->value_);
#endif /* WIN32 */
}
ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator-- (int)
{
return --*this + 1;
}
ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator+= (long rhs)
{
@@ -68,6 +80,7 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator+= (long rhs)
return (*exchange_add_fn_) (&this->value_, rhs) + rhs;
#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */
}
ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator-= (long rhs)
{
@@ -81,36 +94,43 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator-= (long rhs)
return (*exchange_add_fn_) (&this->value_, -rhs) - rhs;
#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator== (long rhs) const
{
return (this->value_ == rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator!= (long rhs) const
{
return (this->value_ != rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator>= (long rhs) const
{
return (this->value_ >= rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator> (long rhs) const
{
return (this->value_ > rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator<= (long rhs) const
{
return (this->value_ <= rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator< (long rhs) const
{
return (this->value_ < rhs);
}
ACE_INLINE ACE_Atomic_Op<ACE_Thread_Mutex, long> &
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= (long rhs)
{
@@ -123,6 +143,7 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= (long rhs)
#endif /* WIN32 */
return *this;
}
ACE_INLINE ACE_Atomic_Op<ACE_Thread_Mutex, long> &
ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= (
const ACE_Atomic_Op<ACE_Thread_Mutex, long> &rhs)
@@ -136,33 +157,39 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= (
#endif /* WIN32 */
return *this;
}
ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::value (void) const
{
return this->value_;
}
ACE_INLINE volatile long &
ACE_Atomic_Op<ACE_Thread_Mutex, long>::value_i (void)
{
return this->value_;
}
ACE_INLINE
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::ACE_Atomic_Op (void)
: value_ (0)
{
}
ACE_INLINE
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::ACE_Atomic_Op (unsigned long c)
: value_ (c)
{
}
ACE_INLINE
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::ACE_Atomic_Op (
const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &rhs)
: value_ (rhs.value_)
{
}
ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator++ (void)
{
@@ -174,11 +201,13 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator++ (void)
return static_cast<unsigned long> ((*increment_fn_) (reinterpret_cast<volatile long *> (&this->value_)));
#endif /* WIN32 */
}
ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator++ (int)
{
return ++*this - 1;
}
ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator-- (void)
{
@@ -190,11 +219,13 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator-- (void)
return static_cast<unsigned long> ((*decrement_fn_) (reinterpret_cast<volatile long *> (&this->value_)));
#endif /* WIN32 */
}
ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator-- (int)
{
return --*this + 1;
}
ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator+= (unsigned long rhs)
{
@@ -208,6 +239,7 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator+= (unsigned long rhs)
return static_cast<unsigned long> ((*exchange_add_fn_) (reinterpret_cast<volatile long *> (&this->value_), rhs)) + rhs;
#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */
}
ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator-= (unsigned long rhs)
{
@@ -222,36 +254,43 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator-= (unsigned long rhs)
return static_cast<unsigned long> ((*exchange_add_fn_) (reinterpret_cast<volatile long *> (&this->value_), -l_rhs)) - rhs;
#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator== (unsigned long rhs) const
{
return (this->value_ == rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator!= (unsigned long rhs) const
{
return (this->value_ != rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator>= (unsigned long rhs) const
{
return (this->value_ >= rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator> (unsigned long rhs) const
{
return (this->value_ > rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator<= (unsigned long rhs) const
{
return (this->value_ <= rhs);
}
ACE_INLINE bool
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator< (unsigned long rhs) const
{
return (this->value_ < rhs);
}
ACE_INLINE ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator= (unsigned long rhs)
{
@@ -264,6 +303,7 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator= (unsigned long rhs)
#endif /* WIN32 */
return *this;
}
ACE_INLINE ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator= (
const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &rhs)
@@ -277,15 +317,19 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator= (
#endif /* WIN32 */
return *this;
}
ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::value (void) const
{
return this->value_;
}
ACE_INLINE volatile unsigned long &
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::value_i (void)
{
return this->value_;
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */
+18
View File
@@ -6,7 +6,9 @@
* Portions of this code are based on atomic operations found in the
* linux kernel source code.
*/
#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC)
#if defined(__i386) && defined(__SUNPRO_C)
static void
__sunpro_asm_code() {
@@ -21,6 +23,7 @@ ace_atomic_add_long: \n\
addl 0x00000008(%esp), %eax \n\
ret \n\
");
__asm("\n\
.globl ace_atomic_swap_long \n\
.type ace_atomic_swap_long,@function \n\
@@ -31,6 +34,7 @@ ace_atomic_swap_long: \n\
xchg %eax, (%edx) \n\
ret \n\
");
__asm("\n\
.globl ace_atomic_swap_add_long \n\
.type ace_atomic_swap_add_long,@function \n\
@@ -42,7 +46,9 @@ ace_atomic_swap_add_long: \n\
ret \n\
");
}
#elif defined(__x86_64) && defined(__SUNPRO_C)
static void
__sunpro_asm_code() {
__asm("\n\
@@ -55,6 +61,7 @@ ace_atomic_add_long: \n\
addq %rsi, %rax \n\
ret \n\
");
__asm("\n\
.globl ace_atomic_swap_long \n\
.type ace_atomic_swap_long,@function \n\
@@ -64,6 +71,7 @@ ace_atomic_swap_long: \n\
movq %rsi, %rax \n\
ret \n\
");
__asm("\n\
.globl ace_atomic_swap_add_long \n\
.type ace_atomic_swap_add_long,@function \n\
@@ -74,7 +82,9 @@ ace_atomic_swap_add_long: \n\
ret \n\
");
}
#elif defined (__sparcv9)
unsigned long
ace_atomic_add_long (volatile unsigned long *dest, long rhs)
{
@@ -89,6 +99,7 @@ ace_atomic_add_long (volatile unsigned long *dest, long rhs)
"retl\n"
"add %o2, %o1, %o0\n");
}
unsigned long
ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs)
{
@@ -103,6 +114,7 @@ ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs)
"retl\n"
"mov %o3, %o0\n");
}
unsigned long
ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs)
{
@@ -118,7 +130,9 @@ ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs)
"retl\n"
"mov %o4, %o0\n");
}
#else
unsigned long
ace_atomic_add_long (volatile unsigned long *dest, long rhs)
{
@@ -133,6 +147,7 @@ ace_atomic_add_long (volatile unsigned long *dest, long rhs)
"retl\n"
"add %o2, %o1, %o0\n");
}
unsigned long
ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs)
{
@@ -147,6 +162,7 @@ ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs)
"retl\n"
"mov %o3, %o0\n");
}
unsigned long
ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs)
{
@@ -162,7 +178,9 @@ ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs)
"retl\n"
"mov %o4, %o0\n");
}
# endif /* __sparcv9 */
#elif !defined (__GNUC__) && !defined (__INTEL_COMPILER)
/* Make compilers stop complaining about an empty translation unit */
static int shut_up_compiler = 0;
+3
View File
@@ -1,12 +1,15 @@
/* -*- C++ -*- */
// $Id: Atomic_Op_Sparc.h 80826 2008-03-04 14:51:23Z wotte $
#ifndef ACE_ATOMIC_OP_SPARC_H
#define ACE_ATOMIC_OP_SPARC_H
extern "C"
{
unsigned long ace_atomic_add_long (volatile unsigned long *dest, long rhs);
unsigned long ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs);
unsigned long ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs);
}
#endif /* ACE_ATOMIC_OP_SPARC_H */
+80
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Atomic_Op_T.h
@@ -8,69 +9,85 @@
* @author Douglas C. Schmidt <schmidt@uci.edu>
*/
//=============================================================================
#ifndef ACE_ATOMIC_OP_T_H
#define ACE_ATOMIC_OP_T_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template<typename TYPE>
struct ACE_Type_Traits
{
typedef TYPE const & parameter_type;
};
template<>
struct ACE_Type_Traits<bool>
{
typedef bool parameter_type;
};
template<>
struct ACE_Type_Traits<char>
{
typedef char parameter_type;
};
template<>
struct ACE_Type_Traits<signed char>
{
typedef signed char parameter_type;
};
template<>
struct ACE_Type_Traits<unsigned char>
{
typedef unsigned char parameter_type;
};
template<>
struct ACE_Type_Traits<short>
{
typedef short parameter_type;
};
template<>
struct ACE_Type_Traits<unsigned short>
{
typedef unsigned short parameter_type;
};
template<>
struct ACE_Type_Traits<int>
{
typedef int parameter_type;
};
template<>
struct ACE_Type_Traits<unsigned int>
{
typedef unsigned int parameter_type;
};
template<>
struct ACE_Type_Traits<long>
{
typedef long parameter_type;
};
template<>
struct ACE_Type_Traits<unsigned long>
{
typedef unsigned long parameter_type;
};
#ifndef ACE_LACKS_LONGLONG_T
template<>
struct ACE_Type_Traits<long long>
@@ -78,6 +95,7 @@ struct ACE_Type_Traits<long long>
typedef long long parameter_type;
};
#endif /* !ACE_LACKS_LONGLONG_T */
#if !defined (ACE_LACKS_LONGLONG_T) \
&& !defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
template<>
@@ -86,26 +104,31 @@ struct ACE_Type_Traits<unsigned long long>
typedef unsigned long long parameter_type;
};
#endif /* !ACE_LACKS_LONGLONG_T && !ACE_LACKS_UNSIGNEDLONGLONG_T */
template<>
struct ACE_Type_Traits<float>
{
typedef float parameter_type;
};
template<>
struct ACE_Type_Traits<double>
{
typedef double parameter_type;
};
template<>
struct ACE_Type_Traits<long double>
{
typedef long double parameter_type;
};
template<typename TYPE>
struct ACE_Type_Traits<TYPE*>
{
typedef TYPE* parameter_type;
};
/**
* @class ACE_Atomic_Op_Ex
*
@@ -128,50 +151,74 @@ template <class ACE_LOCK, typename TYPE>
class ACE_Atomic_Op_Ex
{
public:
typedef typename ACE_Type_Traits<TYPE>::parameter_type arg_type;
// = Initialization methods.
/// Initialize @c value_ to 0.
ACE_Atomic_Op_Ex (ACE_LOCK & mtx);
/// Initialize @c value_ to c.
ACE_Atomic_Op_Ex (ACE_LOCK & mtx, arg_type c);
// = Accessors.
/// Atomically pre-increment @c value_.
TYPE operator++ (void);
/// Atomically post-increment @c value_.
TYPE operator++ (int);
/// Atomically increment @c value_ by rhs.
TYPE operator+= (arg_type rhs);
/// Atomically pre-decrement @c value_.
TYPE operator-- (void);
/// Atomically post-decrement @c value_.
TYPE operator-- (int);
/// Atomically decrement @c value_ by rhs.
TYPE operator-= (arg_type rhs);
/// Atomically compare @c value_ with rhs.
bool operator== (arg_type rhs) const;
/// Atomically compare @c value_ with rhs.
bool operator!= (arg_type rhs) const;
/// Atomically check if @c value_ greater than or equal to rhs.
bool operator>= (arg_type rhs) const;
/// Atomically check if @c value_ greater than rhs.
bool operator> (arg_type rhs) const;
/// Atomically check if @c value_ less than or equal to rhs.
bool operator<= (arg_type rhs) const;
/// Atomically check if @c value_ less than rhs.
bool operator< (arg_type rhs) const;
/// Atomically assign rhs to @c value_.
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &operator= (arg_type rhs);
/// Atomically assign <rhs> to @c value_.
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &operator= (
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> const & rhs);
/// Explicitly return @c value_.
TYPE value (void) const;
/// Dump the state of an object.
void dump (void) const;
// ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
/// Manage copying...
ACE_Atomic_Op_Ex (ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> const &);
/**
* Returns a reference to the underlying <ACE_LOCK>. This makes it
* possible to acquire the lock explicitly, which can be useful in
@@ -180,6 +227,7 @@ public:
* name would be lock_, but HP/C++ will choke on that!
*/
ACE_LOCK & mutex (void);
/**
* Explicitly return @c value_ (by reference). This gives the user
* full, unrestricted access to the underlying value. This method
@@ -187,12 +235,15 @@ public:
* lock. Use with care ;-)
*/
TYPE & value_i (void);
private:
/// Type of synchronization mechanism.
ACE_LOCK & mutex_;
/// Current object decorated by the atomic op.
TYPE value_;
};
/**
* @class ACE_Atomic_Op
*
@@ -211,46 +262,67 @@ template <class ACE_LOCK, typename TYPE>
class ACE_Atomic_Op
{
public:
typedef typename ACE_Type_Traits<TYPE>::parameter_type arg_type;
/// Initialize @c value_ to 0.
ACE_Atomic_Op (void);
/// Initialize @c value_ to c.
ACE_Atomic_Op (arg_type c);
/// Manage copying...
ACE_Atomic_Op (ACE_Atomic_Op<ACE_LOCK, TYPE> const & c);
/// Atomically assign rhs to @c value_.
ACE_Atomic_Op<ACE_LOCK, TYPE> & operator= (arg_type rhs);
/// Atomically assign <rhs> to @c value_.
ACE_Atomic_Op<ACE_LOCK, TYPE> & operator= (
ACE_Atomic_Op<ACE_LOCK, TYPE> const & rhs);
/// Atomically pre-increment @c value_.
TYPE operator++ (void);
/// Atomically post-increment @c value_.
TYPE operator++ (int);
/// Atomically increment @c value_ by rhs.
TYPE operator+= (arg_type rhs);
/// Atomically pre-decrement @c value_.
TYPE operator-- (void);
/// Atomically post-decrement @c value_.
TYPE operator-- (int);
/// Atomically decrement @c value_ by rhs.
TYPE operator-= (arg_type rhs);
/// Atomically compare @c value_ with rhs.
bool operator== (arg_type rhs) const;
/// Atomically compare @c value_ with rhs.
bool operator!= (arg_type rhs) const;
/// Atomically check if @c value_ greater than or equal to rhs.
bool operator>= (arg_type rhs) const;
/// Atomically check if @c value_ greater than rhs.
bool operator> (arg_type rhs) const;
/// Atomically check if @c value_ less than or equal to rhs.
bool operator<= (arg_type rhs) const;
/// Atomically check if @c value_ less than rhs.
bool operator< (arg_type rhs) const;
/// Explicitly return @c value_.
TYPE value (void) const;
/// Dump the state of an object.
void dump (void) const;
/**
* Returns a reference to the underlying <ACE_LOCK>. This makes it
* possible to acquire the lock explicitly, which can be useful in
@@ -262,6 +334,7 @@ public:
* using the ACE_Atomic_Op_Ex template instead.
*/
ACE_LOCK & mutex (void);
/**
* Explicitly return @c value_ (by reference). This gives the user
* full, unrestricted access to the underlying value. This method
@@ -269,22 +342,29 @@ public:
* lock. Use with care ;-)
*/
TYPE & value_i (void);
private:
/// Type of synchronization mechanism.
ACE_LOCK own_mutex_;
/// Underlying atomic op implementation.
ACE_Atomic_Op_Ex <ACE_LOCK, TYPE> impl_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Atomic_Op_T.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Atomic_Op_T.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Atomic_Op_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /*ACE_ATOMIC_OP_T_H*/
+45
View File
@@ -1,12 +1,17 @@
// -*- C++ -*-
//
// $Id: Atomic_Op_T.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Guard_T.h"
#include <algorithm>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
//
// ACE_Atomic_Op_Ex inline functions
//
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ (void)
@@ -15,6 +20,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ (void)
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
return ++this->value_;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator+= (
@@ -24,6 +30,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator+= (
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
return this->value_ += rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- (void)
@@ -32,6 +39,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- (void)
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
return --this->value_;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-= (
@@ -41,6 +49,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-= (
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
return this->value_ -= rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex (
@@ -50,6 +59,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex (
{
// ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::ACE_Atomic_Op_Ex");
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ (int)
@@ -58,6 +68,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator++ (int)
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
return this->value_++;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- (int)
@@ -66,6 +77,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator-- (int)
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
return this->value_--;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator== (
@@ -75,6 +87,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator== (
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
return this->value_ == rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!= (
@@ -83,6 +96,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!= (
// ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator!=");
return !(*this == rhs);
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>= (
@@ -92,6 +106,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator>= (
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
return this->value_ >= rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator> (
@@ -101,6 +116,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator> (
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
return this->value_ > rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<= (
@@ -110,6 +126,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator<= (
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
return this->value_ <= rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator< (
@@ -119,17 +136,22 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator< (
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false);
return this->value_ < rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> const & rhs)
{
// ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator=");
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> tmp (rhs);
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this);
std::swap (this->value_, tmp.value_);
return *this;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value (void) const
@@ -138,6 +160,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value (void) const
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
return this->value_;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE &
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value_i (void)
@@ -148,6 +171,7 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value_i (void)
// lock. Use with care ;-)
return this->value_;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (
@@ -158,9 +182,11 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (
this->value_ = rhs;
return *this;
}
//
// ACE_Atomic_Op inline functions
//
template <class ACE_LOCK, class TYPE> ACE_INLINE
ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (
ACE_Atomic_Op<ACE_LOCK, TYPE> const & rhs)
@@ -169,6 +195,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (
// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op");
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE ACE_Atomic_Op<ACE_LOCK, TYPE> &
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (
@@ -177,6 +204,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (
this->impl_ = i;
return *this;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE ACE_Atomic_Op<ACE_LOCK, TYPE> &
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (
@@ -185,18 +213,21 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator= (
this->impl_ = rhs.impl_;
return *this;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator++ (void)
{
return ++this->impl_;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator++ (int)
{
return this->impl_++;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator+= (
@@ -204,18 +235,21 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator+= (
{
return this->impl_ += rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-- (void)
{
return --this->impl_;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-- (int)
{
return this->impl_--;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-= (
@@ -223,6 +257,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator-= (
{
return this->impl_ -= rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator== (
@@ -230,6 +265,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator== (
{
return this->impl_ == rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator!= (
@@ -237,6 +273,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator!= (
{
return this->impl_ != rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator>= (
@@ -244,6 +281,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator>= (
{
return this->impl_ >= rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator> (
@@ -251,6 +289,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator> (
{
return this->impl_ > rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator<= (
@@ -258,6 +297,7 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator<= (
{
return this->impl_ <= rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE bool
ACE_Atomic_Op<ACE_LOCK, TYPE>::operator< (
@@ -265,12 +305,14 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator< (
{
return this->impl_ < rhs;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::value (void) const
{
return this->impl_.value ();
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE void
ACE_Atomic_Op<ACE_LOCK, TYPE>::dump (void) const
@@ -280,16 +322,19 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::dump (void) const
#endif /* ACE_HAS_DUMP */
return;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE ACE_LOCK &
ACE_Atomic_Op<ACE_LOCK, TYPE>::mutex (void)
{
return this->own_mutex_;
}
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE &
ACE_Atomic_Op<ACE_LOCK, TYPE>::value_i (void)
{
return this->impl_.value_i ();
}
ACE_END_VERSIONED_NAMESPACE_DECL
+8
View File
@@ -1,12 +1,17 @@
// $Id: Auto_Event.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Auto_Event.h"
#if !defined (__ACE_INLINE__)
#include "ace/Auto_Event.inl"
#endif /* __ACE_INLINE__ */
ACE_RCSID (ace,
Auto_Event,
"$Id: Auto_Event.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Auto_Event::ACE_Auto_Event (int initial_state,
int type,
const char *name,
@@ -18,6 +23,7 @@ ACE_Auto_Event::ACE_Auto_Event (int initial_state,
arg)
{
}
#if defined (ACE_HAS_WCHAR)
ACE_Auto_Event::ACE_Auto_Event (int initial_state,
int type,
@@ -31,6 +37,7 @@ ACE_Auto_Event::ACE_Auto_Event (int initial_state,
{
}
#endif /* ACE_HAS_WCHAR */
void
ACE_Auto_Event::dump (void) const
{
@@ -38,5 +45,6 @@ ACE_Auto_Event::dump (void) const
ACE_Event::dump ();
#endif /* ACE_HAS_DUMP */
}
ACE_END_VERSIONED_NAMESPACE_DECL
+14
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//==========================================================================
/**
* @file Auto_Event.h
@@ -10,15 +11,21 @@
* @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
*/
//==========================================================================
#ifndef ACE_AUTO_EVENT_H
#define ACE_AUTO_EVENT_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Event.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Auto_Event
*
@@ -37,6 +44,7 @@ public:
int type = USYNC_THREAD,
const char *name = 0,
void *arg = 0);
#if defined (ACE_HAS_WCHAR)
/// Constructor which will create auto event (wchar_t version)
ACE_Auto_Event (int initial_state,
@@ -44,17 +52,23 @@ public:
const wchar_t *name,
void *arg = 0);
#endif /* ACE_HAS_WCHAR */
/// Default dtor.
~ACE_Auto_Event (void);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks
ACE_ALLOC_HOOK_DECLARE;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Auto_Event.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_AUTO_EVENT_H */
+3
View File
@@ -1,9 +1,12 @@
// -*- C++ -*-
//
// $Id: Auto_Event.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Auto_Event::~ACE_Auto_Event (void)
{
}
ACE_END_VERSIONED_NAMESPACE_DECL
+31
View File
@@ -11,12 +11,17 @@
#ifndef ACE_AUTO_FUNCTOR_H
#define ACE_AUTO_FUNCTOR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Global_Macros.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE_Utils
{
/**
@@ -30,8 +35,10 @@ struct Auto_Functor_Ref
{
X * p_;
Functor f_;
Auto_Functor_Ref(X * p, Functor f);
};
/**
* @class Auto_Functor
*
@@ -53,45 +60,69 @@ class Auto_Functor
public:
typedef X element_type;
typedef Functor functor_type;
/// Constructor
explicit Auto_Functor (X * p = 0,
Functor functor = Functor()); // throw()
Auto_Functor (Auto_Functor & rhs); // throw()
Auto_Functor<X,Functor>& operator= (Auto_Functor & rhs); // throw()
#if !defined(ACE_LACKS_MEMBER_TEMPLATES)
template<typename Y>
Auto_Functor(Auto_Functor<Y,Functor>& rhs); // throw()
template<typename Y>
Auto_Functor<X,Functor>& operator= (Auto_Functor<Y,Functor>& rhs); // throw()
#endif /* ACE_LACKS_MEMBER_TEMPLATES */
~Auto_Functor(); // throw()
X & operator*() const; // throw()
X * operator->() const; // throw()
X * get(); // throw()
X * release(); // throw()
void reset (X * p = 0); // throw()
void reset (X * p, Functor f); // throw()
Functor const & functor() const; // throw()
Auto_Functor(Auto_Functor_Ref<X,Functor> rhs); // throw()
Auto_Functor<X,Functor> & operator=(Auto_Functor_Ref<X,Functor> rhs); // throw()
#if !defined(ACE_LACKS_MEMBER_TEMPLATES)
template<typename Y> operator Auto_Functor_Ref<Y,Functor>(); // throw()
template<typename Y> operator Auto_Functor<Y,Functor>(); // throw()
#else
operator Auto_Functor_Ref<X,Functor>(); // throw()
#endif /* ACE_LACKS_MEMBER_TEMPLATES */
private:
X * p_;
Functor f_;
};
} // namespace ACE_Utils
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined(__ACE_INLINE__)
# include "ace/Auto_Functor.inl"
#endif /* __ACE_INLINE__ */
#if defined(ACE_TEMPLATES_REQUIRE_SOURCE)
# include "ace/Auto_Functor.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#include /**/ "ace/post.h"
#endif /* ACE_AUTO_FUNCTOR_H*/
+21
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: Auto_Functor.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template<typename X, typename Functor> ACE_INLINE
ACE_Utils::Auto_Functor_Ref<X,Functor>::
Auto_Functor_Ref(X * p, Functor f)
@@ -9,18 +11,21 @@ Auto_Functor_Ref(X * p, Functor f)
, f_(f)
{
}
template<typename X, typename Functor> ACE_INLINE
ACE_Utils::Auto_Functor<X,Functor>::Auto_Functor(X * p, Functor f)
: p_(p)
, f_(f)
{
}
template<typename X, typename Functor> ACE_INLINE
ACE_Utils::Auto_Functor<X,Functor>::Auto_Functor(Auto_Functor & rhs)
: p_(rhs.release())
, f_(rhs.f_)
{
}
template<typename X, typename Functor>
ACE_INLINE ACE_Utils::Auto_Functor<X,Functor>&
ACE_Utils::Auto_Functor<X,Functor>:: operator=(Auto_Functor & rhs)
@@ -29,6 +34,7 @@ ACE_Utils::Auto_Functor<X,Functor>:: operator=(Auto_Functor & rhs)
f_ = rhs.f_;
return *this;
}
#if !defined(ACE_LACKS_MEMBER_TEMPLATES)
template<typename X, typename Functor> template<typename Y> ACE_INLINE
ACE_Utils::Auto_Functor<X,Functor>::Auto_Functor(Auto_Functor<Y,Functor>& rhs)
@@ -36,6 +42,7 @@ ACE_Utils::Auto_Functor<X,Functor>::Auto_Functor(Auto_Functor<Y,Functor>& rhs)
, f_(rhs.f_)
{
}
template<typename X, typename Functor> template<typename Y>
ACE_INLINE ACE_Utils::Auto_Functor<X,Functor>&
ACE_Utils::Auto_Functor<X,Functor>::operator=(Auto_Functor<Y,Functor>& rhs)
@@ -44,23 +51,27 @@ ACE_Utils::Auto_Functor<X,Functor>::operator=(Auto_Functor<Y,Functor>& rhs)
return *this;
}
#endif /* ACE_LACKS_MEMBER_TEMPLATES */
template<typename X, typename Functor> ACE_INLINE X &
ACE_Utils::Auto_Functor<X,Functor>::operator*() const
{
return *p_;
}
template<typename X, typename Functor>
ACE_INLINE X *
ACE_Utils::Auto_Functor<X,Functor>::operator->() const
{
return p_;
}
template<typename X, typename Functor>
ACE_INLINE X *
ACE_Utils::Auto_Functor<X,Functor>::get()
{
return p_;
}
template<typename X, typename Functor>
ACE_INLINE X *
ACE_Utils::Auto_Functor<X,Functor>::release()
@@ -69,18 +80,21 @@ ACE_Utils::Auto_Functor<X,Functor>::release()
p_ = 0;
return tmp;
}
template<typename X, typename Functor>
ACE_INLINE Functor const &
ACE_Utils::Auto_Functor<X,Functor>::functor() const
{
return f_;
}
template<typename X, typename Functor> ACE_INLINE
ACE_Utils::Auto_Functor<X,Functor>::Auto_Functor(Auto_Functor_Ref<X,Functor> rhs)
: p_(rhs.p_)
, f_(rhs.f_)
{
}
template<typename X, typename Functor>
ACE_INLINE ACE_Utils::Auto_Functor<X,Functor> &
ACE_Utils::Auto_Functor<X,Functor>::operator=(Auto_Functor_Ref<X,Functor> rhs)
@@ -92,22 +106,29 @@ ACE_Utils::Auto_Functor<X,Functor>::operator=(Auto_Functor_Ref<X,Functor> rhs)
}
return *this;
}
#if !defined(ACE_LACKS_MEMBER_TEMPLATES)
template<typename X, typename Functor> template<typename Y> ACE_INLINE
ACE_Utils::Auto_Functor<X,Functor>::operator ACE_Utils::Auto_Functor_Ref<Y,Functor>()
{
return ACE_Utils::Auto_Functor_Ref<Y,Functor>(release(), f_);
}
template<typename X, typename Functor> template<typename Y> ACE_INLINE
ACE_Utils::Auto_Functor<X,Functor>::operator ACE_Utils::Auto_Functor<Y,Functor>()
{
return ACE_Utils::Auto_Functor<Y,Functor>(release(), f_);
}
#else
template<typename X, typename Functor>ACE_INLINE
ACE_Utils::Auto_Functor<X,Functor>::operator ACE_Utils::Auto_Functor_Ref<X,Functor>()
{
return ACE_Utils::Auto_Functor_Ref<X,Functor>(release(), f_);
}
#endif /* ACE_LACKS_MEMBER_TEMPLATES */
ACE_END_VERSIONED_NAMESPACE_DECL
+19
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Auto_IncDec_T.h
@@ -9,15 +10,22 @@
*/
//=============================================================================
#ifndef ACE_AUTO_INCDEC_T_H
#define ACE_AUTO_INCDEC_T_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Global_Macros.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Auto_IncDec
*
@@ -33,16 +41,21 @@ template <class ACE_SAFELY_INCREMENTABLE_DECREMENTABLE>
class ACE_Auto_IncDec
{
public:
/// Implicitly increment the counter.
ACE_Auto_IncDec (ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter);
/// Implicitly decrement the counter.
~ACE_Auto_IncDec (void);
/// Dump the state of an object.
void dump (void) const;
protected:
/// Reference to the <ACE_SAFELY_INCREMENTABLE_DECREMENTABLE> counter
/// we're incrementing/decrementing.
ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter_;
private:
// = Prevent assignment and initialization.
ACE_UNIMPLEMENTED_FUNC (void operator= (const
@@ -50,10 +63,13 @@ private:
ACE_UNIMPLEMENTED_FUNC (ACE_Auto_IncDec (const
ACE_Auto_IncDec<ACE_SAFELY_INCREMENTABLE_DECREMENTABLE> &))
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Auto_IncDec_T.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Auto_IncDec_T.cpp"
// On Win32 platforms, this code will be included as template source
@@ -65,9 +81,12 @@ ACE_END_VERSIONED_NAMESPACE_DECL
// specialization code. Also, the specialization code *must* be
// inlined or the compiler will ignore the specializations.
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Auto_IncDec_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_AUTO_INCDEC_T_H */
+6
View File
@@ -1,8 +1,11 @@
// -*- C++ -*-
//
// $Id: Auto_IncDec_T.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Implicitly and automatically increment the counter.
template <class ACE_SAFELY_INCREMENTABLE_DECREMENTABLE> ACE_INLINE
ACE_Auto_IncDec<ACE_SAFELY_INCREMENTABLE_DECREMENTABLE>::ACE_Auto_IncDec
(ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter)
@@ -10,10 +13,13 @@ ACE_Auto_IncDec<ACE_SAFELY_INCREMENTABLE_DECREMENTABLE>::ACE_Auto_IncDec
{
++this->counter_;
}
// Implicitly and automatically decrement the counter.
template <class ACE_SAFELY_INCREMENTABLE_DECREMENTABLE> ACE_INLINE
ACE_Auto_IncDec<ACE_SAFELY_INCREMENTABLE_DECREMENTABLE>::~ACE_Auto_IncDec (void)
{
--this->counter_;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+41
View File
@@ -1,4 +1,5 @@
/* -*- C++ -*- */
//=============================================================================
/**
* @file Auto_Ptr.h
@@ -11,13 +12,17 @@
* @author Dr. Harald M. Mueller <mueller@garwein.hai.siemens.co.at>
*/
//=============================================================================
#ifndef ACE_AUTO_PTR_H
#define ACE_AUTO_PTR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (_MSC_VER)
// Suppress warning e.g. "return type for
// 'ACE_Auto_Array_Pointer<type>::operator ->' is 'type *' (i.e., not a UDT
@@ -27,7 +32,9 @@
# pragma warning(disable: 4284)
#endif /* _MSC_VER */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Auto_Basic_Ptr
*
@@ -39,24 +46,32 @@ class ACE_Auto_Basic_Ptr
{
public:
typedef X element_type;
// = Initialization and termination methods
explicit ACE_Auto_Basic_Ptr (X * p = 0) : p_ (p) {}
ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr<X> & ap);
ACE_Auto_Basic_Ptr<X> &operator= (ACE_Auto_Basic_Ptr<X> & rhs);
~ACE_Auto_Basic_Ptr (void);
// = Accessor methods.
X &operator *() const;
X *get (void) const;
X *release (void);
void reset (X * p = 0);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
X *p_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if !defined (ACE_LACKS_AUTO_PTR) && \
defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \
(ACE_HAS_STANDARD_CPP_LIBRARY != 0)
@@ -66,6 +81,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
using std::auto_ptr;
#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
#else /* ACE_HAS_STANDARD_CPP_LIBRARY */
/**
* @class auto_ptr
*
@@ -76,13 +92,18 @@ class auto_ptr : public ACE_Auto_Basic_Ptr<X>
{
public:
typedef X element_type;
// = Initialization and termination methods
explicit auto_ptr (X * p = 0) : ACE_Auto_Basic_Ptr<X> (p) {}
auto_ptr (auto_ptr<X> & ap) : ACE_Auto_Basic_Ptr<X> (ap.release ()) {}
X *operator-> () const;
};
#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @brief Implements the draft C++ standard auto_ptr abstraction.
* This version can be used instead of auto_ptr<T>, and obviates
@@ -94,10 +115,13 @@ class ACE_Auto_Ptr : public ACE_Auto_Basic_Ptr <X>
{
public:
typedef X element_type;
// = Initialization and termination methods
explicit ACE_Auto_Ptr (X * p = 0) : ACE_Auto_Basic_Ptr<X> (p) {}
X *operator-> () const;
};
/**
* @class ACE_Auto_Basic_Array_Ptr
*
@@ -111,24 +135,31 @@ class ACE_Auto_Basic_Array_Ptr
{
public:
typedef X element_type;
// = Initialization and termination methods.
explicit ACE_Auto_Basic_Array_Ptr (X * p = 0) : p_ (p) {}
ACE_Auto_Basic_Array_Ptr (ACE_Auto_Basic_Array_Ptr<X> & ap);
ACE_Auto_Basic_Array_Ptr<X> &operator= (ACE_Auto_Basic_Array_Ptr<X> & rhs);
~ACE_Auto_Basic_Array_Ptr (void);
// = Accessor methods.
X & operator* () const;
X & operator[] (int i) const;
X * get (void) const;
X * release (void);
void reset (X * p = 0);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
X * p_;
};
/**
* @class ACE_Auto_Array_Ptr
*
@@ -140,12 +171,15 @@ class ACE_Auto_Array_Ptr : public ACE_Auto_Basic_Array_Ptr<X>
{
public:
typedef X element_type;
// = Initialization and termination methods.
explicit ACE_Auto_Array_Ptr (X *p = 0)
: ACE_Auto_Basic_Array_Ptr<X> (p) {}
X *operator-> () const;
};
/**
* @brief Reset given @c auto_ptr element to new element.
*
@@ -172,7 +206,9 @@ ACE_auto_ptr_reset (AUTO_PTR_TYPE & ap,
ap.reset (p);
#endif /* ACE_AUTO_PTR_LACKS_RESET */
}
ACE_END_VERSIONED_NAMESPACE_DECL
// Some platforms have an older version of auto_ptr
// support, which lacks reset, and cannot be disabled
// easily. Portability to these platforms requires
@@ -184,19 +220,24 @@ ACE_END_VERSIONED_NAMESPACE_DECL
// ACE_AUTO_PTR_RESET.
# define ACE_AUTO_PTR_RESET(AUTOPTR,NEWPTR,TYPE) \
ACE_auto_ptr_reset (AUTOPTR, NEWPTR);
#if defined (__ACE_INLINE__)
#include "ace/Auto_Ptr.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Auto_Ptr.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Auto_Ptr.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#if defined (_MSC_VER)
// Restore the warning state to what it was before entry.
# pragma warning(pop)
#endif /* _MSC_VER */
#include /**/ "ace/post.h"
#endif /* ACE_AUTO_PTR_H */
+25
View File
@@ -1,8 +1,11 @@
// -*- C++ -*-
//
// $Id: Auto_Ptr.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Global_Macros.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template<class X> ACE_INLINE void
ACE_Auto_Basic_Ptr<X>::dump (void) const
{
@@ -10,6 +13,7 @@ ACE_Auto_Basic_Ptr<X>::dump (void) const
ACE_TRACE ("ACE_Auto_Basic_Ptr<X>::dump");
#endif /* ACE_HAS_DUMP */
}
template<class X> ACE_INLINE void
ACE_Auto_Basic_Array_Ptr<X>::dump (void) const
{
@@ -17,18 +21,21 @@ ACE_Auto_Basic_Array_Ptr<X>::dump (void) const
ACE_TRACE ("ACE_Auto_Basic_Array_Ptr<X>::dump");
#endif /* ACE_HAS_DUMP */
}
template<class X> ACE_INLINE
ACE_Auto_Basic_Ptr<X>::ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr<X> &rhs)
: p_ (rhs.release ())
{
ACE_TRACE ("ACE_Auto_Basic_Ptr<X>::ACE_Auto_Basic_Ptr");
}
template<class X> ACE_INLINE X *
ACE_Auto_Basic_Ptr<X>::get (void) const
{
ACE_TRACE ("ACE_Auto_Basic_Ptr<X>::get");
return this->p_;
}
template<class X> ACE_INLINE X *
ACE_Auto_Basic_Ptr<X>::release (void)
{
@@ -37,6 +44,7 @@ ACE_Auto_Basic_Ptr<X>::release (void)
this->p_ = 0;
return old;
}
template<class X> ACE_INLINE void
ACE_Auto_Basic_Ptr<X>::reset (X *p)
{
@@ -45,6 +53,7 @@ ACE_Auto_Basic_Ptr<X>::reset (X *p)
delete this->get ();
this->p_ = p;
}
template<class X> ACE_INLINE ACE_Auto_Basic_Ptr<X> &
ACE_Auto_Basic_Ptr<X>::operator= (ACE_Auto_Basic_Ptr<X> &rhs)
{
@@ -55,40 +64,48 @@ ACE_Auto_Basic_Ptr<X>::operator= (ACE_Auto_Basic_Ptr<X> &rhs)
}
return *this;
}
template<class X> ACE_INLINE
ACE_Auto_Basic_Ptr<X>::~ACE_Auto_Basic_Ptr (void)
{
ACE_TRACE ("ACE_Auto_Basic_Ptr<X>::~ACE_Auto_Basic_Ptr");
delete this->get ();
}
template<class X> ACE_INLINE X &
ACE_Auto_Basic_Ptr<X>::operator *() const
{
ACE_TRACE ("ACE_Auto_Basic_Ptr<X>::operator *()");
return *this->get ();
}
#if defined (ACE_LACKS_AUTO_PTR) || \
!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
(ACE_HAS_STANDARD_CPP_LIBRARY == 0)
template<class X> ACE_INLINE X *
auto_ptr<X>::operator-> () const
{
ACE_TRACE ("auto_ptr<X>::operator->");
return this->get ();
}
#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */
template<class X> ACE_INLINE X *
ACE_Auto_Ptr<X>::operator-> () const
{
ACE_TRACE ("ACE_Auto_Ptr<X>::operator->");
return this->get ();
}
template<class X> ACE_INLINE X *
ACE_Auto_Basic_Array_Ptr<X>::get (void) const
{
ACE_TRACE ("ACE_Auto_Basic_Array_Ptr<X>::get");
return this->p_;
}
template<class X> ACE_INLINE X *
ACE_Auto_Basic_Array_Ptr<X>::release (void)
{
@@ -97,6 +114,7 @@ ACE_Auto_Basic_Array_Ptr<X>::release (void)
this->p_ = 0;
return old;
}
template<class X> ACE_INLINE void
ACE_Auto_Basic_Array_Ptr<X>::reset (X *p)
{
@@ -105,12 +123,14 @@ ACE_Auto_Basic_Array_Ptr<X>::reset (X *p)
delete [] this->get ();
this->p_ = p;
}
template<class X> ACE_INLINE
ACE_Auto_Basic_Array_Ptr<X>::ACE_Auto_Basic_Array_Ptr (ACE_Auto_Basic_Array_Ptr<X> &rhs)
: p_ (rhs.release ())
{
ACE_TRACE ("ACE_Auto_Basic_Array_Ptr<X>::ACE_Auto_Basic_Array_Ptr");
}
template<class X> ACE_INLINE ACE_Auto_Basic_Array_Ptr<X> &
ACE_Auto_Basic_Array_Ptr<X>::operator= (ACE_Auto_Basic_Array_Ptr<X> &rhs)
{
@@ -121,26 +141,31 @@ ACE_Auto_Basic_Array_Ptr<X>::operator= (ACE_Auto_Basic_Array_Ptr<X> &rhs)
}
return *this;
}
template<class X> ACE_INLINE
ACE_Auto_Basic_Array_Ptr<X>::~ACE_Auto_Basic_Array_Ptr (void)
{
ACE_TRACE ("ACE_Auto_Basic_Array_Ptr<X>::~ACE_Auto_Basic_Array_Ptr");
delete [] this->get ();
}
template<class X> ACE_INLINE X &
ACE_Auto_Basic_Array_Ptr<X>::operator *() const
{
return *this->get ();
}
template<class X> ACE_INLINE X &
ACE_Auto_Basic_Array_Ptr<X>::operator[](int i) const
{
X *array = this->get ();
return array[i];
}
template<class X> ACE_INLINE X *
ACE_Auto_Array_Ptr<X>::operator->() const
{
return this->get ();
}
ACE_END_VERSIONED_NAMESPACE_DECL
+36
View File
@@ -1,24 +1,34 @@
// $Id: Barrier.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Barrier.h"
#if defined (ACE_HAS_THREADS)
#if !defined (__ACE_INLINE__)
#include "ace/Barrier.inl"
#endif /* __ACE_INLINE__ */
#include "ace/Guard_T.h"
#include "ace/OS_NS_errno.h"
#if defined (ACE_HAS_DUMP)
# include "ace/Log_Msg.h"
#endif /* ACE_HAS_DUMP */
ACE_RCSID (ace,
Barrier,
"$Id: Barrier.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_Sub_Barrier)
void
ACE_Sub_Barrier::dump (void) const
{
#if defined (ACE_HAS_DUMP)
// ACE_TRACE ("ACE_Sub_Barrier::dump");
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
this->barrier_finished_.dump ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("running_threads_ = %d"), this->running_threads_));
@@ -26,6 +36,7 @@ ACE_Sub_Barrier::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
ACE_Sub_Barrier::ACE_Sub_Barrier (unsigned int count,
ACE_Thread_Mutex &lock,
const ACE_TCHAR *name,
@@ -35,12 +46,15 @@ ACE_Sub_Barrier::ACE_Sub_Barrier (unsigned int count,
{
// ACE_TRACE ("ACE_Sub_Barrier::ACE_Sub_Barrier");
}
ACE_ALLOC_HOOK_DEFINE(ACE_Barrier)
void
ACE_Barrier::dump (void) const
{
#if defined (ACE_HAS_DUMP)
// ACE_TRACE ("ACE_Barrier::dump");
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
this->lock_.dump ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_generation_ = %d"), this->current_generation_));
@@ -50,6 +64,7 @@ ACE_Barrier::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
ACE_Barrier::ACE_Barrier (unsigned int count,
const ACE_TCHAR *name,
void *arg)
@@ -63,20 +78,25 @@ ACE_Barrier::ACE_Barrier (unsigned int count,
this->sub_barrier_[0] = &this->sub_barrier_1_;
this->sub_barrier_[1] = &this->sub_barrier_2_;
}
int
ACE_Barrier::wait (void)
{
ACE_TRACE ("ACE_Barrier::wait");
ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
ACE_Sub_Barrier *sbp =
this->sub_barrier_[this->current_generation_];
// Check for shutdown...
if (sbp == 0)
{
errno = ESHUTDOWN;
return -1;
}
int retval = 0;
if (sbp->running_threads_ == 1)
{
// We're the last running thread, so swap generations and tell
@@ -90,9 +110,11 @@ ACE_Barrier::wait (void)
else
{
--sbp->running_threads_;
// Block until all the other threads wait().
while (sbp->running_threads_ != this->count_)
sbp->barrier_finished_.wait ();
// We're awake and the count has completed. See if it completed
// because all threads hit the barrier, or because the barrier
// was shut down.
@@ -102,36 +124,45 @@ ACE_Barrier::wait (void)
retval = -1;
}
}
return retval;
}
int
ACE_Barrier::shutdown (void)
{
ACE_TRACE ("ACE_Barrier::shutdown");
ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
ACE_Sub_Barrier *sbp =
this->sub_barrier_[this->current_generation_];
// Check for shutdown...
if (sbp == 0)
{
errno = ESHUTDOWN;
return -1;
}
// Flag the shutdown
this->sub_barrier_[0] = 0;
this->sub_barrier_[1] = 0;
// Tell all the threads waiting on the barrier to continue on their way.
sbp->running_threads_ = this->count_;
sbp->barrier_finished_.broadcast ();
return 0;
}
ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Barrier)
ACE_Thread_Barrier::ACE_Thread_Barrier (unsigned int count,
const ACE_TCHAR *name)
: ACE_Barrier (count, name)
{
// ACE_TRACE ("ACE_Thread_Barrier::ACE_Thread_Barrier");
}
void
ACE_Thread_Barrier::dump (void) const
{
@@ -140,14 +171,17 @@ ACE_Thread_Barrier::dump (void) const
ACE_Barrier::dump ();
#endif /* ACE_HAS_DUMP */
}
#if 0
ACE_ALLOC_HOOK_DEFINE(ACE_Process_Barrier)
ACE_Process_Barrier::ACE_Process_Barrier (u_int count,
const ACE_TCHAR *name)
: ACE_Barrier (count, USYNC_PROCESS, name)
{
// ACE_TRACE ("ACE_Process_Barrier::ACE_Process_Barrier");
}
void
ACE_Process_Barrier::dump (void) const
{
@@ -157,6 +191,8 @@ ACE_Process_Barrier::dump (void) const
#endif /* ACE_HAS_DUMP */
}
#endif /* 0 */
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_THREADS */
+41
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//==========================================================================
/**
* @file Barrier.h
@@ -10,18 +11,26 @@
* @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
*/
//==========================================================================
#ifndef ACE_BARRIER_H
#define ACE_BARRIER_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include /**/ "ace/config-all.h"
// ACE platform supports some form of threading.
#if !defined (ACE_HAS_THREADS)
#include "ace/OS_NS_errno.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Barrier
*
@@ -35,10 +44,15 @@ public:
int wait (void) { ACE_NOTSUP_RETURN (-1); }
void dump (void) const {}
};
ACE_END_VERSIONED_NAMESPACE_DECL
#else /* ACE_HAS_THREADS */
#include "ace/Condition_Thread_Mutex.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
struct ACE_Export ACE_Sub_Barrier
{
// = Initialization.
@@ -46,16 +60,22 @@ struct ACE_Export ACE_Sub_Barrier
ACE_Thread_Mutex &lock,
const ACE_TCHAR *name = 0,
void *arg = 0);
~ACE_Sub_Barrier (void);
/// True if this generation of the barrier is done.
ACE_Condition_Thread_Mutex barrier_finished_;
/// Number of threads that are still running.
int running_threads_;
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
};
/**
* @class ACE_Barrier
*
@@ -80,8 +100,10 @@ public:
ACE_Barrier (unsigned int count,
const ACE_TCHAR *name = 0,
void *arg = 0);
/// Default dtor.
~ACE_Barrier (void);
/// Block the caller until all @c count threads have called @c wait and
/// then allow all the caller threads to continue in parallel.
///
@@ -89,6 +111,7 @@ public:
/// @retval -1 if an error occurs or the barrier is shut
/// down (@sa shutdown ()).
int wait (void);
/// Shut the barrier down, aborting the wait of all waiting threads.
/// Any threads waiting on the barrier when it is shut down will return with
/// value -1, errno ESHUTDOWN.
@@ -97,18 +120,24 @@ public:
///
/// @since ACE beta 5.4.9.
int shutdown (void);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
protected:
/// Serialize access to the barrier state.
ACE_Thread_Mutex lock_;
/// Either 0 or 1, depending on whether we are the first generation
/// of waiters or the next generation of waiters.
int current_generation_;
/// Total number of threads that can be waiting at any one time.
int count_;
/**
* We keep two @c sub_barriers, one for the first "generation" of
* waiters, and one for the next "generation" of waiters. This
@@ -120,11 +149,13 @@ protected:
ACE_Sub_Barrier sub_barrier_1_;
ACE_Sub_Barrier sub_barrier_2_;
ACE_Sub_Barrier *sub_barrier_[2];
private:
// = Prevent assignment and initialization.
void operator= (const ACE_Barrier &);
ACE_Barrier (const ACE_Barrier &);
};
#if 0
/**
* @class ACE_Process_Barrier
@@ -139,12 +170,15 @@ class ACE_Export ACE_Process_Barrier : public ACE_Barrier
public:
/// Create a Process_Barrier, passing in the optional @a name.
ACE_Process_Barrier (unsigned int count, const ACE_TCHAR *name = 0);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
};
#endif /* 0 */
/**
* @class ACE_Thread_Barrier
*
@@ -158,18 +192,25 @@ class ACE_Export ACE_Thread_Barrier : public ACE_Barrier
public:
/// Create a Thread_Barrier, passing in the optional @a name.
ACE_Thread_Barrier (unsigned int count, const ACE_TCHAR *name = 0);
/// Default dtor.
~ACE_Thread_Barrier (void);
/// Dump the state of an object.
void dump (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Barrier.inl"
#endif /* __ACE_INLINE__ */
#endif /* !ACE_HAS_THREADS */
#include /**/ "ace/post.h"
#endif /* ACE_BARRIER_H */
+5
View File
@@ -1,17 +1,22 @@
// -*- C++ -*-
//
// $Id: Barrier.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Sub_Barrier::~ACE_Sub_Barrier (void)
{
}
ACE_INLINE
ACE_Barrier::~ACE_Barrier (void)
{
}
ACE_INLINE
ACE_Thread_Barrier::~ACE_Thread_Barrier (void)
{
}
ACE_END_VERSIONED_NAMESPACE_DECL
@@ -1,21 +1,29 @@
// $Id: Base_Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $
#include "ace/Base_Thread_Adapter.h"
ACE_RCSID (ace,
Base_Thread_Adapter,
"$Id: Base_Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $")
#if !defined (ACE_HAS_INLINED_OSCALLS)
# include "ace/Base_Thread_Adapter.inl"
#endif /* ACE_HAS_INLINED_OSCALLS */
#if defined (ACE_HAS_TSS_EMULATION)
# include "ace/OS_NS_Thread.h"
#endif /* ACE_HAS_TSS_EMULATION */
#include "ace/Service_Config.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0;
ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0;
ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0;
ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0;
ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0;
ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
ACE_THR_FUNC user_func,
void *arg,
@@ -33,6 +41,7 @@ ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
, ctx_ (ACE_Service_Config::current())
{
ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter");
if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0)
(*ACE_Base_Thread_Adapter::init_log_msg_hook_) (
this->log_msg_attributes_
@@ -45,9 +54,11 @@ ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
getitimer (ITIMER_PROF, &itimer_);
#endif // ACE_USES_GPROF
}
ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void)
{
}
void
ACE_Base_Thread_Adapter::inherit_log_msg (void)
{
@@ -55,23 +66,27 @@ ACE_Base_Thread_Adapter::inherit_log_msg (void)
(*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)(
this->thr_desc_,
this->log_msg_attributes_);
// Initialize the proper configuration context for the new thread
// Placed here since inherit_log_msg() gets called from any of our
// descendants (before self-destructing)
ACE_Service_Config::current (this->ctx_);
}
void
ACE_Base_Thread_Adapter::close_log_msg (void)
{
if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
(*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
}
void
ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg)
{
if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
(*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
}
ACE_OS_Thread_Descriptor *
ACE_Base_Thread_Adapter::thr_desc_log_msg (void)
{
@@ -79,13 +94,17 @@ ACE_Base_Thread_Adapter::thr_desc_log_msg (void)
return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) ();
return 0;
}
ACE_END_VERSIONED_NAMESPACE_DECL
// Run the thread entry point for the <ACE_Thread_Adapter>. This must
// be an extern "C" to make certain compilers happy...
extern "C" ACE_THR_FUNC_RETURN
ACE_THREAD_ADAPTER_NAME (void *args)
{
ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME");
#if defined (ACE_HAS_TSS_EMULATION)
// As early as we can in the execution of the new thread, allocate
// its local TS storage. Allocate it on the stack, to save dynamic
@@ -93,13 +112,18 @@ ACE_THREAD_ADAPTER_NAME (void *args)
void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
ACE_TSS_Emulation::tss_open (ts_storage);
#endif /* ACE_HAS_TSS_EMULATION */
ACE_Base_Thread_Adapter * const thread_args =
static_cast<ACE_Base_Thread_Adapter *> (args);
#ifdef ACE_USES_GPROF
setitimer (ITIMER_PROF, thread_args->timerval (), 0);
#endif // ACE_USES_GPROF
// Invoke the user-supplied function with the args.
ACE_THR_FUNC_RETURN status = thread_args->invoke ();
return status;
}
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Base_Thread_Adapter.h
@@ -8,27 +9,37 @@
* @author Nanbor Wang <nanbor@cs.wustl.edu>
*/
//=============================================================================
#ifndef ACE_BASE_THREAD_ADAPTER_H
#define ACE_BASE_THREAD_ADAPTER_H
#include /**/ "ace/pre.h"
#include "ace/OS_Log_Msg_Attributes.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include /**/ "ace/ACE_export.h"
#include "ace/OS_Log_Msg_Attributes.h"
#ifdef ACE_USES_GPROF
#include "os_include/sys/os_time.h"
#endif // ACE_USES_GPROF
#if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1)
# define ACE_THREAD_ADAPTER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_thread_adapter)
#else
# define ACE_THREAD_ADAPTER_NAME ace_thread_adapter
#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
// Run the thread entry point for the ACE_Thread_Adapter. This must
// be an extern "C" to make certain compilers happy...
extern "C" ACE_Export ACE_THR_FUNC_RETURN ACE_THREAD_ADAPTER_NAME (void *args);
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_OS_Thread_Descriptor
*
@@ -42,9 +53,11 @@ class ACE_Export ACE_OS_Thread_Descriptor
public:
/// Get the thread creation flags.
long flags (void) const;
protected:
/// For use by ACE_Thread_Descriptor.
ACE_OS_Thread_Descriptor (long flags = 0);
/**
* Keeps track of whether this thread was created "detached" or not.
* If a thread is *not* created detached then if someone calls
@@ -54,8 +67,11 @@ protected:
long flags_;
};
class ACE_Service_Gestalt;
/**
* @class ACE_Base_Thread_Adapter
*
@@ -75,23 +91,31 @@ class ACE_Service_Gestalt;
class ACE_Export ACE_Base_Thread_Adapter
{
public:
virtual ~ACE_Base_Thread_Adapter (void);
/// Virtual method invoked by the thread entry point.
virtual ACE_THR_FUNC_RETURN invoke (void) = 0;
/// Accessor for the C entry point function to the OS thread creation
/// routine.
ACE_THR_C_FUNC entry_point (void);
#ifdef ACE_USES_GPROF
/// Accessor to the itimer_
/// followed http://sam.zoy.org/writings/programming/gprof.html
struct itimerval* timerval (void);
#endif // ACE_USES_PROF
/// Invoke the close_log_msg_hook, if it is present
static void close_log_msg (void);
/// Invoke the sync_log_msg_hook, if it is present
static void sync_log_msg (const ACE_TCHAR *prog_name);
/// Invoke the thr_desc_log_msg_hook, if it is present
static ACE_OS_Thread_Descriptor *thr_desc_log_msg (void);
protected:
/// Constructor.
ACE_Base_Thread_Adapter (ACE_THR_FUNC user_func,
@@ -106,6 +130,7 @@ protected:
/// Inherit the logging features if the parent thread has an
/// ACE_Log_Msg.
void inherit_log_msg (void);
private:
/// The hooks to inherit and cleanup the Log_Msg attributes
static ACE_INIT_LOG_MSG_HOOK init_log_msg_hook_;
@@ -113,22 +138,28 @@ private:
static ACE_CLOSE_LOG_MSG_HOOK close_log_msg_hook_;
static ACE_SYNC_LOG_MSG_HOOK sync_log_msg_hook_;
static ACE_THR_DESC_LOG_MSG_HOOK thr_desc_log_msg_hook_;
/// Set the Log_Msg hooks
static void set_log_msg_hooks (ACE_INIT_LOG_MSG_HOOK init_hook,
ACE_INHERIT_LOG_MSG_HOOK inherit_hook,
ACE_CLOSE_LOG_MSG_HOOK close_hook,
ACE_SYNC_LOG_MSG_HOOK sync_hook,
ACE_THR_DESC_LOG_MSG_HOOK thr_desc);
/// Allow the ACE_Log_Msg class to set its hooks.
friend class ACE_Log_Msg;
protected:
/// Thread startup function passed in by the user (C++ linkage).
ACE_THR_FUNC user_func_;
/// Argument to thread startup function.
void *arg_;
/// Entry point to the underlying OS thread creation call (C
/// linkage).
ACE_THR_C_FUNC entry_point_;
/**
* Optional thread descriptor. Passing this pointer in will force
* the spawned thread to cache this location in <Log_Msg> and wait
@@ -136,17 +167,22 @@ protected:
* descriptor.
*/
ACE_OS_Thread_Descriptor *thr_desc_;
/// The ACE_Log_Msg attributes.
ACE_OS_Log_Msg_Attributes log_msg_attributes_;
/// That is usefull for gprof, define itimerval
#ifdef ACE_USES_GPROF
struct itimerval itimer_;
#endif // ACE_USES_GPROF
/// Keep a reference to the configuration context that spawns the
/// thread so the child can inherit it.
ACE_Service_Gestalt * const ctx_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
# if defined (ACE_HAS_INLINED_OSCALLS)
# if defined (ACE_INLINE)
# undef ACE_INLINE
@@ -154,6 +190,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_INLINE inline
# include "ace/Base_Thread_Adapter.inl"
# endif /* ACE_HAS_INLINED_OSCALLS */
#include /**/ "ace/post.h"
#endif /* ACE_BASE_THREAD_ADAPTER_H */
@@ -1,17 +1,21 @@
// -*- C++ -*-
//
// $Id: Base_Thread_Adapter.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE long
ACE_OS_Thread_Descriptor::flags (void) const
{
return flags_;
}
ACE_INLINE
ACE_OS_Thread_Descriptor::ACE_OS_Thread_Descriptor (long flags)
: flags_ (flags)
{
}
ACE_INLINE void
ACE_Base_Thread_Adapter::set_log_msg_hooks (
ACE_INIT_LOG_MSG_HOOK init_hook,
@@ -26,11 +30,13 @@ ACE_Base_Thread_Adapter::set_log_msg_hooks (
ACE_Base_Thread_Adapter::sync_log_msg_hook_ = sync_hook;
ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = thr_desc_hook;
}
ACE_INLINE ACE_THR_C_FUNC
ACE_Base_Thread_Adapter::entry_point (void)
{
return this->entry_point_;
}
#ifdef ACE_USES_GPROF
ACE_INLINE itimerval*
ACE_Base_Thread_Adapter::timerval (void)
@@ -38,4 +44,5 @@ ACE_Base_Thread_Adapter::timerval (void)
return &(this->itimer_);
}
#endif // ACE_USES_GPROF
ACE_END_VERSIONED_NAMESPACE_DECL
@@ -1,11 +1,14 @@
// $Id: Based_Pointer_Repository.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Map_Manager.h"
#include "ace/Based_Pointer_Repository.h"
#include "ace/Guard_T.h"
#include "ace/Null_Mutex.h"
#include "ace/Synch_Traits.h"
#include "ace/RW_Thread_Mutex.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Based_Pointer_Repository_Rep
*
@@ -22,30 +25,37 @@ public:
typedef ACE_Map_Manager <void *, size_t, ACE_Null_Mutex> MAP_MANAGER;
typedef ACE_Map_Iterator <void *, size_t, ACE_Null_Mutex> MAP_ITERATOR;
typedef ACE_Map_Entry <void *, size_t> MAP_ENTRY;
/// Keeps track of the mapping between addresses and their associated
/// values.
MAP_MANAGER addr_map_;
/// Synchronize concurrent access to the map.
ACE_SYNCH_MUTEX lock_;
};
ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository (void)
{
ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository");
ACE_NEW (this->rep_,
ACE_Based_Pointer_Repository_Rep);
}
ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository (void)
{
ACE_TRACE ("ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository");
delete this->rep_;
}
// Search for appropriate base address in repository
int
ACE_Based_Pointer_Repository::find (void *addr, void *&base_addr)
{
ACE_TRACE ("ACE_Based_Pointer_Repository::find");
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;
for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
iter.next (ce) != 0;
iter.advance ())
@@ -57,27 +67,35 @@ ACE_Based_Pointer_Repository::find (void *addr, void *&base_addr)
base_addr = ce->ext_id_;
return 1;
}
// Assume base address 0 (e.g., if new'ed).
base_addr = 0;
return 0;
}
// Bind a new entry to the repository or update the size of an
// existing entry.
int
ACE_Based_Pointer_Repository::bind (void *addr, size_t size)
{
ACE_TRACE ("ACE_Based_Pointer_Repository::bind");
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
return this->rep_->addr_map_.rebind (addr, size);
}
// Unbind a base from the repository.
int
ACE_Based_Pointer_Repository::unbind (void *addr)
{
ACE_TRACE ("ACE_Based_Pointer_Repository::unbind");
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;
// Search for service handlers that requested notification.
for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
iter.next (ce) != 0;
iter.advance ())
@@ -89,11 +107,14 @@ ACE_Based_Pointer_Repository::unbind (void *addr)
// Unbind base address.
return this->rep_->addr_map_.unbind (ce->ext_id_);
}
return 0;
}
#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
template ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX> *
ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX>::singleton_;
#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
ACE_END_VERSIONED_NAMESPACE_DECL
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Based_Pointer_Repository.h
@@ -9,20 +10,28 @@
* @author Douglas C. Schmidt <schmidt@.cs.wustl.edu>
*/
//=============================================================================
#ifndef ACE_BASED_POINTER_REPOSITORY_H
#define ACE_BASED_POINTER_REPOSITORY_H
#include /**/ "ace/pre.h"
#include /**/ "ace/ACE_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Singleton.h"
#include "ace/Synch_Traits.h"
#include "ace/os_include/os_stddef.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward decl., using the "Cheshire Cat" technique.
class ACE_Based_Pointer_Repository_Rep;
/**
* @class ACE_Based_Pointer_Repository
*
@@ -33,9 +42,11 @@ class ACE_Export ACE_Based_Pointer_Repository
{
public:
// = Use ACE_Null_Mutex to allow locking while iterating.
// = Initialization and termination methods.
ACE_Based_Pointer_Repository (void);
~ACE_Based_Pointer_Repository (void);
// = Search structure methods.
/**
* Return the appropriate @a base_addr region that contains @a addr.
@@ -44,27 +55,38 @@ public:
*/
int find (void *addr,
void *&base_addr);
/// Bind a new entry to the repository or update the size of an
/// existing entry. Returns 0 on success and -1 on failure.
int bind (void *addr,
size_t size);
/// Unbind from the repository the <base_addr> that @a addr is
/// contained within.
int unbind (void *addr);
private:
/// Use the "Cheshire-Cat" technique to hide the implementation in
/// order to avoid circular #include dependencies.
ACE_Based_Pointer_Repository_Rep *rep_;
};
// ----------------------------------
/// Declare a process wide singleton
ACE_SINGLETON_DECLARE (ACE_Singleton,
ACE_Based_Pointer_Repository,
ACE_SYNCH_RW_MUTEX)
/// Provide a Singleton access point to the based pointer repository.
typedef ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX>
ACE_BASED_POINTER_REPOSITORY;
ACE_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif /* ACE_BASED_POINTER_REPOSITORY_H */
+40
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Based_Pointer_T.h
@@ -9,11 +10,15 @@
* @author Douglas C. Schmidt <schmidt@.cs.wustl.edu>
*/
//=============================================================================
#ifndef ACE_BASED_POINTER_T_H
#define ACE_BASED_POINTER_T_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#include "ace/Basic_Types.h"
#if defined (_MSC_VER)
// Suppress warning e.g. "return type for
// 'ACE_Based_Pointer<long>::operator ->' is 'long *' (i.e., not a UDT
@@ -21,7 +26,9 @@
// notation)"
#pragma warning(disable: 4284)
#endif /* _MSC_VER */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Based_Pointer_Basic
*
@@ -55,6 +62,7 @@ public:
* address 0.
*/
ACE_Based_Pointer_Basic (void);
/**
* Initialize this object using the @a initial pointer. This
* constructor initializes the <base_offset_> by asking the
@@ -77,46 +85,66 @@ public:
* indicates a "NULL" pointer.
*/
ACE_Based_Pointer_Basic (CONCRETE *initial);
/// Copy constructor.
ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic<CONCRETE> &);
/// Constructor for know base address. @a o is only used to
/// resolve overload ambiguity.
ACE_Based_Pointer_Basic (const void *base_addr, int o);
/// Pseudo-assignment operator.
void operator = (CONCRETE *from);
/// Pseudo-assignment operator.
void operator = (const ACE_Based_Pointer_Basic<CONCRETE> &);
/// Dereference operator.
CONCRETE operator * (void) const;
/// Less than operator.
bool operator < (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
/// Less than or equal operator.
bool operator <= (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
/// Greater than operator.
bool operator > (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
/// Greater than or equal operator.
bool operator >= (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
/// Equality operator.
bool operator == (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
/// Inequality operator.
bool operator != (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
/// Subscript operator.
CONCRETE operator [](int index) const;
/// Increment operator.
void operator+= (int index);
/// Returns the underlying memory address of the smart pointer.
operator CONCRETE *() const;
/// Returns the underlying memory address of the smart pointer.
CONCRETE *addr (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
/// Dump the state of the object.
void dump (void) const;
protected:
ptrdiff_t target_;
/// Keep track of our offset from the base pointer.
ptrdiff_t base_offset_;
};
/**
* @class ACE_Based_Pointer
*
@@ -135,32 +163,44 @@ public:
/// Constructor. See constructor for ACE_Based_Pointer_Basic for
/// details.
ACE_Based_Pointer (void);
/// Initialize this object using the <initial> pointer. See
/// constructor for ACE_Based_Pointer_Basic for details.
ACE_Based_Pointer (CONCRETE *initial);
/// Initialize this object with known @a base_addr. @a dummy is
/// a dummy value used to resolve overload ambiguity and it
/// otherwise ignored.
ACE_Based_Pointer (const void *base_addr, int dummy);
/// Copy constructor (not implemented yet).
ACE_Based_Pointer (const ACE_Based_Pointer<CONCRETE> &);
/// Assignment operator.
void operator = (const ACE_Based_Pointer<CONCRETE> &);
/// Pseudo-assignment operator.
void operator = (CONCRETE *from);
/// The C++ "delegation operator".
CONCRETE *operator-> (void);
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Based_Pointer_T.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/Based_Pointer_T.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Based_Pointer_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
#endif /* ACE_BASED_POINTER_T_H */
+21
View File
@@ -1,15 +1,19 @@
// -*- C++ -*-
//
// $Id: Based_Pointer_T.inl 81705 2008-05-15 14:02:02Z johnnyw $
#define ACE_COMPUTE_BASED_POINTER(P) (((char *) (P) - (P)->base_offset_) + (P)->target_)
#include "ace/Global_Macros.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class CONCRETE> ACE_INLINE CONCRETE *
ACE_Based_Pointer<CONCRETE>::operator->(void)
{
ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::operator->");
return reinterpret_cast<CONCRETE *> (ACE_COMPUTE_BASED_POINTER (this));
}
template <class CONCRETE> ACE_INLINE void
ACE_Based_Pointer_Basic<CONCRETE>::operator = (CONCRETE *rhs)
{
@@ -21,6 +25,7 @@ ACE_Based_Pointer_Basic<CONCRETE>::operator = (CONCRETE *rhs)
this->target_ = ((char *) rhs
- ((char *) this - this->base_offset_));
}
template <class CONCRETE> ACE_INLINE void
ACE_Based_Pointer<CONCRETE>::operator = (CONCRETE *rhs)
{
@@ -32,27 +37,33 @@ ACE_Based_Pointer<CONCRETE>::operator = (CONCRETE *rhs)
this->target_ = ((char *) rhs
- ((char *) this - this->base_offset_));
}
template <class CONCRETE> ACE_INLINE CONCRETE
ACE_Based_Pointer_Basic<CONCRETE>::operator *(void) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator *");
return *reinterpret_cast<CONCRETE *> (ACE_COMPUTE_BASED_POINTER (this));
}
template <class CONCRETE> ACE_INLINE CONCRETE *
ACE_Based_Pointer_Basic<CONCRETE>::addr (void) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::addr");
if (this->target_ == -1)
return 0;
else
return reinterpret_cast<CONCRETE *> (ACE_COMPUTE_BASED_POINTER (this));
}
template <class CONCRETE> ACE_INLINE
ACE_Based_Pointer_Basic<CONCRETE>::operator CONCRETE *() const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator CONCRETE *()");
return this->addr ();
}
template <class CONCRETE> ACE_INLINE CONCRETE
ACE_Based_Pointer_Basic<CONCRETE>::operator [] (int index) const
{
@@ -61,58 +72,68 @@ ACE_Based_Pointer_Basic<CONCRETE>::operator [] (int index) const
reinterpret_cast<CONCRETE *> (ACE_COMPUTE_BASED_POINTER (this));
return c[index];
}
template <class CONCRETE> ACE_INLINE void
ACE_Based_Pointer_Basic<CONCRETE>::operator += (int index)
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator +=");
this->base_offset_ += (index * sizeof (CONCRETE));
}
template <class CONCRETE> ACE_INLINE bool
ACE_Based_Pointer_Basic<CONCRETE>::operator == (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator ==");
return ACE_COMPUTE_BASED_POINTER (this) == ACE_COMPUTE_BASED_POINTER (&rhs);
}
template <class CONCRETE> ACE_INLINE bool
ACE_Based_Pointer_Basic<CONCRETE>::operator != (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator !=");
return !(*this == rhs);
}
template <class CONCRETE> ACE_INLINE bool
ACE_Based_Pointer_Basic<CONCRETE>::operator < (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator <");
return ACE_COMPUTE_BASED_POINTER (this) < ACE_COMPUTE_BASED_POINTER (&rhs);
}
template <class CONCRETE> ACE_INLINE bool
ACE_Based_Pointer_Basic<CONCRETE>::operator <= (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator <=");
return ACE_COMPUTE_BASED_POINTER (this) <= ACE_COMPUTE_BASED_POINTER (&rhs);
}
template <class CONCRETE> ACE_INLINE bool
ACE_Based_Pointer_Basic<CONCRETE>::operator > (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator >");
return ACE_COMPUTE_BASED_POINTER (this) > ACE_COMPUTE_BASED_POINTER (&rhs);
}
template <class CONCRETE> ACE_INLINE bool
ACE_Based_Pointer_Basic<CONCRETE>::operator >= (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator >=");
return ACE_COMPUTE_BASED_POINTER (this) >= ACE_COMPUTE_BASED_POINTER (&rhs);
}
template <class CONCRETE> ACE_INLINE void
ACE_Based_Pointer_Basic<CONCRETE>::operator= (const ACE_Based_Pointer_Basic<CONCRETE> &rhs)
{
ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator=");
*this = rhs.addr ();
}
template <class CONCRETE> ACE_INLINE void
ACE_Based_Pointer<CONCRETE>::operator= (const ACE_Based_Pointer<CONCRETE> &rhs)
{
ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::operator=");
*this = rhs.addr ();
}
ACE_END_VERSIONED_NAMESPACE_DECL
+14
View File
@@ -1,22 +1,29 @@
// $Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Basic_Stats.h"
#include "ace/Log_Msg.h"
#if !defined (__ACE_INLINE__)
#include "ace/Basic_Stats.inl"
#endif /* __ACE_INLINE__ */
ACE_RCSID(ace,
Basic_Stats,
"$Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs)
{
if (rhs.samples_count_ == 0)
return;
if (this->samples_count_ == 0)
{
this->min_ = rhs.min_;
this->min_at_ = rhs.min_at_;
this->max_ = rhs.max_;
this->max_at_ = rhs.max_at_;
}
@@ -33,9 +40,11 @@ ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs)
this->max_at_ = rhs.max_at_;
}
}
this->samples_count_ += rhs.samples_count_;
this->sum_ += rhs.sum_;
}
void
ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const
{
@@ -46,20 +55,25 @@ ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const
ACE_TEXT ("%s : no data collected\n"), msg));
return;
}
ACE_UINT64 avg = this->sum_ / this->samples_count_;
ACE_UINT64 l_min = this->min_ / sf;
ACE_UINT64 l_max = this->max_ / sf;
ACE_UINT64 l_avg = avg / sf;
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("%s latency : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"),
msg,
l_min, this->min_at_,
l_avg,
l_max, this->max_at_));
#else
ACE_UNUSED_ARG (msg);
ACE_UNUSED_ARG (sf);
#endif /* ACE_NLOGGING */
}
ACE_END_VERSIONED_NAMESPACE_DECL
+18
View File
@@ -9,15 +9,20 @@
*/
//=============================================================================
#ifndef ACE_BASIC_STATS_H
#define ACE_BASIC_STATS_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#include "ace/Basic_Types.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/// Collect basic stats about a series of samples
/**
* Compute the average and standard deviation (aka jitter) for an
@@ -33,12 +38,16 @@ public:
* the class is initialized.
*/
ACE_Basic_Stats (void);
/// The number of samples received so far
ACE_UINT32 samples_count (void) const;
/// Record one sample.
void sample (ACE_UINT64 value);
/// Update the values to reflect the stats in @a rhs.
void accumulate (const ACE_Basic_Stats &rhs);
/// Dump all the samples
/**
* Prints out the results, using @a msg as a prefix for each message and
@@ -48,23 +57,32 @@ public:
*/
void dump_results (const ACE_TCHAR *msg,
ACE_UINT32 scale_factor) const;
/// The number of samples
ACE_UINT32 samples_count_;
/// The minimum value
ACE_UINT64 min_;
/// The number of the sample that had the minimum value
ACE_UINT32 min_at_;
/// The maximum value
ACE_UINT64 max_;
/// The number of the sample that had the maximum value
ACE_UINT32 max_at_;
/// The sum of all the values
ACE_UINT64 sum_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "ace/Basic_Stats.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_BASIC_STATS_H */
+7
View File
@@ -1,7 +1,9 @@
// -*- C++ -*-
//
// $Id: Basic_Stats.inl 80826 2008-03-04 14:51:23Z wotte $
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Basic_Stats::ACE_Basic_Stats (void)
: samples_count_ (0)
@@ -12,15 +14,18 @@ ACE_Basic_Stats::ACE_Basic_Stats (void)
, sum_ (0)
{
}
ACE_INLINE ACE_UINT32
ACE_Basic_Stats::samples_count (void) const
{
return this->samples_count_;
}
ACE_INLINE void
ACE_Basic_Stats::sample (ACE_UINT64 value)
{
++this->samples_count_;
if (this->samples_count_ == 1u)
{
this->min_ = value;
@@ -41,6 +46,8 @@ ACE_Basic_Stats::sample (ACE_UINT64 value)
this->max_at_ = this->samples_count_;
}
}
this->sum_ += value;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+13
View File
@@ -1,12 +1,15 @@
#include "ace/Basic_Types.h"
#if !defined (__ACE_INLINE__)
# include "ace/Basic_Types.inl"
#endif /* ! __ACE_INLINE__ */
ACE_RCSID (ace,
Basic_Types,
"$Id: Basic_Types.cpp 80826 2008-03-04 14:51:23Z wotte $")
#if defined (ACE_LACKS_LONGLONG_T) && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
# include "ace/Log_Msg.h"
# include "ace/OS_NS_stdio.h"
@@ -15,7 +18,9 @@ ACE_RCSID (ace,
// FUZZ: disable check_for_streams_include
# include "ace/streams.h"
# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
ACE_U_LongLong::output (FILE *file) const
{
@@ -25,6 +30,7 @@ ACE_U_LongLong::output (FILE *file) const
ACE_OS::fprintf (file, "0x%lx", l_ ());
}
ACE_TCHAR *
ACE_U_LongLong::as_string (ACE_TCHAR *output,
unsigned int base,
@@ -89,6 +95,7 @@ ACE_U_LongLong::as_string (ACE_TCHAR *output,
{
ACE_OS::sprintf(output,
(uppercase ? "%lX" : "%lx"), this->l_ ());
}
break;
}
@@ -100,9 +107,11 @@ ACE_U_LongLong::as_string (ACE_TCHAR *output,
}
}
}
return output;
}
# if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
ostream&
operator<< (ostream& os, const ACE_U_LongLong& ll)
@@ -113,6 +122,7 @@ operator<< (ostream& os, const ACE_U_LongLong& ll)
unsigned long flags = os.setf(0);
#endif
char buffer[32];
if ((flags & ios::oct) != 0)
os << ll.as_string (buffer, 8);
else if ((flags & ios::hex) != 0)
@@ -122,6 +132,9 @@ operator<< (ostream& os, const ACE_U_LongLong& ll)
return os;
}
# endif
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_LACKS_LONGLONG_T */
+103
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Basic_Types.h
@@ -41,37 +42,50 @@
*
*/
//=============================================================================
#include "ace/config-lite.h"
#ifndef ACE_BASIC_TYPES_H
# define ACE_BASIC_TYPES_H
# include /**/ "ace/pre.h"
# if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
# endif /* ACE_LACKS_PRAGMA_ONCE */
// Pull in definitions
# include "ace/os_include/os_limits.h" // Integer limits
# include "ace/os_include/os_float.h" // Floating point limits
# include "ace/os_include/os_stdlib.h" // Other types
# include "ace/os_include/os_stddef.h" // Get ptrdiff_t - see further comments below
# if defined(ACE_LACKS_LONGLONG_T)
# include "ace/os_include/os_stdio.h" // For long long emulation
# endif /* ACE_LACKS_LONGLONG_T */
# include "ace/os_include/sys/os_types.h"
# if !defined (ACE_LACKS_SYS_PARAM_H)
# include /**/ <sys/param.h>
# endif /* ACE_LACKS_SYS_PARAM_H */
# include "ace/ACE_export.h"
# if !defined (ACE_LACKS_STDINT_H)
# include <stdint.h>
# endif
# if !defined (ACE_LACKS_INTTYPES_H)
# include <inttypes.h>
# endif
#ifdef ACE_LACKS_INTPTR_T
# include "ace/If_Then_Else.h"
// This intptr_t typedef is here instead of
// <ace/os_include/os_inttypes.h> since it depends on the template
// metaprogramming in <ace/If_Then_Else.h>.
// We could compare ACE_SIZEOF_VOID_P against ACE_SIZEOF_LONG, etc.
// However, that depends on the ACE preprocessor symbol definitions in
// the platform-specific configuration header being correct.
@@ -79,6 +93,7 @@
// i.e. determining the type at compile-time rather than at
// preprocessing-time, will work for all platforms, and does not
// depend on ACE developer-defined configuration parameters.
typedef ACE::If_Then_Else<
(sizeof (void*) == sizeof (signed int)),
signed int,
@@ -96,6 +111,7 @@ typedef ACE::If_Then_Else<
#endif /* ACE_LACKS_LONGLONG_T */
>::result_type
>::result_type intptr_t;
typedef ACE::If_Then_Else<
(sizeof (void*) == sizeof (unsigned int)),
unsigned int,
@@ -113,9 +129,12 @@ typedef ACE::If_Then_Else<
#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */
>::result_type
>::result_type uintptr_t;
#endif /* ACE_LACKS_INTPTR_T */
// A char always has 1 byte, by definition.
# define ACE_SIZEOF_CHAR 1
// Unfortunately, there isn't a portable way to determine the size of a wchar.
// So we just define them on a platform basis. If the platform doesn't
// define it and it's an XPG4 system, assume wchar_t is 4 bytes. Some code
@@ -132,6 +151,7 @@ typedef ACE::If_Then_Else<
# endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */
# endif /* !ACE_SIZEOF_WCHAR */
# endif /* ACE_HAS_WCHAR */
// The number of bytes in a short.
# if !defined (ACE_SIZEOF_SHORT)
# if (USHRT_MAX) == 255U
@@ -146,6 +166,7 @@ typedef ACE::If_Then_Else<
# error: unsupported short size, must be updated for this platform!
# endif /* USHRT_MAX */
# endif /* !defined (ACE_SIZEOF_SHORT) */
// The number of bytes in an int.
# if !defined (ACE_SIZEOF_INT)
# if (UINT_MAX) == 65535U
@@ -158,6 +179,7 @@ typedef ACE::If_Then_Else<
# error: unsupported int size, must be updated for this platform!
# endif /* UINT_MAX */
# endif /* !defined (ACE_SIZEOF_INT) */
// The number of bytes in a long.
# if !defined (ACE_SIZEOF_LONG)
# if (ULONG_MAX) == 65535UL
@@ -170,6 +192,7 @@ typedef ACE::If_Then_Else<
# error: unsupported long size, must be updated for this platform!
# endif /* ULONG_MAX */
# endif /* !defined (ACE_SIZEOF_LONG) */
// The number of bytes in a long long.
# if !defined (ACE_SIZEOF_LONG_LONG)
# if defined (ACE_LACKS_LONGLONG_T)
@@ -197,10 +220,13 @@ typedef ACE::If_Then_Else<
# endif
# endif /* !defined (ACE_SIZEOF_LONG_LONG) */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// The sizes of the commonly implemented types are now known. Set up
// typedefs for whatever we can. Some of these are needed for certain
// cases of ACE_UINT64, so do them before the 64-bit stuff.
#if defined (ACE_INT8_TYPE)
typedef ACE_INT8_TYPE ACE_INT8;
#elif defined (ACE_HAS_INT8_T)
@@ -210,6 +236,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#else
typedef char ACE_INT8;
#endif /* defined (ACE_INT8_TYPE) */
#if defined (ACE_UINT8_TYPE)
typedef ACE_UINT8_TYPE ACE_UINT8;
#elif defined (ACE_HAS_UINT8_T)
@@ -217,6 +244,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#else
typedef unsigned char ACE_UINT8;
#endif /* defined (ACE_UINT8_TYPE) */
#if defined (ACE_INT16_TYPE)
typedef ACE_INT16_TYPE ACE_INT16;
#elif defined (ACE_HAS_INT16_T)
@@ -228,6 +256,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#else
# error Have to add to the ACE_INT16 type setting
#endif /* defined (ACE_INT16_TYPE) */
#if defined (ACE_UINT16_TYPE)
typedef ACE_UINT16_TYPE ACE_UINT16;
#elif defined (ACE_HAS_UINT16_T)
@@ -239,6 +268,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#else
# error Have to add to the ACE_UINT16 type setting
#endif /* defined (ACE_UINT16_TYPE) */
#if defined (ACE_INT32_TYPE)
typedef ACE_INT32_TYPE ACE_INT32;
#elif defined (ACE_HAS_INT32_T)
@@ -250,6 +280,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#else
# error Have to add to the ACE_INT32 type setting
#endif /* defined (ACE_INT32_TYPE) */
#if defined (ACE_UINT32_TYPE)
typedef ACE_UINT32_TYPE ACE_UINT32;
#elif defined (ACE_HAS_UINT32_T)
@@ -261,6 +292,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#else
# error Have to add to the ACE_UINT32 type setting
#endif /* defined (ACE_UINT32_TYPE) */
#if defined (ACE_INT64_TYPE)
typedef ACE_INT64_TYPE ACE_INT64;
#elif defined (ACE_HAS_INT64_T)
@@ -275,8 +307,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
# endif /* __GNUC__ */
typedef long long ACE_INT64;
#endif /* defined (ACE_INT64_TYPE) */
#if !(defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T))
/* See matching #if around ACE_U_LongLong class declaration below */
# if defined (ACE_UINT64_TYPE)
typedef ACE_UINT64_TYPE ACE_UINT64;
# elif defined (ACE_HAS_UINT64_T)
@@ -293,11 +327,15 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
# endif /* defined (ACE_UINT64_TYPE) */
#endif /* !(ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T) */
typedef ACE_UINT16 ACE_USHORT16; // @@ Backward compatibility.
// Define a generic byte for use in codecs
typedef unsigned char ACE_Byte;
// Define a pseudo wide character type when wchar is not supported so we
// can support basic wide character string operations.
# if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
# define ACE_WINT_T wint_t
# define ACE_WCHAR_T wchar_t
@@ -305,17 +343,21 @@ typedef unsigned char ACE_Byte;
# define ACE_WINT_T ACE_UINT16
# define ACE_WCHAR_T ACE_UINT16
# endif /* ACE_HAS_WCHAR */
// The number of bytes in a void *.
# ifndef ACE_SIZEOF_VOID_P
# define ACE_SIZEOF_VOID_P ACE_SIZEOF_LONG
# endif /* ACE_SIZEOF_VOID_P */
// Type for doing arithmetic on pointers ... as elsewhere, we assume
// that unsigned versions of a type are the same size as the signed
// version of the same type.
# if defined (ACE_HAS_WINCE) && (_WIN32_WCE < 400)
typedef unsigned long ptrdiff_t; // evc3, PocketPC don't defined ptrdiff_t
# endif
ACE_END_VERSIONED_NAMESPACE_DECL
// Byte-order (endian-ness) determination.
# if defined (BYTE_ORDER)
# if (BYTE_ORDER == LITTLE_ENDIAN)
@@ -362,12 +404,14 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_BYTE_ORDER ACE_BIG_ENDIAN
# endif
# endif /* ! BYTE_ORDER && ! __BYTE_ORDER */
// Byte swapping macros to deal with differences between little endian
// and big endian machines. Note that "long" here refers to 32 bit
// quantities.
# define ACE_SWAP_LONG(L) ((ACE_SWAP_WORD ((L) & 0xFFFF) << 16) \
| ACE_SWAP_WORD(((L) >> 16) & 0xFFFF))
# define ACE_SWAP_WORD(L) ((((L) & 0x00FF) << 8) | (((L) & 0xFF00) >> 8))
# if defined (ACE_LITTLE_ENDIAN)
# define ACE_HTONL(X) ACE_SWAP_LONG (X)
# define ACE_NTOHL(X) ACE_SWAP_LONG (X)
@@ -379,6 +423,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_IDL_NCTOHL(X) (X << 24)
# define ACE_IDL_NSTOHL(X) ((X) << 16)
# endif /* ACE_LITTLE_ENDIAN */
# if defined (ACE_LITTLE_ENDIAN)
# define ACE_HTONS(x) ACE_SWAP_WORD(x)
# define ACE_NTOHS(x) ACE_SWAP_WORD(x)
@@ -386,6 +431,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_HTONS(x) x
# define ACE_NTOHS(x) x
# endif /* ACE_LITTLE_ENDIAN */
#if defined (ACE_LACKS_LONGLONG_T)
// This throws away the high 32 bits. It's very unlikely that a
// pointer will be more than 32 bits wide if the platform does not
@@ -399,11 +445,14 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \
reinterpret_cast<PTR_TYPE> (static_cast<intptr_t> (L))
#endif /* ! ACE_LACKS_LONGLONG_T */
// If the platform lacks an unsigned long long, define one.
#if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
// Forward declaration for streams
# include "ace/iosfwd.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_U_LongLong
*
@@ -432,6 +481,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_U_LongLong &operator= (const ACE_INT32 &);
ACE_U_LongLong &operator= (const ACE_UINT32 &);
~ACE_U_LongLong (void);
// = Overloaded relation operators.
bool operator== (const ACE_U_LongLong &) const;
bool operator== (const ACE_UINT32) const;
@@ -445,17 +495,21 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
bool operator> (const ACE_UINT32) const;
bool operator>= (const ACE_U_LongLong &) const;
bool operator>= (const ACE_UINT32) const;
ACE_U_LongLong operator+ (const ACE_U_LongLong &) const;
ACE_U_LongLong operator+ (const ACE_UINT32) const;
ACE_U_LongLong operator- (const ACE_U_LongLong &) const;
ACE_U_LongLong operator- (const ACE_UINT32) const;
ACE_U_LongLong operator* (const ACE_UINT32) const;
ACE_U_LongLong &operator*= (const ACE_UINT32);
ACE_U_LongLong operator<< (const unsigned int) const;
ACE_U_LongLong &operator<<= (const unsigned int);
ACE_U_LongLong operator>> (const unsigned int) const;
ACE_U_LongLong &operator>>= (const unsigned int);
double operator/ (const double) const;
ACE_U_LongLong &operator+= (const ACE_U_LongLong &);
ACE_U_LongLong &operator+= (const ACE_UINT32);
ACE_U_LongLong &operator-= (const ACE_U_LongLong &);
@@ -468,16 +522,19 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_U_LongLong &operator|= (const ACE_UINT32);
ACE_U_LongLong &operator&= (const ACE_U_LongLong);
ACE_U_LongLong &operator&= (const ACE_UINT32);
// Note that the following take ACE_UINT32 arguments. These are
// typical use cases, and easy to implement. But, they limit the
// return values to 32 bits as well. There are no checks for
// overflow.
ACE_UINT32 operator/ (const ACE_UINT32) const;
ACE_UINT32 operator% (const ACE_UINT32) const;
// The following only operate on the lower 32 bits (they take only
// 32 bit arguments).
ACE_UINT32 operator| (const ACE_INT32) const;
ACE_UINT32 operator& (const ACE_INT32) const;
// The following operators convert their arguments to
// ACE_UINT32. So, there may be information loss if they are
// used.
@@ -491,20 +548,27 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_UINT32 operator/ (const unsigned int) const;
ACE_UINT32 operator/ (const int) const;
# endif /* ACE_SIZEOF_INT != 4 */
// = Helper methods.
/// Outputs the value to the FILE, in hex.
void output (FILE * = stdout) const;
ACE_TCHAR *as_string (ACE_TCHAR *string,
unsigned int base = 10,
unsigned int uppercase = 0) const;
ACE_UINT32 hi (void) const;
ACE_UINT32 lo (void) const;
void hi (const ACE_UINT32 hi);
void lo (const ACE_UINT32 lo);
#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
long long to_int64 (void) const;
# endif
private:
#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
long long data_;
#else
@@ -516,7 +580,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_UINT32 hi_;
/// Low 32 bits.
ACE_UINT32 lo_;
# else
/// Low 32 bits.
ACE_UINT32 lo_;
/// High 32 bits.
@@ -527,23 +593,31 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
union
{
struct ace_hi_lo_correct_endian data_;
/// To ensure alignment on 8-byte boundary.
double for_alignment_;
};
// @note the following four accessors are inlined here in
// order to minimize the extent of the data_ struct. It's
// only used here; the .i and .cpp files use the accessors.
/// Internal utility function to hide access through struct.
const ACE_UINT32 &h_ () const { return data_.hi_; }
/// Internal utility function to hide access through struct.
ACE_UINT32 &h_ () { return data_.hi_; }
/// Internal utility function to hide access through struct.
const ACE_UINT32 &l_ () const { return data_.lo_; }
/// Internal utility function to hide access through struct.
ACE_UINT32 &l_ () { return data_.lo_; }
// @note the above four accessors are inlined here in
// order to minimize the extent of the data_ struct. It's
// only used here; the .inl and .cpp files use the accessors.
/// These functions are used to implement multiplication.
ACE_UINT32 ul_shift (ACE_UINT32 a,
ACE_UINT32 c_in,
@@ -559,13 +633,19 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_UINT32 *carry) const;
#endif // ACE_LACKS_UNSIGNEDLONGLONG_T
};
typedef ACE_U_LongLong ACE_UINT64;
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
ostream &operator<< (ostream &, const ACE_U_LongLong &);
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
ACE_END_VERSIONED_NAMESPACE_DECL
# endif /* ACE_LACKS_LONGLONG_T */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Conversions from ACE_UINT64 to ACE_UINT32. ACE_CU64_TO_CU32 should
// be used on const ACE_UINT64's.
# if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
@@ -579,6 +659,7 @@ ACE_U64_TO_U32 (ACE_U_LongLong const & n)
*/
return n.lo ();
}
inline ACE_UINT32
ACE_CU64_TO_CU32 (ACE_U_LongLong const & n)
{
@@ -590,13 +671,16 @@ ACE_U64_TO_U32 (ACE_UINT64 n)
{
return static_cast<ACE_UINT32> (n);
}
inline ACE_UINT32
ACE_CU64_TO_CU32 (ACE_UINT64 n)
{
return static_cast<ACE_UINT32> (n);
}
# endif /* ! ACE_LACKS_LONGLONG_T */
ACE_END_VERSIONED_NAMESPACE_DECL
// 64-bit literals require special marking on some platforms.
# if defined (ACE_LACKS_LONGLONG_T)
// Can only specify 32-bit arguments.
@@ -619,6 +703,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_UINT64_LITERAL(n) n ## ull
# define ACE_INT64_LITERAL(n) n ## ll
# endif /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */
#if !defined (ACE_INT8_FORMAT_SPECIFIER)
# if defined (PRId8)
# define ACE_INT8_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId8)
@@ -626,6 +711,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_INT8_FORMAT_SPECIFIER ACE_TEXT ("%d")
# endif /* defined (PRId8) */
#endif /* ACE_INT8_FORMAT_SPECIFIER */
#if !defined (ACE_UINT8_FORMAT_SPECIFIER)
# if defined (PRIu8)
# define ACE_UINT8_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu8)
@@ -633,6 +719,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_UINT8_FORMAT_SPECIFIER ACE_TEXT ("%u")
# endif /* defined (PRIu8) */
#endif /* ACE_UINT8_FORMAT_SPECIFIER */
#if !defined (ACE_INT16_FORMAT_SPECIFIER)
# if defined (PRId16)
# define ACE_INT16_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId16)
@@ -640,6 +727,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_INT16_FORMAT_SPECIFIER ACE_TEXT ("%d")
# endif /* defined (PRId16) */
#endif /* ACE_INT16_FORMAT_SPECIFIER */
#if !defined (ACE_UINT16_FORMAT_SPECIFIER)
# if defined (PRIu16)
# define ACE_UINT16_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu16)
@@ -647,6 +735,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_UINT16_FORMAT_SPECIFIER ACE_TEXT ("%u")
# endif /* defined (PRIu16) */
#endif /* ACE_UINT16_FORMAT_SPECIFIER */
#if !defined (ACE_INT32_FORMAT_SPECIFIER)
# if defined (PRId32)
# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId32)
@@ -656,6 +745,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%ld")
# endif /* defined (PRId32) */
#endif /* ACE_INT32_FORMAT_SPECIFIER */
#if !defined (ACE_UINT32_FORMAT_SPECIFIER)
# if defined (PRIu32)
# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu32)
@@ -665,6 +755,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%lu")
# endif /* defined (PRIu32) */
#endif /* ACE_UINT32_FORMAT_SPECIFIER */
#if !defined (ACE_INT64_FORMAT_SPECIFIER)
# if defined (PRId64)
# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId64)
@@ -674,6 +765,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%lld")
# endif /* defined (PRId64) */
#endif /* ACE_INT64_FORMAT_SPECIFIER */
#if !defined (ACE_UINT64_FORMAT_SPECIFIER)
# if defined (PRIu64)
# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu64)
@@ -683,6 +775,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%llu")
# endif /* defined (PRIu64) */
#endif /* ACE_UINT64_FORMAT_SPECIFIER */
#if !defined (ACE_SSIZE_T_FORMAT_SPECIFIER)
# if defined (ACE_WIN64)
# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%I64d")
@@ -690,6 +783,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%d")
# endif /* ACE_WIN64 */
#endif /* ACE_SSIZE_T_FORMAT_SPECIFIER */
#if !defined (ACE_SIZE_T_FORMAT_SPECIFIER)
# if defined (ACE_WIN64)
# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%I64u")
@@ -697,6 +791,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%u")
# endif /* ACE_WIN64 */
#endif /* ACE_SIZE_T_FORMAT_SPECIFIER */
// Cast from UINT64 to a double requires an intermediate cast to INT64
// on some platforms.
# if defined (ACE_LACKS_LONGLONG_T)
@@ -710,6 +805,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_UINT64_DBLCAST_ADAPTER(n) (n)
# endif /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */
// The number of bytes in a float.
# ifndef ACE_SIZEOF_FLOAT
# if FLT_MAX_EXP == 128
@@ -720,6 +816,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# error: unsupported float size, must be updated for this platform!
# endif /* FLT_MAX_EXP */
# endif /* ACE_SIZEOF_FLOAT */
// The number of bytes in a double.
# ifndef ACE_SIZEOF_DOUBLE
# if DBL_MAX_EXP == 128
@@ -730,6 +827,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# error: unsupported double size, must be updated for this platform!
# endif /* DBL_MAX_EXP */
# endif /* ACE_SIZEOF_DOUBLE */
// The number of bytes in a long double.
# ifndef ACE_SIZEOF_LONG_DOUBLE
# if LDBL_MAX_EXP == 128
@@ -750,6 +848,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# error: unsupported double size, must be updated for this platform!
# endif /* LDBL_MAX_EXP */
# endif /* ACE_SIZEOF_LONG_DOUBLE */
// Max and min sizes for the ACE integer types.
#define ACE_CHAR_MAX 0x7F
#define ACE_CHAR_MIN -(ACE_CHAR_MAX)-1
@@ -763,6 +862,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
#define ACE_UINT32_MAX 0xFFFFFFFF
#define ACE_INT64_MAX ACE_INT64_LITERAL(0x7FFFFFFFFFFFFFFF)
#define ACE_INT64_MIN -(ACE_INT64_MAX)-1
#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
// ACE_U_LongLong's constructor accepts a "long long" in this
// case. Set it to ACE_U_LongLong (-1) since the bit pattern for long
@@ -775,14 +875,17 @@ ACE_END_VERSIONED_NAMESPACE_DECL
#else
# define ACE_UINT64_MAX ACE_UINT64_LITERAL (0xFFFFFFFFFFFFFFFF)
#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */
// These use ANSI/IEEE format.
#define ACE_FLT_MAX 3.402823466e+38F
#define ACE_FLT_MIN 1.175494351e-38F
#define ACE_DBL_MAX 1.7976931348623158e+308
#define ACE_DBL_MIN 2.2250738585072014e-308
# if defined (__ACE_INLINE__)
# include "ace/Basic_Types.inl"
# endif /* __ACE_INLINE__ */
# include /**/ "ace/post.h"
#endif /* ACE_BASIC_TYPES_H */
+172
View File
@@ -1,65 +1,80 @@
// -*- C++ -*-
//
// $Id: Basic_Types.inl 80826 2008-03-04 14:51:23Z wotte $
# if !defined (ACE_LACKS_LONGLONG_T) && defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Implementation for ACE_U_LongLong when we have signed long long
// but no unsigned long long.
ACE_INLINE
ACE_U_LongLong::ACE_U_LongLong (const long long value)
: data_ (value)
{
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::hi (void) const
{
return (data_ >> 32) & 0xFFFFFFFF;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::lo (void) const
{
return data_ & 0xFFFFFFFF;
}
ACE_INLINE void
ACE_U_LongLong::hi (const ACE_UINT32 hi)
{
data_ = hi;
data_ <<= 32;
}
ACE_INLINE void
ACE_U_LongLong::lo (const ACE_UINT32 lo)
{
data_ = lo;
}
ACE_INLINE long long
ACE_U_LongLong::to_int64 (void) const
{
return data_;
}
ACE_INLINE
ACE_U_LongLong::~ACE_U_LongLong (void)
{
}
ACE_INLINE bool
ACE_U_LongLong::operator== (const ACE_U_LongLong &n) const
{
return data_ == n.data_;
}
ACE_INLINE bool
ACE_U_LongLong::operator== (const ACE_UINT32 n) const
{
return data_ == n;
}
ACE_INLINE bool
ACE_U_LongLong::operator!= (const ACE_U_LongLong &n) const
{
return ! (*this == n);
}
ACE_INLINE bool
ACE_U_LongLong::operator!= (const ACE_UINT32 n) const
{
return ! (*this == n);
}
ACE_INLINE bool
ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const
{
@@ -74,22 +89,27 @@ ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const
else
return data_ < n.data_;
}
ACE_INLINE bool
ACE_U_LongLong::operator< (const ACE_UINT32 n) const
{
return operator< (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE bool
ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const
{
if (data_ == n.data_) return true;
return data_ < n.data_;
}
ACE_INLINE bool
ACE_U_LongLong::operator<= (const ACE_UINT32 n) const
{
return operator<= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE bool
ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const
{
@@ -104,33 +124,41 @@ ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const
else
return data_ > n.data_;
}
ACE_INLINE bool
ACE_U_LongLong::operator> (const ACE_UINT32 n) const
{
return operator> (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE bool
ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const
{
if (data_ == n.data_) return true;
return data_ > n.data_;
}
ACE_INLINE bool
ACE_U_LongLong::operator>= (const ACE_UINT32 n) const
{
return operator>= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE
ACE_U_LongLong::ACE_U_LongLong (const ACE_U_LongLong &n)
: data_ (n.data_)
{
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator= (const ACE_U_LongLong &n)
{
data_ = n.data_;
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator= (const ACE_INT32 &rhs)
{
@@ -147,107 +175,135 @@ ACE_U_LongLong::operator= (const ACE_INT32 &rhs)
// implementation is to simply set all bits to zero.
data_ = 0;
}
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator= (const ACE_UINT32 &rhs)
{
data_ = rhs;
return *this;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator+ (const ACE_U_LongLong &n) const
{
return data_ + n.data_;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator+ (const ACE_UINT32 n) const
{
return operator+ (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator- (const ACE_U_LongLong &n) const
{
return data_ - n.data_;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator- (const ACE_UINT32 n) const
{
return operator- (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator<< (const u_int n) const
{
return data_ << n;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator<<= (const u_int n)
{
data_ <<= n;
return *this;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator>> (const u_int n) const
{
return data_ >> n;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator>>= (const u_int n)
{
data_ >>= n;
return *this;
}
ACE_INLINE double
ACE_U_LongLong::operator/ (const double n) const
{
return data_ / n;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator+= (const ACE_U_LongLong &n)
{
data_ += n.data_;
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator+= (const ACE_UINT32 n)
{
return operator+= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator* (const ACE_UINT32 n) const
{
return data_ * n;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator*= (const ACE_UINT32 n)
{
data_ *= n;
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator-= (const ACE_U_LongLong &n)
{
data_ -= n.data_;
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator-= (const ACE_UINT32 n)
{
return operator-= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator++ ()
{
++data_;
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator-- ()
{
--data_;
return *this;
}
ACE_INLINE const ACE_U_LongLong
ACE_U_LongLong::operator++ (int)
{
@@ -257,6 +313,7 @@ ACE_U_LongLong::operator++ (int)
++*this;
return temp;
}
ACE_INLINE const ACE_U_LongLong
ACE_U_LongLong::operator-- (int)
{
@@ -266,139 +323,170 @@ ACE_U_LongLong::operator-- (int)
--*this;
return temp;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator|= (const ACE_U_LongLong n)
{
data_ |= n.data_;
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator|= (const ACE_UINT32 n)
{
return operator|= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator&= (const ACE_U_LongLong n)
{
data_ &= n.data_;
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator&= (const ACE_UINT32 n)
{
return operator&= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const ACE_UINT32 n) const
{
return data_ / n;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator% (const ACE_UINT32 n) const
{
return data_ % n;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator| (const ACE_INT32 n) const
{
return data_ | n;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator& (const ACE_INT32 n) const
{
return data_ & n;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator* (const ACE_INT32 n) const
{
return operator* ((ACE_UINT32) n);
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator*= (const ACE_INT32 n)
{
return operator*= ((ACE_UINT32) n);
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const ACE_INT32 n) const
{
return operator/ ((ACE_UINT32) n);
}
#if ACE_SIZEOF_INT == 4
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const u_long n) const
{
return operator/ ((ACE_UINT32) n);
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const long n) const
{
return operator/ ((ACE_UINT32) n);
}
#else /* ACE_SIZEOF_INT != 4 */
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const u_int n) const
{
return operator/ ((ACE_UINT32) n);
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const int n) const
{
return operator/ ((ACE_UINT32) n);
}
#endif
ACE_END_VERSIONED_NAMESPACE_DECL
#elif defined (ACE_LACKS_LONGLONG_T)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_U_LongLong::ACE_U_LongLong (const ACE_UINT32 lo, const ACE_UINT32 hi)
{
h_ () = hi;
l_ () = lo;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::hi (void) const
{
return h_ ();
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::lo (void) const
{
return l_ ();
}
ACE_INLINE void
ACE_U_LongLong::hi (const ACE_UINT32 hi)
{
h_ () = hi;
}
ACE_INLINE void
ACE_U_LongLong::lo (const ACE_UINT32 lo)
{
l_ () = lo;
}
ACE_INLINE
ACE_U_LongLong::~ACE_U_LongLong (void)
{
}
ACE_INLINE bool
ACE_U_LongLong::operator== (const ACE_U_LongLong &n) const
{
return h_ () == n.h_ () && l_ () == n.l_ ();
}
ACE_INLINE bool
ACE_U_LongLong::operator== (const ACE_UINT32 n) const
{
return h_ () == 0 && l_ () == n;
}
ACE_INLINE bool
ACE_U_LongLong::operator!= (const ACE_U_LongLong &n) const
{
return ! (*this == n);
}
ACE_INLINE bool
ACE_U_LongLong::operator!= (const ACE_UINT32 n) const
{
return ! (*this == n);
}
ACE_INLINE bool
ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const
{
@@ -406,11 +494,13 @@ ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const
: h_ () > n.h_ () ? 0
: l_ () < n.l_ ();
}
ACE_INLINE bool
ACE_U_LongLong::operator< (const ACE_UINT32 n) const
{
return operator< (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE bool
ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const
{
@@ -418,11 +508,13 @@ ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const
: h_ () > n.h_ () ? 0
: l_ () <= n.l_ ();
}
ACE_INLINE bool
ACE_U_LongLong::operator<= (const ACE_UINT32 n) const
{
return operator<= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE bool
ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const
{
@@ -430,11 +522,13 @@ ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const
: h_ () < n.h_ () ? 0
: l_ () > n.l_ ();
}
ACE_INLINE bool
ACE_U_LongLong::operator> (const ACE_UINT32 n) const
{
return operator> (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE bool
ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const
{
@@ -442,24 +536,29 @@ ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const
: h_ () < n.h_ () ? 0
: l_ () >= n.l_ ();
}
ACE_INLINE bool
ACE_U_LongLong::operator>= (const ACE_UINT32 n) const
{
return operator>= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE
ACE_U_LongLong::ACE_U_LongLong (const ACE_U_LongLong &n)
{
h_ () = n.h_ ();
l_ () = n.l_ ();
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator= (const ACE_U_LongLong &n)
{
h_ () = n.h_ ();
l_ () = n.l_ ();
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator= (const ACE_INT32 &rhs)
{
@@ -477,131 +576,168 @@ ACE_U_LongLong::operator= (const ACE_INT32 &rhs)
l_ () = 0;
h_ () = 0;
}
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator= (const ACE_UINT32 &rhs)
{
l_ () = rhs;
h_ () = 0;
return *this;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator+ (const ACE_U_LongLong &n) const
{
ACE_U_LongLong ret (l_ () + n.l_ (), h_ () + n.h_ ());
if (ret.l_ () < n.l_ ()) /* carry */ ++ret.h_ ();
return ret;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator+ (const ACE_UINT32 n) const
{
return operator+ (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator- (const ACE_U_LongLong &n) const
{
ACE_U_LongLong ret (l_ () - n.l_ (), h_ () - n.h_ ());
if (l_ () < n.l_ ()) /* borrow */ --ret.h_ ();
return ret;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator- (const ACE_UINT32 n) const
{
return operator- (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator<< (const u_int n) const
{
const ACE_UINT32 carry_mask = l_ () >> (32 - n);
ACE_U_LongLong ret (n < 32 ? l_ () << n : 0,
n < 32 ? (h_ () << n) | carry_mask : carry_mask);
return ret;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator<<= (const u_int n)
{
const ACE_UINT32 carry_mask = l_ () >> (32 - n);
h_ () = n < 32 ? (h_ () << n) | carry_mask : carry_mask;
// g++ 2.7.2.3/Solaris 2.5.1 doesn't modify l_ () if shifted by 32.
l_ () = n < 32 ? l_ () << n : 0;
return *this;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator>> (const u_int n) const
{
const ACE_UINT32 carry_mask = h_ () << (32 - n);
ACE_U_LongLong ret (n < 32 ? (l_ () >> n) | carry_mask : 0,
n < 32 ? h_ () >> n : 0);
return ret;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator>>= (const u_int n)
{
const ACE_UINT32 carry_mask = h_ () << (32 - n);
l_ () = n < 32 ? (l_ () >> n) | carry_mask : carry_mask;
h_ () = n < 32 ? h_ () >> n : 0;
return *this;
}
ACE_INLINE double
ACE_U_LongLong::operator/ (const double n) const
{
// See the derivation above in operator/ (const ACE_UINT32).
return ((double) 0xffffffffu - n + 1.0) / n * h_ () +
(double) h_ () + (double) l_ () / n;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator+= (const ACE_U_LongLong &n)
{
h_ () += n.h_ ();
l_ () += n.l_ ();
if (l_ () < n.l_ ()) /* carry */ ++h_ ();
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator+= (const ACE_UINT32 n)
{
return operator+= (static_cast<const ACE_U_LongLong> (n));
}
#define ACE_HIGHBIT (~(~0UL >> 1))
ACE_INLINE ACE_UINT32
ACE_U_LongLong::ul_shift (ACE_UINT32 a, ACE_UINT32 c_in, ACE_UINT32 *c_out) const
{
const ACE_UINT32 b = (a << 1) | c_in;
*c_out = (*c_out << 1) + ((a & ACE_HIGHBIT) > 0);
return b;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::ull_shift (ACE_U_LongLong a,
ACE_UINT32 c_in,
ACE_UINT32 *c_out) const
{
ACE_U_LongLong b;
b.l_ () = (a.l_ () << 1) | c_in;
c_in = ((a.l_ () & ACE_HIGHBIT) > 0);
b.h_ () = (a.h_ () << 1) | c_in;
*c_out = (*c_out << 1) + ((a.h_ () & ACE_HIGHBIT) > 0);
return b;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::ull_add (ACE_U_LongLong a, ACE_U_LongLong b, ACE_UINT32 *carry) const
{
ACE_U_LongLong r (0, 0);
ACE_UINT32 c1, c2, c3, c4;
c1 = a.l_ () % 2;
c2 = b.l_ () % 2;
c3 = 0;
r.l_ () = a.l_ ()/2 + b.l_ ()/2 + (c1+c2)/2;
r.l_ () = ul_shift (r.l_ (), (c1+c2)%2, &c3);
c1 = a.h_ () % 2;
c2 = b.h_ () % 2;
c4 = 0;
r.h_ () = a.h_ ()/2 + b.h_ ()/2 + (c1+c2+c3)/2;
r.h_ () = ul_shift (r.h_ (), (c1+c2+c3)%2, &c4);
*carry = c4;
return r;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::ull_mult (ACE_U_LongLong a, ACE_UINT32 b, ACE_UINT32 *carry) const
{
@@ -609,6 +745,7 @@ ACE_U_LongLong::ull_mult (ACE_U_LongLong a, ACE_UINT32 b, ACE_UINT32 *carry) con
const ACE_U_LongLong zero (0, 0);
ACE_U_LongLong accum (0, 0);
ACE_UINT32 c;
*carry = 0;
if (b > 0)
do
@@ -622,47 +759,60 @@ ACE_U_LongLong::ull_mult (ACE_U_LongLong a, ACE_UINT32 b, ACE_UINT32 *carry) con
mask >>= 1;
}
while (mask > 0);
return accum;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator* (const ACE_UINT32 n) const
{
ACE_UINT32 carry; // will throw the carry away
return ull_mult (*this, n, &carry);
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator*= (const ACE_UINT32 n)
{
ACE_UINT32 carry; // will throw the carry away
return *this = ull_mult (*this, n, &carry);
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator-= (const ACE_U_LongLong &n)
{
h_ () -= n.h_ ();
if (l_ () < n.l_ ()) /* borrow */ --h_ ();
l_ () -= n.l_ ();
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator-= (const ACE_UINT32 n)
{
return operator-= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator++ ()
{
++l_ ();
if (l_ () == 0) /* carry */ ++h_ ();
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator-- ()
{
if (l_ () == 0) /* borrow */ --h_ ();
--l_ ();
return *this;
}
ACE_INLINE const ACE_U_LongLong
ACE_U_LongLong::operator++ (int)
{
@@ -672,6 +822,7 @@ ACE_U_LongLong::operator++ (int)
++*this;
return temp;
}
ACE_INLINE const ACE_U_LongLong
ACE_U_LongLong::operator-- (int)
{
@@ -681,30 +832,37 @@ ACE_U_LongLong::operator-- (int)
--*this;
return temp;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator|= (const ACE_U_LongLong n)
{
l_ () |= n.l_ ();
h_ () |= n.h_ ();
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator|= (const ACE_UINT32 n)
{
return operator|= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator&= (const ACE_U_LongLong n)
{
l_ () &= n.l_ ();
h_ () &= n.h_ ();
return *this;
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator&= (const ACE_UINT32 n)
{
return operator&= (static_cast<const ACE_U_LongLong> (n));
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const ACE_UINT32 n) const
{
@@ -716,8 +874,10 @@ ACE_U_LongLong::operator/ (const ACE_UINT32 n) const
// = ((0x100000000u - n) / n * hi_ + hi_ * n / n + lo_ / n
// = (0x100000000u - n) / n * hi_ + hi_ + lo_ / n
// = (0xffffffffu - n + 1) / n * hi_ + hi_ + lo_ / n
return (0xffffffffu - n + 1) / n * h_ () + h_ () + l_ () / n;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator% (const ACE_UINT32 n) const
{
@@ -728,55 +888,67 @@ ACE_U_LongLong::operator% (const ACE_UINT32 n) const
// = (0x100000000u % n * hi_ + lo_ % n) % n
// = ((0x100000000u - n) % n * hi_ + lo_ % n) % n
// = ((0xffffffffu - n + 1) % n * hi_ + lo_ % n) % n
return ((0xffffffff - n + 1) % n * h_ () + l_ () % n) % n;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator| (const ACE_INT32 n) const
{
return l_ () | n;
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator& (const ACE_INT32 n) const
{
return l_ () & n;
}
ACE_INLINE ACE_U_LongLong
ACE_U_LongLong::operator* (const ACE_INT32 n) const
{
return operator* ((ACE_UINT32) n);
}
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator*= (const ACE_INT32 n)
{
return operator*= ((ACE_UINT32) n);
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const ACE_INT32 n) const
{
return operator/ ((ACE_UINT32) n);
}
#if ACE_SIZEOF_INT == 4
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const u_long n) const
{
return operator/ ((ACE_UINT32) n);
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const long n) const
{
return operator/ ((ACE_UINT32) n);
}
#else /* ACE_SIZEOF_INT != 4 */
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const u_int n) const
{
return operator/ ((ACE_UINT32) n);
}
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const int n) const
{
return operator/ ((ACE_UINT32) n);
}
#endif /* ACE_SIZEOF_INT != 4 */
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */
+83
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file Bound_Ptr.h
@@ -9,15 +10,22 @@
* @author Boris Kolpackov <boris@codesynthesis.com>
*/
//=============================================================================
#ifndef ACE_BOUND_PTR_H
#define ACE_BOUND_PTR_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Auto_Ptr.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Bound_Ptr_Counter
*
@@ -33,45 +41,61 @@ class ACE_Bound_Ptr_Counter
public:
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
ACE_Bound_Ptr_Counter (long init_obj_ref_count = 0);
~ACE_Bound_Ptr_Counter (void);
/// Create a ACE_Bound_Ptr_Counter<ACE_LOCK> and initialize the
/// reference count to indicate ownership by a strong pointer.
static ACE_Bound_Ptr_Counter<ACE_LOCK> *create_strong (void);
/// Increase both the object and counter reference counts and return
/// the new object reference count. A return value of -1 indicates
/// that the object has already been destroyed.
static long attach_strong (ACE_Bound_Ptr_Counter<ACE_LOCK> *counter);
/// Decreases both the object and counter reference counts and
/// deletes whichever has no more references. Returns the new object
/// reference count.
static long detach_strong (ACE_Bound_Ptr_Counter<ACE_LOCK> *counter);
/// Create a ACE_Bound_Ptr_Counter<ACE_LOCK> and initialize the
/// reference count to indicate no ownership.
static ACE_Bound_Ptr_Counter<ACE_LOCK> *create_weak (void);
/// Increase the counter reference count and return argument.
static void attach_weak (ACE_Bound_Ptr_Counter<ACE_LOCK> *counter);
/// Decreases the counter reference count and deletes the counter if
/// it has no more references.
static void detach_weak (ACE_Bound_Ptr_Counter<ACE_LOCK> *counter);
/// Determine whether the object has been deleted.
static bool object_was_deleted (ACE_Bound_Ptr_Counter<ACE_LOCK> *counter);
private:
/// Allocate a new ACE_Bound_Ptr_Counter<ACE_LOCK> instance,
/// returning NULL if it cannot be created.
static ACE_Bound_Ptr_Counter<ACE_LOCK> *internal_create (long init_obj_ref_count);
private:
/// Reference count of underlying object. Is set to -1 once the
/// object has been destroyed to indicate to all weak pointers that
/// it is no longer valid.
long obj_ref_count_;
/// Reference count of this counter.
long self_ref_count_;
/// Mutex variable to synchronize access to the reference counts.
ACE_LOCK lock_;
};
// Forward decl.
template <class X, class ACE_LOCK> class ACE_Weak_Bound_Ptr;
/**
* @class ACE_Strong_Bound_Ptr
*
@@ -91,13 +115,17 @@ public:
/// Constructor that initializes an ACE_Strong_Bound_Ptr to point to the
/// object \<p\> immediately.
explicit ACE_Strong_Bound_Ptr (X *p = 0);
/// Constructor that initializes an ACE_Strong_Bound_Ptr by stealing
/// ownership of an object from an auto_ptr.
explicit ACE_Strong_Bound_Ptr (auto_ptr<X> p);
/// Copy constructor binds @c this and @a r to the same object.
ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r);
/// Constructor binds @c this and @a r to the same object.
ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r);
/// Copy constructor binds @c this and @a r to the same object if
/// Y* can be implicitly converted to X*.
template <class Y>
@@ -110,12 +138,16 @@ public:
//
COUNTER::attach_strong (this->counter_);
}
/// Destructor.
~ACE_Strong_Bound_Ptr (void);
/// Assignment operator that binds @c this and @a r to the same object.
void operator = (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r);
/// Assignment operator that binds @c this and @a r to the same object.
void operator = (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r);
/// Assignment operator that binds @c this and @a r to the same object
/// if Y* can be implicitly converted to X*.
template <class Y>
@@ -125,7 +157,9 @@ public:
// This operator is temporarily defined here to increase our chances
// of being accepted by broken compilers.
//
// This will work if &r == this, by first increasing the ref count
COUNTER *new_counter = r.counter_;
X* new_ptr = dynamic_cast<X_t*> (r.ptr_);
COUNTER::attach_strong (new_counter);
@@ -133,8 +167,10 @@ public:
delete this->ptr_;
this->counter_ = new_counter;
this->ptr_ = new_ptr;
return *this;
}
/// Equality operator that returns @c true if both
/// ACE_Strong_Bound_Ptr instances point to the same underlying
/// object.
@@ -143,6 +179,7 @@ public:
* instantiated and not used yet.
*/
bool operator == (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Equality operator that returns true if the ACE_Strong_Bound_Ptr
/// and ACE_Weak_Bound_Ptr objects point to the same underlying
/// object.
@@ -151,46 +188,64 @@ public:
* instantiated and not used yet.
*/
bool operator == (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Equality operator that returns @c true if the
/// ACE_Strong_Bound_Ptr and the raw pointer point to the same
/// underlying object.
bool operator == (X *p) const;
/// Inequality operator, which is the opposite of equality.
bool operator != (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Inequality operator, which is the opposite of equality.
bool operator != (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Inequality operator, which is the opposite of equality.
bool operator != (X *p) const;
/// Redirection operator
X *operator-> (void) const;
/// Dereference operator
X &operator * (void) const;
/// Get the pointer value.
X *get (void) const;
/// Resets the ACE_Strong_Bound_Ptr to refer to a different
/// underlying object.
void reset (X *p = 0);
/// Resets the ACE_Strong_Bound_Ptr to refer to a different
/// underlying object, ownership of which is stolen from the
/// auto_ptr.
void reset (auto_ptr<X> p);
/// Allows us to check for NULL on all ACE_Strong_Bound_Ptr
/// objects.
int null (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
typedef X X_t; // This indirection is for Borland C++.
friend class ACE_Weak_Bound_Ptr<X, ACE_LOCK>;
template <class Y, class L>
friend class ACE_Strong_Bound_Ptr;
/// The ACE_Bound_Ptr_Counter type.
typedef ACE_Bound_Ptr_Counter<ACE_LOCK> COUNTER;
/// The reference counter.
COUNTER *counter_;
/// The underlying object.
X *ptr_;
};
/**
* @class ACE_Weak_Bound_Ptr
*
@@ -214,16 +269,22 @@ public:
/// Constructor that initializes an ACE_Weak_Bound_Ptr to point to
/// the object \<p\> immediately.
explicit ACE_Weak_Bound_Ptr (X *p = 0);
/// Copy constructor binds @c this and @a r to the same object.
ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r);
/// Constructor binds @c this and @a r to the same object.
ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r);
/// Destructor.
~ACE_Weak_Bound_Ptr (void);
/// Assignment operator that binds @c this and @a r to the same object.
void operator = (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r);
/// Assignment operator that binds @c this and @a r to the same object.
void operator = (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r);
/// Equality operator that returns @c true if both
/// ACE_Weak_Bound_Ptr objects point to the same underlying object.
/**
@@ -231,6 +292,7 @@ public:
* instantiated and not used yet.
*/
bool operator == (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Equality operator that returns @c true if the ACE_Weak_Bound_Ptr
/// and ACE_Strong_Bound_Ptr objects point to the same underlying
/// object.
@@ -239,15 +301,20 @@ public:
* instantiated and not used yet.
*/
bool operator == (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Equality operator that returns @c true if the ACE_Weak_Bound_Ptr
/// and the raw pointer point to the same underlying object.
bool operator == (X *p) const;
/// Inequality operator, which is the opposite of equality.
bool operator != (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Inequality operator, which is the opposite of equality.
bool operator != (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const;
/// Inequality operator, which is the opposite of equality.
bool operator != (X *p) const;
/// Redirection operator.
/**
* It returns a temporary strong pointer and makes use of the
@@ -257,17 +324,21 @@ public:
* the locking overhead, then use the unsafe_get method instead.
*/
ACE_Strong_Bound_Ptr<X, ACE_LOCK> operator-> (void) const;
/// Obtain a strong pointer corresponding to this weak pointer. This
/// function is useful to create a temporary strong pointer for
/// conversion to a reference.
ACE_Strong_Bound_Ptr<X, ACE_LOCK> strong (void) const;
/// Get the pointer value. Warning: this does not affect the
/// reference count of the underlying object, so it may disappear on
/// you while you are using it if you are not careful.
X *unsafe_get (void) const;
/// Resets the ACE_Weak_Bound_Ptr to refer to a different underlying
/// object.
void reset (X *p = 0);
/// Increment the reference count on the underlying object.
/**
* Returns the new reference count on the object. This function may
@@ -276,6 +347,7 @@ public:
* servants.
*/
long add_ref (void);
/// Decrement the reference count on the underlying object, which is deleted
/// if the count has reached zero.
/**
@@ -285,22 +357,33 @@ public:
* servants.
*/
long remove_ref (void);
/// Allows us to check for NULL on all ACE_Weak_Bound_Ptr objects.
int null (void) const;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
private:
typedef X X_t; // This indirection is for Borland C++.
friend class ACE_Strong_Bound_Ptr<X, ACE_LOCK>;
/// The ACE_Bound_Ptr_Counter type.
typedef ACE_Bound_Ptr_Counter<ACE_LOCK> COUNTER;
/// The reference counter.
COUNTER *counter_;
/// The underlying object.
X *ptr_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#include "ace/Bound_Ptr.inl"
#include /**/ "ace/post.h"
#endif /* ACE_BOUND_PTR_H */
+80
View File
@@ -1,11 +1,15 @@
/* -*- C++ -*- */
// $Id: Bound_Ptr.inl 80826 2008-03-04 14:51:23Z wotte $
// Bound_Ptr.i
#include "ace/Guard_T.h"
#if !defined (ACE_NEW_THROWS_EXCEPTIONS)
# include "ace/Log_Msg.h"
#endif /* ACE_NEW_THROWS_EXCEPTIONS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class ACE_LOCK> inline ACE_Bound_Ptr_Counter<ACE_LOCK> *
ACE_Bound_Ptr_Counter<ACE_LOCK>::internal_create (long init_obj_ref_count)
{
@@ -15,6 +19,7 @@ ACE_Bound_Ptr_Counter<ACE_LOCK>::internal_create (long init_obj_ref_count)
0);
return temp;
}
template <class ACE_LOCK> inline ACE_Bound_Ptr_Counter<ACE_LOCK> *
ACE_Bound_Ptr_Counter<ACE_LOCK>::create_strong (void)
{
@@ -29,43 +34,57 @@ ACE_Bound_Ptr_Counter<ACE_LOCK>::create_strong (void)
return temp;
}
template <class ACE_LOCK> inline long
ACE_Bound_Ptr_Counter<ACE_LOCK>::attach_strong (ACE_Bound_Ptr_Counter<ACE_LOCK>* counter)
{
ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, -1);
// Can't attach a strong pointer to an object that has already been deleted.
if (counter->obj_ref_count_ == -1)
return -1;
long new_obj_ref_count = ++counter->obj_ref_count_;
++counter->self_ref_count_;
return new_obj_ref_count;
}
template <class ACE_LOCK> inline long
ACE_Bound_Ptr_Counter<ACE_LOCK>::detach_strong (ACE_Bound_Ptr_Counter<ACE_LOCK>* counter)
{
ACE_Bound_Ptr_Counter<ACE_LOCK> *counter_del = 0;
long new_obj_ref_count;
{
ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, -1);
if ((new_obj_ref_count = --counter->obj_ref_count_) == 0)
// Change the object reference count to -1 to indicate that the
// object has been deleted, as opposed to a weak pointer that
// simply hasn't had any strong pointers created from it yet.
counter->obj_ref_count_ = -1;
if (--counter->self_ref_count_ == 0)
// Since counter contains the lock held by the ACE_Guard, the
// guard needs to be released before freeing the memory holding
// the lock. So save the pointer to free, then release, then
// free.
counter_del = counter;
} // Release the lock
delete counter_del;
return new_obj_ref_count;
}
template <class ACE_LOCK> inline ACE_Bound_Ptr_Counter<ACE_LOCK> *
ACE_Bound_Ptr_Counter<ACE_LOCK>::create_weak (void)
{
// Set initial object reference count to 0.
ACE_Bound_Ptr_Counter<ACE_LOCK> *temp = internal_create (0);
#if defined (ACE_NEW_THROWS_EXCEPTIONS)
if (temp == 0)
@@ -75,55 +94,69 @@ ACE_Bound_Ptr_Counter<ACE_LOCK>::create_weak (void)
#endif /* ACE_NEW_THROWS_EXCEPTIONS */
return temp;
}
template <class ACE_LOCK> inline void
ACE_Bound_Ptr_Counter<ACE_LOCK>::attach_weak (ACE_Bound_Ptr_Counter<ACE_LOCK>* counter)
{
ACE_GUARD (ACE_LOCK, guard, counter->lock_);
++counter->self_ref_count_;
}
template <class ACE_LOCK> inline void
ACE_Bound_Ptr_Counter<ACE_LOCK>::detach_weak (ACE_Bound_Ptr_Counter<ACE_LOCK>* counter)
{
ACE_Bound_Ptr_Counter<ACE_LOCK> *counter_del = 0;
{
ACE_GUARD (ACE_LOCK, guard, counter->lock_);
if (--counter->self_ref_count_ == 0)
// Since counter contains the lock held by the ACE_Guard, the
// guard needs to be released before freeing the memory holding
// the lock. So save the pointer to free, then release, then
// free.
counter_del = counter;
} // Release the lock
delete counter_del;
}
template <class ACE_LOCK> inline bool
ACE_Bound_Ptr_Counter<ACE_LOCK>::object_was_deleted (ACE_Bound_Ptr_Counter<ACE_LOCK> *counter)
{
ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, 0);
return counter->obj_ref_count_ == -1;
}
template <class ACE_LOCK> inline
ACE_Bound_Ptr_Counter<ACE_LOCK>::ACE_Bound_Ptr_Counter (long init_obj_ref_count)
: obj_ref_count_ (init_obj_ref_count),
self_ref_count_ (1)
{
}
template <class ACE_LOCK> inline
ACE_Bound_Ptr_Counter<ACE_LOCK>::~ACE_Bound_Ptr_Counter (void)
{
}
template <class X, class ACE_LOCK> inline
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::ACE_Strong_Bound_Ptr (X *p)
: counter_ (COUNTER::create_strong ()),
ptr_ (p)
{
}
template <class X, class ACE_LOCK> inline
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::ACE_Strong_Bound_Ptr (auto_ptr<X> p)
: counter_ (COUNTER::create_strong ()),
ptr_ (p.release())
{
}
template <class X, class ACE_LOCK> inline
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r)
: counter_ (r.counter_),
@@ -131,6 +164,7 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_
{
COUNTER::attach_strong (this->counter_);
}
template <class X, class ACE_LOCK> inline
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r)
: counter_ (r.counter_),
@@ -146,12 +180,14 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Pt
this->ptr_ = 0;
}
}
template <class X, class ACE_LOCK> inline
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::~ACE_Strong_Bound_Ptr (void)
{
if (COUNTER::detach_strong (this->counter_) == 0)
delete this->ptr_;
}
template <class X, class ACE_LOCK> inline void
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &rhs)
{
@@ -159,6 +195,7 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Strong_Bound_Ptr<X, ACE
// why go through all that?
if (&rhs == this)
return;
COUNTER *new_counter = rhs.counter_;
X_t *new_ptr = rhs.ptr_;
COUNTER::attach_strong (new_counter);
@@ -167,6 +204,7 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Strong_Bound_Ptr<X, ACE
this->counter_ = new_counter;
this->ptr_ = new_ptr;
}
template <class X, class ACE_LOCK> inline void
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &rhs)
{
@@ -174,8 +212,10 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Weak_Bound_Ptr<X, ACE_L
// why go through all that?
if (&rhs == this)
return;
COUNTER *new_counter = rhs.counter_;
X_t *new_ptr = rhs.ptr_;
// When creating a strong pointer from a weak one we can't assume that the
// underlying object still exists. Therefore we must check for a return value
// of -1, which indicates that the object has been destroyed.
@@ -185,63 +225,75 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Weak_Bound_Ptr<X, ACE_L
new_counter = COUNTER::create_strong ();
new_ptr = 0;
}
if (COUNTER::detach_strong (this->counter_) == 0)
delete this->ptr_;
this->counter_ = new_counter;
this->ptr_ = new_ptr;
}
template <class X, class ACE_LOCK> inline bool
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator== (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const
{
return this->ptr_ == r.ptr_;
}
template <class X, class ACE_LOCK> inline bool
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator== (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const
{
// Use the weak pointer's operator== since it will check for null.
return r == *this;
}
template <class X, class ACE_LOCK> inline bool
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator== (X *p) const
{
return this->ptr_ == p;
}
template <class X, class ACE_LOCK> inline bool
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator!= (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const
{
return this->ptr_ != r.ptr_;
}
template <class X, class ACE_LOCK> inline bool
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator!= (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const
{
// Use the weak pointer's operator!= since it will check for null.
return r != *this;
}
template <class X, class ACE_LOCK> inline bool
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator!= (X *p) const
{
return this->ptr_ != p;
}
template <class X, class ACE_LOCK> inline X *
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator-> (void) const
{
return this->ptr_;
}
template<class X, class ACE_LOCK> inline X &
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::operator *() const
{
return *this->ptr_;
}
template <class X, class ACE_LOCK> inline X*
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::get (void) const
{
return this->ptr_;
}
template <class X, class ACE_LOCK> inline int
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::null (void) const
{
return this->ptr_ == 0;
}
template<class X, class ACE_LOCK> inline void
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::reset (X *p)
{
@@ -252,6 +304,7 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::reset (X *p)
if (COUNTER::detach_strong (old_counter) == 0)
delete old_ptr;
}
template<class X, class ACE_LOCK> inline void
ACE_Strong_Bound_Ptr<X, ACE_LOCK>::reset (auto_ptr<X> p)
{
@@ -262,12 +315,14 @@ ACE_Strong_Bound_Ptr<X, ACE_LOCK>::reset (auto_ptr<X> p)
if (COUNTER::detach_strong (old_counter) == 0)
delete old_ptr;
}
template <class X, class ACE_LOCK> inline
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::ACE_Weak_Bound_Ptr (X *p)
: counter_ (COUNTER::create_weak ()),
ptr_ (p)
{
}
template <class X, class ACE_LOCK> inline
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r)
: counter_ (r.counter_),
@@ -275,6 +330,7 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr<X,
{
COUNTER::attach_weak (this->counter_);
}
template <class X, class ACE_LOCK> inline
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r)
: counter_ (r.counter_),
@@ -282,11 +338,13 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr<
{
COUNTER::attach_weak (this->counter_);
}
template <class X, class ACE_LOCK> inline
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::~ACE_Weak_Bound_Ptr (void)
{
COUNTER::detach_weak (this->counter_);
}
template <class X, class ACE_LOCK> inline void
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &rhs)
{
@@ -297,6 +355,7 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Weak_Bound_Ptr<X, ACE_LOC
this->counter_ = new_counter;
this->ptr_ = rhs.ptr_;
}
template <class X, class ACE_LOCK> inline void
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &rhs)
{
@@ -307,6 +366,7 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator = (const ACE_Strong_Bound_Ptr<X, ACE_L
this->counter_ = new_counter;
this->ptr_ = rhs.ptr_;
}
template <class X, class ACE_LOCK> inline bool
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator== (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const
{
@@ -314,8 +374,10 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator== (const ACE_Weak_Bound_Ptr<X, ACE_LOC
// if the underlying object has been deleted.
if (COUNTER::object_was_deleted (this->counter_))
return r.ptr_ == 0;
return this->ptr_ == r.ptr_;
}
template <class X, class ACE_LOCK> inline bool
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator== (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const
{
@@ -323,8 +385,10 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator== (const ACE_Strong_Bound_Ptr<X, ACE_L
// if the underlying object has been deleted.
if (COUNTER::object_was_deleted (this->counter_))
return r.ptr_ == 0;
return this->ptr_ == r.ptr_;
}
template <class X, class ACE_LOCK> inline bool
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator== (X *p) const
{
@@ -332,8 +396,10 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator== (X *p) const
// if the underlying object has been deleted.
if (COUNTER::object_was_deleted (this->counter_))
return p == 0;
return this->ptr_ == p;
}
template <class X, class ACE_LOCK> inline bool
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator!= (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r) const
{
@@ -341,8 +407,10 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator!= (const ACE_Weak_Bound_Ptr<X, ACE_LOC
// if the underlying object has been deleted.
if (COUNTER::object_was_deleted (this->counter_))
return r.ptr_ != 0;
return this->ptr_ != r.ptr_;
}
template <class X, class ACE_LOCK> inline bool
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator!= (const ACE_Strong_Bound_Ptr<X, ACE_LOCK> &r) const
{
@@ -350,8 +418,10 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator!= (const ACE_Strong_Bound_Ptr<X, ACE_L
// if the underlying object has been deleted.
if (COUNTER::object_was_deleted (this->counter_))
return r.ptr_ != 0;
return this->ptr_ != r.ptr_;
}
template <class X, class ACE_LOCK> inline bool
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator!= (X *p) const
{
@@ -359,18 +429,22 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator!= (X *p) const
// if the underlying object has been deleted.
if (COUNTER::object_was_deleted (this->counter_))
return p != 0;
return this->ptr_ != p;
}
template <class X, class ACE_LOCK> inline ACE_Strong_Bound_Ptr<X, ACE_LOCK>
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::operator-> (void) const
{
return ACE_Strong_Bound_Ptr<X, ACE_LOCK> (*this);
}
template <class X, class ACE_LOCK> inline ACE_Strong_Bound_Ptr<X, ACE_LOCK>
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::strong (void) const
{
return ACE_Strong_Bound_Ptr<X, ACE_LOCK> (*this);
}
template <class X, class ACE_LOCK> inline X*
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::unsafe_get (void) const
{
@@ -378,6 +452,7 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::unsafe_get (void) const
// is defined to be unsafe!
return this->ptr_;
}
template <class X, class ACE_LOCK> inline int
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::null (void) const
{
@@ -385,8 +460,10 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::null (void) const
// if the underlying object has been deleted.
if (COUNTER::object_was_deleted (this->counter_))
return 1;
return this->ptr_ == 0;
}
template<class X, class ACE_LOCK> inline void
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::reset (X *p)
{
@@ -395,11 +472,13 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::reset (X *p)
this->ptr_ = p;
COUNTER::detach_weak (old_counter);
}
template<class X, class ACE_LOCK> inline long
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::add_ref ()
{
return COUNTER::attach_strong (counter_);
}
template<class X, class ACE_LOCK> inline long
ACE_Weak_Bound_Ptr<X, ACE_LOCK>::remove_ref ()
{
@@ -411,4 +490,5 @@ ACE_Weak_Bound_Ptr<X, ACE_LOCK>::remove_ref ()
}
return new_obj_ref_count;
}
ACE_END_VERSIONED_NAMESPACE_DECL
+95
View File
@@ -1,27 +1,36 @@
#include "ace/CDR_Base.h"
#if !defined (__ACE_INLINE__)
# include "ace/CDR_Base.inl"
#endif /* ! __ACE_INLINE__ */
#include "ace/Message_Block.h"
#include "ace/OS_Memory.h"
#include "ace/OS_NS_string.h"
ACE_RCSID (ace,
CDR_Base,
"$Id: CDR_Base.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (NONNATIVE_LONGDOUBLE)
static const ACE_INT16 max_eleven_bit = 0x3ff;
static const ACE_INT16 max_fifteen_bit = 0x3fff;
#endif /* NONNATIVE_LONGDOUBLE */
//
// See comments in CDR_Base.inl about optimization cases for swap_XX_array.
//
void
ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
{
// ACE_ASSERT(n > 0); The caller checks that n > 0
// We pretend that AMD64/GNU G++ systems have a Pentium CPU to
// take advantage of the inline assembly implementation.
// Later, we try to read in 32 or 64 bit chunks,
// so make sure we don't do that for unaligned addresses.
#if ACE_SIZEOF_LONG == 8 && \
@@ -47,14 +56,17 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
#endif
if (n == 0)
return;
//
// Loop unrolling. Here be dragons.
//
// (n & (~3)) is the greatest multiple of 4 not bigger than n.
// In the while loop ahead, orig will move over the array by 8 byte
// increments (4 elements of 2 bytes).
// end marks our barrier for not falling outside.
char const * const end = orig + 2 * (n & (~3));
// See if we're aligned for writting in 64 or 32 bit chunks...
#if ACE_SIZEOF_LONG == 8 && \
!((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__))
@@ -93,21 +105,27 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
// 64 bit architecture.
register unsigned long a =
* reinterpret_cast<const unsigned long*> (orig);
register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8;
register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8;
a = (a1 | a2);
* reinterpret_cast<unsigned long*> (target) = a;
#else
register ACE_UINT32 a =
* reinterpret_cast<const ACE_UINT32*> (orig);
register ACE_UINT32 b =
* reinterpret_cast<const ACE_UINT32*> (orig + 4);
register ACE_UINT32 a1 = (a & 0x00ff00ffU) << 8;
register ACE_UINT32 b1 = (b & 0x00ff00ffU) << 8;
register ACE_UINT32 a2 = (a & 0xff00ff00U) >> 8;
register ACE_UINT32 b2 = (b & 0xff00ff00U) >> 8;
a = (a1 | a2);
b = (b1 | b2);
* reinterpret_cast<ACE_UINT32*> (target) = a;
* reinterpret_cast<ACE_UINT32*> (target + 4) = b;
#endif
@@ -158,13 +176,17 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
// 64 bit architecture.
register unsigned long a =
* reinterpret_cast<const unsigned long*> (orig);
register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8;
register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8;
a = (a1 | a2);
ACE_UINT16 b1 = static_cast<ACE_UINT16> (a >> 48);
ACE_UINT16 b2 = static_cast<ACE_UINT16> ((a >> 32) & 0xffff);
ACE_UINT16 b3 = static_cast<ACE_UINT16> ((a >> 16) & 0xffff);
ACE_UINT16 b4 = static_cast<ACE_UINT16> (a & 0xffff);
#if defined(ACE_LITTLE_ENDIAN)
* reinterpret_cast<ACE_UINT16*> (target) = b4;
* reinterpret_cast<ACE_UINT16*> (target + 2) = b3;
@@ -181,16 +203,20 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
* reinterpret_cast<const ACE_UINT32*> (orig);
register ACE_UINT32 b =
* reinterpret_cast<const ACE_UINT32*> (orig + 4);
register ACE_UINT32 a1 = (a & 0x00ff00ff) << 8;
register ACE_UINT32 b1 = (b & 0x00ff00ff) << 8;
register ACE_UINT32 a2 = (a & 0xff00ff00) >> 8;
register ACE_UINT32 b2 = (b & 0xff00ff00) >> 8;
a = (a1 | a2);
b = (b1 | b2);
ACE_UINT32 c1 = static_cast<ACE_UINT16> (a >> 16);
ACE_UINT32 c2 = static_cast<ACE_UINT16> (a & 0xffff);
ACE_UINT32 c3 = static_cast<ACE_UINT16> (b >> 16);
ACE_UINT32 c4 = static_cast<ACE_UINT16> (b & 0xffff);
#if defined(ACE_LITTLE_ENDIAN)
* reinterpret_cast<ACE_UINT16*> (target) = c2;
* reinterpret_cast<ACE_UINT16*> (target + 2) = c1;
@@ -203,10 +229,12 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
* reinterpret_cast<ACE_UINT16*> (target + 6) = c4;
#endif
#endif
orig += 8;
target += 8;
}
}
// (n & 3) == (n % 4).
switch (n&3) {
case 3:
@@ -221,10 +249,12 @@ ACE_CDR::swap_2_array (char const * orig, char* target, size_t n)
ACE_CDR::swap_2 (orig, target);
}
}
void
ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
{
// ACE_ASSERT (n > 0); The caller checks that n > 0
#if ACE_SIZEOF_LONG == 8
// Later, we read from *orig in 64 bit chunks,
// so make sure we don't generate unaligned readings.
@@ -238,16 +268,20 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
--n;
}
#endif /* ACE_SIZEOF_LONG == 8 */
if (n == 0)
return;
//
// Loop unrolling. Here be dragons.
//
// (n & (~3)) is the greatest multiple of 4 not bigger than n.
// In the while loop, orig will move over the array by 16 byte
// increments (4 elements of 4 bytes).
// ends marks our barrier for not falling outside.
char const * const end = orig + 4 * (n & (~3));
#if ACE_SIZEOF_LONG == 8
// 64 bits architecture.
// See if we can write in 8 byte chunks.
@@ -259,6 +293,7 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
* reinterpret_cast<const long*> (orig);
register unsigned long b =
* reinterpret_cast<const long*> (orig + 8);
#if defined(ACE_HAS_INTEL_ASSEMBLY)
asm ("bswapq %1" : "=r" (a) : "0" (a));
asm ("bswapq %1" : "=r" (b) : "0" (b));
@@ -273,11 +308,14 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8;
register unsigned long a51 = (a & 0xff000000ff000000L) >> 24;
register unsigned long b51 = (b & 0xff000000ff000000L) >> 24;
a = (a84 | a73 | a62 | a51);
b = (b84 | b73 | b62 | b51);
#endif
* reinterpret_cast<long*> (target) = a;
* reinterpret_cast<long*> (target + 8) = b;
orig += 16;
target += 16;
}
@@ -291,6 +329,7 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
* reinterpret_cast<const long*> (orig);
register unsigned long b =
* reinterpret_cast<const long*> (orig + 8);
#if defined(ACE_HAS_INTEL_ASSEMBLY)
asm ("bswapq %1" : "=r" (a) : "0" (a));
asm ("bswapq %1" : "=r" (b) : "0" (b));
@@ -305,13 +344,16 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8;
register unsigned long a51 = (a & 0xff000000ff000000L) >> 24;
register unsigned long b51 = (b & 0xff000000ff000000L) >> 24;
a = (a84 | a73 | a62 | a51);
b = (b84 | b73 | b62 | b51);
#endif
ACE_UINT32 c1 = static_cast<ACE_UINT32> (a >> 32);
ACE_UINT32 c2 = static_cast<ACE_UINT32> (a & 0xffffffff);
ACE_UINT32 c3 = static_cast<ACE_UINT32> (b >> 32);
ACE_UINT32 c4 = static_cast<ACE_UINT32> (b & 0xffffffff);
#if defined (ACE_LITTLE_ENDIAN)
* reinterpret_cast<ACE_UINT32*> (target + 0) = c2;
* reinterpret_cast<ACE_UINT32*> (target + 4) = c1;
@@ -327,7 +369,9 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
target += 16;
}
}
#else /* ACE_SIZEOF_LONG != 8 */
while (orig < end)
{
#if defined (ACE_HAS_PENTIUM) && defined (__GNUG__)
@@ -339,10 +383,12 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
*reinterpret_cast<const unsigned int*> (orig + 8);
register unsigned int d =
*reinterpret_cast<const unsigned int*> (orig + 12);
asm ("bswap %1" : "=r" (a) : "0" (a));
asm ("bswap %1" : "=r" (b) : "0" (b));
asm ("bswap %1" : "=r" (c) : "0" (c));
asm ("bswap %1" : "=r" (d) : "0" (d));
*reinterpret_cast<unsigned int*> (target) = a;
*reinterpret_cast<unsigned int*> (target + 4) = b;
*reinterpret_cast<unsigned int*> (target + 8) = c;
@@ -373,21 +419,26 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
* reinterpret_cast<const ACE_UINT32*> (orig + 8);
register ACE_UINT32 d =
* reinterpret_cast<const ACE_UINT32*> (orig + 12);
// Expect the optimizer reordering this A LOT.
// We leave it this way for clarity.
a = (a << 24) | ((a & 0xff00) << 8) | ((a & 0xff0000) >> 8) | (a >> 24);
b = (b << 24) | ((b & 0xff00) << 8) | ((b & 0xff0000) >> 8) | (b >> 24);
c = (c << 24) | ((c & 0xff00) << 8) | ((c & 0xff0000) >> 8) | (c >> 24);
d = (d << 24) | ((d & 0xff00) << 8) | ((d & 0xff0000) >> 8) | (d >> 24);
* reinterpret_cast<ACE_UINT32*> (target) = a;
* reinterpret_cast<ACE_UINT32*> (target + 4) = b;
* reinterpret_cast<ACE_UINT32*> (target + 8) = c;
* reinterpret_cast<ACE_UINT32*> (target + 12) = d;
#endif
orig += 16;
target += 16;
}
#endif /* ACE_SIZEOF_LONG == 8 */
// (n & 3) == (n % 4).
switch (n & 3) {
case 3:
@@ -402,6 +453,7 @@ ACE_CDR::swap_4_array (char const * orig, char* target, size_t n)
ACE_CDR::swap_4 (orig, target);
}
}
//
// We don't benefit from unrolling in swap_8_array and swap_16_array
// (swap_8 and swap_16 are big enough).
@@ -410,6 +462,7 @@ void
ACE_CDR::swap_8_array (char const * orig, char* target, size_t n)
{
// ACE_ASSERT(n > 0); The caller checks that n > 0
char const * const end = orig + 8*n;
while (orig < end)
{
@@ -418,10 +471,12 @@ ACE_CDR::swap_8_array (char const * orig, char* target, size_t n)
target += 8;
}
}
void
ACE_CDR::swap_16_array (char const * orig, char* target, size_t n)
{
// ACE_ASSERT(n > 0); The caller checks that n > 0
char const * const end = orig + 16*n;
while (orig < end)
{
@@ -430,6 +485,7 @@ ACE_CDR::swap_16_array (char const * orig, char* target, size_t n)
target += 16;
}
}
void
ACE_CDR::mb_align (ACE_Message_Block *mb)
{
@@ -442,34 +498,44 @@ ACE_CDR::mb_align (ACE_Message_Block *mb)
mb->rd_ptr (start);
mb->wr_ptr (start);
}
int
ACE_CDR::grow (ACE_Message_Block *mb, size_t minsize)
{
size_t newsize =
ACE_CDR::first_size (minsize + ACE_CDR::MAX_ALIGNMENT);
if (newsize <= mb->size ())
return 0;
ACE_Data_Block *db =
mb->data_block ()->clone_nocopy (0, newsize);
if (db == 0)
return -1;
// Do the equivalent of ACE_CDR::mb_align() here to avoid having
// to allocate an ACE_Message_Block on the stack thereby avoiding
// the manipulation of the data blocks reference count
size_t mb_len = mb->length ();
char *start = ACE_ptr_align_binary (db->base (),
ACE_CDR::MAX_ALIGNMENT);
ACE_OS::memcpy (start, mb->rd_ptr (), mb_len);
mb->data_block (db);
// Setting the data block on the mb resets the read and write
// pointers back to the beginning. We must set the rd_ptr to the
// aligned start and adjust the write pointer to the end
mb->rd_ptr (start);
mb->wr_ptr (start + mb_len);
// Remove the DONT_DELETE flags from mb
mb->clr_self_flags (ACE_Message_Block::DONT_DELETE);
return 0;
}
size_t
ACE_CDR::total_length (const ACE_Message_Block* begin,
const ACE_Message_Block* end)
@@ -482,16 +548,19 @@ ACE_CDR::total_length (const ACE_Message_Block* begin,
l += i->length ();
return l;
}
void
ACE_CDR::consolidate (ACE_Message_Block *dst,
const ACE_Message_Block *src)
{
if (src == 0)
return;
size_t newsize =
ACE_CDR::first_size (ACE_CDR::total_length (src, 0)
+ ACE_CDR::MAX_ALIGNMENT);
dst->size (newsize);
#if !defined (ACE_CDR_IGNORE_ALIGNMENT)
// We must copy the contents of <src> into the new buffer, but
// respecting the alignment.
@@ -505,6 +574,7 @@ ACE_CDR::consolidate (ACE_Message_Block *dst,
dst->rd_ptr (static_cast<size_t> (offset));
dst->wr_ptr (dst->rd_ptr ());
#endif /* ACE_CDR_IGNORE_ALIGNMENT */
for (const ACE_Message_Block* i = src;
i != 0;
i = i->cont ())
@@ -517,23 +587,28 @@ ACE_CDR::consolidate (ACE_Message_Block *dst,
dst->wr_ptr (i->length ());
}
}
#if defined (NONNATIVE_LONGLONG)
bool
ACE_CDR::LongLong::operator== (const ACE_CDR::LongLong &rhs) const
{
return this->h == rhs.h && this->l == rhs.l;
}
bool
ACE_CDR::LongLong::operator!= (const ACE_CDR::LongLong &rhs) const
{
return this->l != rhs.l || this->h != rhs.h;
}
#endif /* NONNATIVE_LONGLONG */
#if defined (NONNATIVE_LONGDOUBLE)
ACE_CDR::LongDouble&
ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs)
{
ACE_OS::memset (this->ld, 0, sizeof (this->ld));
if (sizeof (rhs) == 8)
{
#if defined (ACE_LITTLE_ENDIAN)
@@ -551,6 +626,7 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs)
ACE_INT16 exponent = ((rhs_ptr[0] & 0x7f) << 4) |
((rhs_ptr[1] >> 4) & 0xf);
const char* exp_ptr = reinterpret_cast<const char*> (&exponent);
// Infinity and NaN have an exponent of 0x7ff in 64-bit IEEE
if (exponent == 0x7ff)
{
@@ -561,9 +637,11 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs)
exponent = (exponent - max_eleven_bit) + max_fifteen_bit;
}
exponent |= sign;
// Store the sign bit and exponent
this->ld[0] = exp_ptr[byte_zero];
this->ld[1] = exp_ptr[byte_one];
// Store the mantissa. In an 8 byte double, it is split by
// 4 bits (because of the 12 bits for sign and exponent), so
// we have to shift and or the rhs to get the right bytes.
@@ -596,6 +674,7 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs)
}
return *this;
}
ACE_CDR::LongDouble&
ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble& rhs)
{
@@ -603,20 +682,24 @@ ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble& rhs)
*this = rhs;
return *this;
}
bool
ACE_CDR::LongDouble::operator== (const ACE_CDR::LongDouble &rhs) const
{
return ACE_OS::memcmp (this->ld, rhs.ld, 16) == 0;
}
bool
ACE_CDR::LongDouble::operator!= (const ACE_CDR::LongDouble &rhs) const
{
return ACE_OS::memcmp (this->ld, rhs.ld, 16) != 0;
}
ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const
{
ACE_CDR::LongDouble::NativeImpl ret = 0.0;
char* lhs_ptr = reinterpret_cast<char*> (&ret);
if (sizeof (ret) == 8)
{
#if defined (ACE_LITTLE_ENDIAN)
@@ -633,8 +716,10 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const
char* exp_ptr = reinterpret_cast<char*> (&exponent);
exp_ptr[byte_zero] = copy[0];
exp_ptr[byte_one] = copy[1];
ACE_INT16 sign = (exponent & 0x8000);
exponent &= 0x7fff;
// Infinity and NaN have an exponent of 0x7fff in 128-bit IEEE
if (exponent == 0x7fff)
{
@@ -645,9 +730,11 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const
exponent = (exponent - max_fifteen_bit) + max_eleven_bit;
}
exponent = (exponent << 4) | sign;
// Store the sign and exponent
lhs_ptr[0] = exp_ptr[byte_zero];
lhs_ptr[1] = exp_ptr[byte_one];
// Store the mantissa. In an 8 byte double, it is split by
// 4 bits (because of the 12 bits for sign and exponent), so
// we have to shift and or the rhs to get the right bytes.
@@ -667,6 +754,7 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const
++ri;
}
}
#if defined (ACE_LITTLE_ENDIAN)
ACE_CDR::swap_8 (lhs_ptr, lhs_ptr);
#endif
@@ -675,31 +763,38 @@ ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const
{
ACE_OS::memcpy(lhs_ptr, this->ld, sizeof (ret));
}
// This bit of code is unnecessary. However, this code is
// necessary to work around a bug in the gcc 4.1.1 optimizer.
ACE_CDR::LongDouble tmp;
tmp.assign (ret);
return ret;
}
#endif /* NONNATIVE_LONGDOUBLE */
#if defined(_UNICOS) && !defined(_CRAYMPP)
// placeholders to get things compiling
ACE_CDR::Float::Float (void)
{
}
ACE_CDR::Float::Float (const float & /* init */)
{
}
ACE_CDR::Float &
ACE_CDR::Float::operator= (const float & /* rhs */)
{
return *this;
}
bool
ACE_CDR::Float::operator!= (const ACE_CDR::Float & /* rhs */) const
{
return false;
}
#endif /* _UNICOS */
ACE_END_VERSIONED_NAMESPACE_DECL
+45
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file CDR_Base.h
@@ -23,16 +24,23 @@
*/
//=============================================================================
#ifndef ACE_CDR_BASE_H
#define ACE_CDR_BASE_H
#include /**/ "ace/pre.h"
#include /**/ "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Basic_Types.h"
#include "ace/Default_Constants.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Stuff used by the ACE CDR classes. Watch these values... they're also used
// in the ACE_CDR Byte_Order enum below.
#if defined ACE_LITTLE_ENDIAN
@@ -42,7 +50,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
# define ACE_CDR_BYTE_ORDER 0
// big endian encapsulation byte order has value = 0
#endif /* ! ACE_LITTLE_ENDIAN */
class ACE_Message_Block;
/**
* @class ACE_CDR
*
@@ -56,16 +66,19 @@ public:
// By defining as many of these constants as possible as enums we
// ensure they get inlined and avoid pointless static memory
// allocations.
enum
{
// Note that some of these get reused as part of the standard
// binary format: unsigned is the same size as its signed cousin,
// float is LONG_SIZE, and double is LONGLONG_SIZE.
OCTET_SIZE = 1,
SHORT_SIZE = 2,
LONG_SIZE = 4,
LONGLONG_SIZE = 8,
LONGDOUBLE_SIZE = 16,
OCTET_ALIGN = 1,
SHORT_ALIGN = 2,
LONG_ALIGN = 4,
@@ -73,9 +86,11 @@ public:
/// @note the CORBA LongDouble alignment requirements do not
/// match its size...
LONGDOUBLE_ALIGN = 8,
/// Maximal CDR 1.1 alignment: "quad precision" FP (i.e. "CDR::Long
/// double", size as above).
MAX_ALIGNMENT = 8,
/// The default buffer size.
/**
* @todo We want to add options to control this
@@ -83,14 +98,17 @@ public:
* default value ;-)
*/
DEFAULT_BUFSIZE = ACE_DEFAULT_CDR_BUFSIZE,
/// The buffer size grows exponentially until it reaches this size;
/// afterwards it grows linearly using the next constant
EXP_GROWTH_MAX = ACE_DEFAULT_CDR_EXP_GROWTH_MAX,
/// Once exponential growth is ruled out the buffer size increases
/// in chunks of this size, note that this constants have the same
/// value right now, but it does not need to be so.
LINEAR_GROWTH_CHUNK = ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK
};
/**
* @enum Byte_Order
*
@@ -106,6 +124,7 @@ public:
/// Use whichever byte order is native to this machine.
BYTE_ORDER_NATIVE = ACE_CDR_BYTE_ORDER
};
/**
* Do byte swapping for each basic IDL type size. There exist only
* routines to put byte, halfword (2 bytes), word (4 bytes),
@@ -128,9 +147,11 @@ public:
static void swap_16_array (char const *orig,
char *target,
size_t length);
/// Align the message block to ACE_CDR::MAX_ALIGNMENT,
/// set by the CORBA spec at 8 bytes.
static void mb_align (ACE_Message_Block *mb);
/**
* Compute the size of the smallest buffer that can contain at least
* @a minsize bytes.
@@ -142,9 +163,11 @@ public:
* large value, but does not explode at the end.
*/
static size_t first_size (size_t minsize);
/// Compute not the smallest, but the second smallest buffer that
/// will fir @a minsize bytes.
static size_t next_size (size_t minsize);
/**
* Increase the capacity of mb to contain at least @a minsize bytes.
* If @a minsize is zero the size is increased by an amount at least
@@ -153,13 +176,16 @@ public:
* @retval 0 Success.
*/
static int grow (ACE_Message_Block *mb, size_t minsize);
/// Copy a message block chain into a single message block,
/// preserving the alignment of the first message block of the
/// original stream, not the following message blocks.
static void consolidate (ACE_Message_Block *dst,
const ACE_Message_Block *src);
static size_t total_length (const ACE_Message_Block *begin,
const ACE_Message_Block *end);
/**
* @name Basic OMG IDL Types
*
@@ -176,6 +202,7 @@ public:
typedef ACE_INT32 Long;
typedef ACE_UINT32 ULong;
typedef ACE_UINT64 ULongLong;
# if (defined (_MSC_VER)) || (defined (__BORLANDC__))
typedef __int64 LongLong;
# elif ACE_SIZEOF_LONG == 8 && !defined(_CRAYMPP)
@@ -203,6 +230,7 @@ public:
ACE_CDR::Long l;
ACE_CDR::Long h;
# endif /* ! ACE_BIG_ENDIAN */
/**
* @name Overloaded Relation Operators.
*
@@ -214,11 +242,13 @@ public:
//@}
};
# endif /* no native 64 bit integer type */
# if defined (NONNATIVE_LONGLONG)
# define ACE_CDR_LONGLONG_INITIALIZER {0,0}
# else
# define ACE_CDR_LONGLONG_INITIALIZER 0
# endif /* NONNATIVE_LONGLONG */
# if ACE_SIZEOF_FLOAT == 4
typedef float Float;
# else /* ACE_SIZEOF_FLOAT != 4 */
@@ -239,6 +269,7 @@ public:
# endif /* ACE_SIZEOF_INT != 4 */
};
# endif /* ACE_SIZEOF_FLOAT != 4 */
# if ACE_SIZEOF_DOUBLE == 8
typedef double Double;
# else /* ACE_SIZEOF_DOUBLE != 8 */
@@ -253,10 +284,12 @@ public:
# endif /* ACE_SIZEOF_INT != 8 */
};
# endif /* ACE_SIZEOF_DOUBLE != 8 */
// 94-9-32 Appendix A defines a 128 bit floating point "long
// double" data type, with greatly extended precision and four
// more bits of exponent (compared to "double"). This is an IDL
// extension, not yet standard.
# if ACE_SIZEOF_LONG_DOUBLE == 16
typedef long double LongDouble;
# define ACE_CDR_LONG_DOUBLE_INITIALIZER 0
@@ -281,11 +314,15 @@ public:
# else
typedef long double NativeImpl;
# endif /* ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE==1 */
char ld[16];
LongDouble& assign (const NativeImpl& rhs);
LongDouble& assign (const LongDouble& rhs);
bool operator== (const LongDouble &rhs) const;
bool operator!= (const LongDouble &rhs) const;
LongDouble& operator*= (const NativeImpl rhs) {
return this->assign (static_cast<NativeImpl> (*this) * rhs);
}
@@ -314,22 +351,30 @@ public:
this->assign (static_cast<NativeImpl> (*this) - 1);
return ldv;
}
operator NativeImpl () const;
};
# endif /* ACE_SIZEOF_LONG_DOUBLE != 16 */
//@}
#if !defined (ACE_CDR_GIOP_MAJOR_VERSION)
# define ACE_CDR_GIOP_MAJOR_VERSION 1
#endif /*ACE_CDR_GIOP_MAJOR_VERSION */
#if !defined (ACE_CDR_GIOP_MINOR_VERSION)
# define ACE_CDR_GIOP_MINOR_VERSION 2
#endif /* ACE_CDR_GIOP_MINOR_VERSION */
};
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
# include "ace/CDR_Base.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_CDR_BASE_H */
+16
View File
@@ -1,15 +1,19 @@
// -*- C++ -*-
//
// $Id: CDR_Base.inl 80826 2008-03-04 14:51:23Z wotte $
#if defined (ACE_HAS_INTRINSIC_BYTESWAP)
// Take advantage of MSVC++ byte swapping compiler intrinsics (found
// in <stdlib.h>).
# pragma intrinsic (_byteswap_ushort, _byteswap_ulong, _byteswap_uint64)
#endif /* ACE_HAS_INTRINSIC_BYTESWAP */
#if defined (ACE_HAS_BSWAP_16) || defined (ACE_HAS_BSWAP_32) || defined (ACE_HAS_BSWAP_64)
# include "ace/os_include/os_byteswap.h"
#endif
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
//
// The ACE_CDR::swap_X and ACE_CDR::swap_X_array routines are broken
// in 5 cases for optimization:
@@ -57,6 +61,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// asigned to a certain variable so you don't have to clobber any
// register directly.
//
ACE_INLINE void
ACE_CDR::swap_2 (const char *orig, char* target)
{
@@ -90,6 +95,7 @@ ACE_CDR::swap_2 (const char *orig, char* target)
*udst = (usrc << 8) | (usrc >> 8);
#endif /* ACE_HAS_PENTIUM */
}
ACE_INLINE void
ACE_CDR::swap_4 (const char* orig, char* target)
{
@@ -124,6 +130,7 @@ ACE_CDR::swap_4 (const char* orig, char* target)
* reinterpret_cast<ACE_UINT32*> (target) = x;
#endif /* ACE_HAS_INTRINSIC_BYTESWAP */
}
ACE_INLINE void
ACE_CDR::swap_8 (const char* orig, char* target)
{
@@ -185,17 +192,20 @@ ACE_CDR::swap_8 (const char* orig, char* target)
* reinterpret_cast<ACE_UINT32*> (target + 4) = x;
#endif /* ACE_HAS_INTRINSIC_BYTESWAP */
}
ACE_INLINE void
ACE_CDR::swap_16 (const char* orig, char* target)
{
swap_8 (orig + 8, target);
swap_8 (orig, target + 8);
}
ACE_INLINE size_t
ACE_CDR::first_size (size_t minsize)
{
if (minsize == 0)
return ACE_CDR::DEFAULT_BUFSIZE;
size_t newsize = ACE_CDR::DEFAULT_BUFSIZE;
while (newsize < minsize)
{
@@ -203,6 +213,7 @@ ACE_CDR::first_size (size_t minsize)
{
// We grow exponentially at the beginning, this is fast and
// reduces the number of allocations.
// Quickly multiply by two using a bit shift. This is
// guaranteed to work since the variable is an unsigned
// integer.
@@ -218,10 +229,12 @@ ACE_CDR::first_size (size_t minsize)
}
return newsize;
}
ACE_INLINE size_t
ACE_CDR::next_size (size_t minsize)
{
size_t newsize = ACE_CDR::first_size (minsize);
if (newsize == minsize)
{
// If necessary increment the size
@@ -233,7 +246,10 @@ ACE_CDR::next_size (size_t minsize)
else
newsize += ACE_CDR::LINEAR_GROWTH_CHUNK;
}
return newsize;
}
ACE_END_VERSIONED_NAMESPACE_DECL
// ****************************************************************
+30
View File
@@ -2,13 +2,17 @@
#include "ace/SString.h"
#include "ace/OS_Memory.h"
#include "ace/Truncate.h"
#if !defined (__ACE_INLINE__)
# include "ace/CDR_Size.inl"
#endif /* ! __ACE_INLINE__ */
ACE_RCSID (ace,
CDR_Size,
"$Id: CDR_Size.cpp 82559 2008-08-07 20:23:07Z parsons $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_CDR::Boolean
ACE_SizeCDR::write_wchar (ACE_CDR::WChar x)
{
@@ -19,11 +23,13 @@ ACE_SizeCDR::write_wchar (ACE_CDR::WChar x)
errno = EACCES;
return (this->good_bit_ = false);
}
if (static_cast<ACE_CDR::Short> (major_version_) == 1
&& static_cast<ACE_CDR::Short> (minor_version_) == 2)
{
ACE_CDR::Octet len =
static_cast<ACE_CDR::Octet> (ACE_OutputCDR::wchar_maxbytes ());
if (this->write_1 (&len))
{
if (ACE_OutputCDR::wchar_maxbytes () == sizeof(ACE_CDR::WChar))
@@ -59,6 +65,7 @@ ACE_SizeCDR::write_wchar (ACE_CDR::WChar x)
errno = EINVAL;
return (this->good_bit_ = false);
}
if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar))
{
const void *temp = &x;
@@ -69,9 +76,11 @@ ACE_SizeCDR::write_wchar (ACE_CDR::WChar x)
ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
return this->write_2 (reinterpret_cast<const ACE_CDR::UShort *> (&sx));
}
ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&ox));
}
ACE_CDR::Boolean
ACE_SizeCDR::write_string (ACE_CDR::ULong len,
const ACE_CDR::Char *x)
@@ -92,8 +101,10 @@ ACE_SizeCDR::write_string (ACE_CDR::ULong len,
if (this->write_ulong (1))
return this->write_char (0);
}
return (this->good_bit_ = false);
}
ACE_CDR::Boolean
ACE_SizeCDR::write_string (const ACE_CString &x)
{
@@ -102,6 +113,7 @@ ACE_SizeCDR::write_string (const ACE_CString &x)
return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()),
x.c_str());
}
ACE_CDR::Boolean
ACE_SizeCDR::write_wstring (ACE_CDR::ULong len,
const ACE_CDR::WChar *x)
@@ -113,6 +125,7 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len,
errno = EACCES;
return (this->good_bit_ = false);
}
if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
&& static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
{
@@ -125,6 +138,7 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len,
this->write_ulong (
ACE_Utils::truncate_cast<ACE_CDR::ULong> (
ACE_OutputCDR::wchar_maxbytes () * len));
if (good_ulong)
{
return this->write_wchar_array (x, len);
@@ -136,6 +150,7 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len,
return this->write_ulong (0);
}
}
else
if (x != 0)
{
@@ -146,30 +161,35 @@ ACE_SizeCDR::write_wstring (ACE_CDR::ULong len,
return this->write_wchar (0);
return (this->good_bit_ = false);
}
ACE_CDR::Boolean
ACE_SizeCDR::write_1 (const ACE_CDR::Octet *)
{
this->adjust (1);
return true;
}
ACE_CDR::Boolean
ACE_SizeCDR::write_2 (const ACE_CDR::UShort *)
{
this->adjust (ACE_CDR::SHORT_SIZE);
return true;
}
ACE_CDR::Boolean
ACE_SizeCDR::write_4 (const ACE_CDR::ULong *)
{
this->adjust (ACE_CDR::LONG_SIZE);
return true;
}
ACE_CDR::Boolean
ACE_SizeCDR::write_8 (const ACE_CDR::ULongLong *)
{
this->adjust (ACE_CDR::LONGLONG_SIZE);
return true;
}
ACE_CDR::Boolean
ACE_SizeCDR::write_16 (const ACE_CDR::LongDouble *)
{
@@ -177,19 +197,23 @@ ACE_SizeCDR::write_16 (const ACE_CDR::LongDouble *)
ACE_CDR::LONGDOUBLE_ALIGN);
return true;
}
ACE_CDR::Boolean
ACE_SizeCDR::write_wchar_array_i (const ACE_CDR::WChar *,
ACE_CDR::ULong length)
{
if (length == 0)
return true;
size_t const align = (ACE_OutputCDR::wchar_maxbytes () == 2) ?
ACE_CDR::SHORT_ALIGN :
ACE_CDR::OCTET_ALIGN;
this->adjust (ACE_OutputCDR::wchar_maxbytes () * length, align);
return true;
}
ACE_CDR::Boolean
ACE_SizeCDR::write_array (const void *,
size_t size,
@@ -198,9 +222,11 @@ ACE_SizeCDR::write_array (const void *,
{
if (length == 0)
return true;
this->adjust (size * length, align);
return true;
}
ACE_CDR::Boolean
ACE_SizeCDR::write_boolean_array (const ACE_CDR::Boolean*,
ACE_CDR::ULong length)
@@ -208,11 +234,13 @@ ACE_SizeCDR::write_boolean_array (const ACE_CDR::Boolean*,
this->adjust (length, 1);
return true;
}
void
ACE_SizeCDR::adjust (size_t size)
{
adjust (size, size);
}
void
ACE_SizeCDR::adjust (size_t size,
size_t align)
@@ -223,11 +251,13 @@ ACE_SizeCDR::adjust (size_t size,
#endif /* ACE_LACKS_CDR_ALIGNMENT */
size_ += size;
}
ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, const ACE_CString &x)
{
ss.write_string (x);
return ss.good_bit ();
}
ACE_END_VERSIONED_NAMESPACE_DECL
+36
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file CDR_Size.h
@@ -20,16 +21,23 @@
*
*/
//=============================================================================
#ifndef ACE_CDR_SIZE_H
#define ACE_CDR_SIZE_H
#include /**/ "ace/pre.h"
#include "ace/CDR_Base.h"
#include "ace/CDR_Stream.h" // for ACE_OutputCDR::from_*
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/SStringfwd.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_SizeCDR
*
@@ -42,15 +50,19 @@ public:
/// Default constructor.
ACE_SizeCDR (ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// Returns @c false if an error has ocurred.
bool good_bit (void) const;
/// Reset current size.
void reset (void);
/// Return current size.
size_t total_length (void) const;
// Return 0 on failure and 1 on success.
//@{ @name Size-calculating pseudo-write operations
ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x);
@@ -66,6 +78,7 @@ public:
ACE_CDR::Boolean write_float (ACE_CDR::Float x);
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x);
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x);
/// For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (const ACE_CDR::Char *x);
ACE_CDR::Boolean write_string (ACE_CDR::ULong len,
@@ -75,6 +88,7 @@ public:
ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length,
const ACE_CDR::WChar *x);
//@}
/// @note the portion written starts at <x> and ends
/// at <x + length>.
/// The length is *NOT* stored into the CDR stream.
@@ -105,22 +119,27 @@ public:
ACE_CDR::ULong length);
ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x,
ACE_CDR::ULong length);
///
/// Adjust to @a size and count <size> octets.
void adjust (size_t size);
/// As above, but now the size and alignment requirements may be
/// different.
void adjust (size_t size,
size_t align);
private:
/// disallow copying...
ACE_SizeCDR (const ACE_SizeCDR& rhs);
ACE_SizeCDR& operator= (const ACE_SizeCDR& rhs);
ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x);
ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x);
ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x);
ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x);
ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x);
/**
* write an array of @a length elements, each of @a size bytes and the
* start aligned at a multiple of <align>. The elements are assumed
@@ -138,31 +157,42 @@ private:
size_t align,
ACE_CDR::ULong length);
ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x,
ACE_CDR::ULong length);
private:
/// Set to false when an error ocurrs.
bool good_bit_;
/// Current size.
size_t size_;
protected:
/// GIOP version information
ACE_CDR::Octet major_version_;
ACE_CDR::Octet minor_version_;
};
// @@ This operator should not be inlined since they force SString.h
// to be included in this header.
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
const ACE_CString &x);
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
# include "ace/CDR_Size.inl"
#else /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Not used by CORBA or TAO
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
ACE_CDR::Char x);
// CDR size-calculating output operators for primitive types
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
ACE_CDR::Short x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
@@ -181,7 +211,9 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
ACE_CDR::Float x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
ACE_CDR::Double x);
// CDR size-calculating output operator from helper classes
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
ACE_OutputCDR::from_boolean x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
@@ -198,9 +230,13 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
const ACE_CDR::Char* x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
const ACE_CDR::WChar* x);
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* ACE_CDR_SIZE_H */
+57
View File
@@ -1,8 +1,11 @@
// -*- C++ -*-
//
// $Id: CDR_Size.inl 80826 2008-03-04 14:51:23Z wotte $
#include "ace/OS_NS_string.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_SizeCDR::ACE_SizeCDR (ACE_CDR::Octet major_version,
ACE_CDR::Octet minor_version)
@@ -12,33 +15,40 @@ ACE_SizeCDR::ACE_SizeCDR (ACE_CDR::Octet major_version,
minor_version_ (minor_version)
{
}
ACE_INLINE bool
ACE_SizeCDR::good_bit (void) const
{
return this->good_bit_;
}
ACE_INLINE void
ACE_SizeCDR::reset (void)
{
this->size_ = 0;
}
ACE_INLINE size_t
ACE_SizeCDR::total_length (void) const
{
return this->size_;
}
// Encode the CDR stream.
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_octet (ACE_CDR::Octet x)
{
return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_boolean (ACE_CDR::Boolean x)
{
return (ACE_CDR::Boolean) this->write_octet (x ? (ACE_CDR::Octet) 1 : (ACE_CDR::Octet) 0);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_char (ACE_CDR::Char x)
{
@@ -46,55 +56,65 @@ ACE_SizeCDR::write_char (ACE_CDR::Char x)
//
return this->write_1 (reinterpret_cast<const ACE_CDR::Octet*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_short (ACE_CDR::Short x)
{
return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_ushort (ACE_CDR::UShort x)
{
return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_long (ACE_CDR::Long x)
{
return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_ulong (ACE_CDR::ULong x)
{
return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_longlong (const ACE_CDR::LongLong &x)
{
return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_ulonglong (const ACE_CDR::ULongLong &x)
{
const void *temp = &x;
return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong *> (temp));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_float (ACE_CDR::Float x)
{
const void *temp = &x;
return this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_double (const ACE_CDR::Double &x)
{
const void *temp = &x;
return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (temp));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_longdouble (const ACE_CDR::LongDouble &x)
{
const void *temp = &x;
return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (temp));
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_string (const ACE_CDR::Char *x)
{
@@ -106,6 +126,7 @@ ACE_SizeCDR::write_string (const ACE_CDR::Char *x)
}
return this->write_string (0, 0);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x)
{
@@ -117,6 +138,7 @@ ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x)
}
return this->write_wstring (0, 0);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x,
ACE_CDR::ULong length)
@@ -128,6 +150,7 @@ ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x,
ACE_CDR::OCTET_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x,
ACE_CDR::ULong length)
@@ -148,6 +171,7 @@ ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x,
length);
return this->write_wchar_array_i (x,length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_octet_array (const ACE_CDR::Octet* x,
ACE_CDR::ULong length)
@@ -157,6 +181,7 @@ ACE_SizeCDR::write_octet_array (const ACE_CDR::Octet* x,
ACE_CDR::OCTET_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x,
ACE_CDR::ULong length)
@@ -166,6 +191,7 @@ ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x,
ACE_CDR::SHORT_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x,
ACE_CDR::ULong length)
@@ -175,6 +201,7 @@ ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x,
ACE_CDR::SHORT_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x,
ACE_CDR::ULong length)
@@ -184,6 +211,7 @@ ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x,
ACE_CDR::LONG_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x,
ACE_CDR::ULong length)
@@ -193,6 +221,7 @@ ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x,
ACE_CDR::LONG_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x,
ACE_CDR::ULong length)
@@ -202,6 +231,7 @@ ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x,
ACE_CDR::LONGLONG_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x,
ACE_CDR::ULong length)
@@ -211,6 +241,7 @@ ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x,
ACE_CDR::LONGLONG_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x,
ACE_CDR::ULong length)
@@ -221,6 +252,7 @@ ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x,
ACE_CDR::ULong length)
@@ -230,6 +262,7 @@ ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x,
ACE_CDR::LONGLONG_ALIGN,
length);
}
ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x,
ACE_CDR::ULong length)
@@ -240,80 +273,94 @@ ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x,
length);
}
// ****************************************************************
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::Char x)
{
ss.write_char (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::Short x)
{
ss.write_short (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::UShort x)
{
ss.write_ushort (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::Long x)
{
ss.write_long (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::ULong x)
{
ss.write_ulong (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::LongLong x)
{
ss.write_longlong (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::ULongLong x)
{
ss.write_ulonglong (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::LongDouble x)
{
ss.write_longdouble (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::Float x)
{
ss.write_float (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x)
{
ss.write_double (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char *x)
{
ss.write_string (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar *x)
{
ss.write_wstring (x);
return (ACE_CDR::Boolean) ss.good_bit ();
}
// The following use the helper classes
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x)
@@ -321,47 +368,57 @@ operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x)
ss.write_boolean (x.val_);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_char x)
{
ss.write_char (x.val_);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wchar x)
{
ss.write_wchar (x.val_);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_octet x)
{
ss.write_octet (x.val_);
return (ACE_CDR::Boolean) ss.good_bit ();
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_string x)
{
ACE_CDR::ULong len = 0;
if (x.val_ != 0)
{
len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x.val_));
}
ss.write_string (len, x.val_);
return
(ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_));
}
ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wstring x)
{
ACE_CDR::ULong len = 0;
if (x.val_ != 0)
{
len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x.val_));
}
ss.write_wstring (len, x.val_);
return
(ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_));
}
ACE_END_VERSIONED_NAMESPACE_DECL
File diff suppressed because it is too large Load Diff
+191
View File
@@ -1,4 +1,5 @@
// -*- C++ -*-
//=============================================================================
/**
* @file CDR_Stream.h
@@ -35,26 +36,37 @@
* @author Codeset translation by Jim Rogers <jrogers@viasoft.com>
*/
//=============================================================================
#ifndef ACE_CDR_STREAM_H
#define ACE_CDR_STREAM_H
#include /**/ "ace/pre.h"
#include "ace/CDR_Base.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/SStringfwd.h"
#include "ace/Message_Block.h"
#if defined (GEN_OSTREAM_OPS)
#include "ace/streams.h"
#endif /* GEN_OSTREAM_OPS */
#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
#include "Monitor_Size.h"
#endif /* ACE_HAS_MONITOR_POINTS==1 */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Char_Codeset_Translator;
class ACE_WChar_Codeset_Translator;
class ACE_InputCDR;
/**
* @class ACE_OutputCDR
*
@@ -80,6 +92,7 @@ public:
friend class ACE_Char_Codeset_Translator;
friend class ACE_WChar_Codeset_Translator;
friend class ACE_InputCDR;
/**
* Default constructor; allows one to set byte ordering, allocators, and
* tuning information.
@@ -105,6 +118,7 @@ public:
size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// Build a CDR stream with an initial buffer, it will *not* remove
/// <data>, since it did not allocated it. It's important to be careful
/// with the alignment of <data>.
@@ -125,6 +139,7 @@ public:
size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// Build a CDR stream with an initial data block, it will *not* remove
/// <data_block>, since it did not allocated it. It's important to be
// careful with the alignment of <data_block>.
@@ -142,6 +157,7 @@ public:
size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// Build a CDR stream with an initial Message_Block chain, it will
/// *not* remove @a data, since it did not allocate it.
ACE_OutputCDR (ACE_Message_Block *data,
@@ -149,33 +165,40 @@ public:
size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// destructor
~ACE_OutputCDR (void);
/**
* Disambiguate overload when inserting booleans, octets, chars, and
* bounded strings.
*/
//@{ @name Helper classes
struct ACE_Export from_boolean
{
explicit from_boolean (ACE_CDR::Boolean b);
ACE_CDR::Boolean val_;
};
struct ACE_Export from_octet
{
explicit from_octet (ACE_CDR::Octet o);
ACE_CDR::Octet val_;
};
struct ACE_Export from_char
{
explicit from_char (ACE_CDR::Char c);
ACE_CDR::Char val_;
};
struct ACE_Export from_wchar
{
explicit from_wchar (ACE_CDR::WChar wc);
ACE_CDR::WChar val_;
};
struct ACE_Export from_string
{
from_string (ACE_CDR::Char* s,
@@ -188,6 +211,7 @@ public:
ACE_CDR::ULong bound_;
ACE_CDR::Boolean nocopy_;
};
struct ACE_Export from_wstring
{
from_wstring (ACE_CDR::WChar* ws,
@@ -201,6 +225,7 @@ public:
ACE_CDR::Boolean nocopy_;
};
//@}
/**
* @{ @name Write operations
* Return 0 on failure and 1 on success.
@@ -218,6 +243,7 @@ public:
ACE_CDR::Boolean write_float (ACE_CDR::Float x);
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x);
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x);
/// For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (const ACE_CDR::Char *x);
ACE_CDR::Boolean write_string (ACE_CDR::ULong len,
@@ -227,6 +253,7 @@ public:
ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length,
const ACE_CDR::WChar *x);
//@}
/// @note the portion written starts at <x> and ends
/// at <x + length>.
/// The length is *NOT* stored into the CDR stream.
@@ -257,10 +284,12 @@ public:
ACE_CDR::ULong length);
ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x,
ACE_CDR::ULong length);
/// Write an octet array contained inside a MB, this can be optimized
/// to minimize copies.
ACE_CDR::Boolean write_octet_array_mb (const ACE_Message_Block* mb);
//@}
/**
* @{ @name Placeholder/replace operations
* Facilitates writing a placeholder into a CDR stream to be replaced
@@ -276,6 +305,7 @@ public:
strm.replace (real_val, pos); // Replace earlier placeholder
@endcode
*/
/**
* Write a placeholder into the stream. The placeholder's pointer
* is returned so it may later be passed as the @a loc argument to
@@ -288,6 +318,7 @@ public:
*/
char* write_long_placeholder (void);
char* write_short_placeholder (void);
/**
* Writes a new value into a specific location. This is commonly
* used to update a prior "placeholder" location in the stream.
@@ -307,6 +338,7 @@ public:
ACE_CDR::Boolean replace (ACE_CDR::Long x, char* loc);
ACE_CDR::Boolean replace (ACE_CDR::Short x, char* loc);
//@}
/**
* Return 0 on failure and 1 on success.
*/
@@ -324,28 +356,36 @@ public:
ACE_CDR::Boolean append_float (ACE_InputCDR &);
ACE_CDR::Boolean append_double (ACE_InputCDR &);
ACE_CDR::Boolean append_longdouble (ACE_InputCDR &);
ACE_CDR::Boolean append_wstring (ACE_InputCDR &);
ACE_CDR::Boolean append_string (ACE_InputCDR &);
//@}
/// Returns @c false if an error has ocurred.
/**
* @note The only expected error is to run out of memory.
*/
bool good_bit (void) const;
/// Reuse the CDR stream to write on the old buffer.
void reset (void);
/// Add the length of each message block in the chain.
size_t total_length (void) const;
/**
* Return the start of the message block chain for this CDR stream.
* @note The complete CDR stream is represented by a chain of
* message blocks.
*/
const ACE_Message_Block *begin (void) const;
/// Return the last message in the chain that is is use.
const ACE_Message_Block *end (void) const;
/// Return the <current_> message block in chain.
const ACE_Message_Block *current (void) const;
/// Replace the message block chain with a single message block.
/**
* Upon successful completion, there will be a single message block
@@ -354,18 +394,21 @@ public:
* @note The only expected error is to run out of memory.
*/
int consolidate (void);
/**
* Access the underlying buffer (read only). @note This
* method only returns a pointer to the first block in the
* chain.
*/
const char *buffer (void) const;
/**
* Return the size of first message block in the block chain. @note This
* method only returns information about the first block in the
* chain.
*/
size_t length (void) const;
/**
* Utility function to allow the user more flexibility.
* Pads the stream up to the nearest <alignment>-byte boundary.
@@ -373,25 +416,32 @@ public:
* Returns 0 on success and -1 on failure.
*/
int align_write_ptr (size_t alignment);
/// Access the codeset translators. They can be null!
ACE_Char_Codeset_Translator *char_translator (void) const;
ACE_WChar_Codeset_Translator *wchar_translator (void) const;
/// Set the char codeset translator.
void char_translator (ACE_Char_Codeset_Translator *);
/// Set the wchar codeset translator.
void wchar_translator (ACE_WChar_Codeset_Translator *);
/// set the global size of serialized wchars. This may be different
/// than the size of a wchar_t.
static void wchar_maxbytes (size_t max_bytes);
/// access the serialized size of wchars.
static size_t wchar_maxbytes (void);
/**
* Return alignment of the wr_ptr(), with respect to the start of
* the CDR stream. This is not the same as the alignment of
* current->wr_ptr()!
*/
size_t current_alignment (void) const;
void current_alignment (size_t current_alignment);
/**
* Returns (in @a buf) the next position in the buffer aligned to
* @a size, it advances the Message_Block wr_ptr past the data
@@ -400,45 +450,57 @@ public:
*/
int adjust (size_t size,
char *&buf);
/// As above, but now the size and alignment requirements may be
/// different.
int adjust (size_t size,
size_t align,
char *&buf);
/// Returns true if this stream is writing in non-native byte order
/// and false otherwise. For example, it would be true if either
/// ACE_ENABLE_SWAP_ON_WRITE is defined or a specific byte order was
/// specified for this stream.
bool do_byte_swap (void) const;
/// Returns the byte order this stream is marshaling data in. Will be one
/// of the values in ACE_CDR::Byte_Order.
int byte_order (void) const;
/// For use by a gateway, which creates the output stream for the
/// reply to the client in its native byte order, but which must
/// send the reply in the byte order of the target's reply to the
/// gateway.
void reset_byte_order (int byte_order);
/// set GIOP version info
void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor);
/// Set the underlying GIOP version..
void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor);
#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
/// Register and unregister our buffer size monitor.
void register_monitor (const char* id);
void unregister_monitor (void);
#endif /* ACE_HAS_MONITOR_POINTS==1 */
private:
// Find the message block in the chain of message blocks
// that the provide location locates.
ACE_Message_Block* find (char* loc);
/// disallow copying...
ACE_OutputCDR (const ACE_OutputCDR& rhs);
ACE_OutputCDR& operator= (const ACE_OutputCDR& rhs);
ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x);
ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x);
ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x);
ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x);
ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x);
/**
* write an array of @a length elements, each of @a size bytes and the
* start aligned at a multiple of <align>. The elements are assumed
@@ -456,9 +518,11 @@ private:
size_t align,
ACE_CDR::ULong length);
ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x,
ACE_CDR::ULong length);
/**
* Grow the CDR stream. When it returns @a buf contains a pointer to
* memory in the CDR stream, with at least @a size bytes ahead of it
@@ -468,11 +532,14 @@ private:
int grow_and_adjust (size_t size,
size_t align,
char *&buf);
private:
/// The start of the chain of message blocks.
ACE_Message_Block start_;
/// The current block in the chain where we are writing.
ACE_Message_Block *current_;
#if !defined (ACE_LACKS_CDR_ALIGNMENT)
/**
* The current alignment as measured from the start of the buffer.
@@ -484,6 +551,7 @@ private:
*/
size_t current_alignment_;
#endif /* ACE_LACKS_CDR_ALIGNMENT */
/**
* Is the current block writable. When we steal a buffer from the
* user and just chain it into the message block we are not supposed
@@ -491,6 +559,7 @@ private:
* buffer.
*/
bool current_is_writable_;
/**
* If not zero swap bytes at writing so the created CDR stream byte
* order does *not* match the machine byte order. The motivation
@@ -501,20 +570,26 @@ private:
* USE AT YOUR OWN RISK
*/
bool do_byte_swap_;
/// Set to false when an error ocurrs.
bool good_bit_;
/// Break-even point for copying.
size_t const memcpy_tradeoff_;
#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
ACE::Monitor_Control::Size_Monitor *monitor_;
#endif /* ACE_HAS_MONITOR_POINTS==1 */
protected:
/// GIOP version information
ACE_CDR::Octet major_version_;
ACE_CDR::Octet minor_version_;
/// If not nil, invoke for translation of character and string data.
ACE_Char_Codeset_Translator *char_translator_;
ACE_WChar_Codeset_Translator *wchar_translator_;
/**
* Some wide char codesets may be defined with a maximum number
* of bytes that is smaller than the size of a wchar_t. This means
@@ -527,7 +602,9 @@ protected:
static size_t wchar_maxbytes_;
};
// ****************************************************************
/**
* @class ACE_InputCDR
*
@@ -550,6 +627,7 @@ public:
// arrays and such.
friend class ACE_Char_Codeset_Translator;
friend class ACE_WChar_Codeset_Translator;
/**
* Create an input stream from an arbitrary buffer. The buffer must
* be properly aligned because this contructor will *not* work if
@@ -562,12 +640,14 @@ public:
int byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// Create an empty input stream. The caller is responsible for
/// putting the right data and providing the right alignment.
ACE_InputCDR (size_t bufsiz,
int byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// Create an input stream from an ACE_Message_Block
/**
* The alignment of the @a data block is carried into the new
@@ -581,6 +661,7 @@ public:
ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION,
ACE_Lock* lock = 0);
/// Create an input stream from an ACE_Data_Block. The <flag>
/// indicates whether the <data> can be deleted by the CDR stream
/// or not
@@ -589,6 +670,7 @@ public:
int byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/// Create an input stream from an ACE_Data_Block. It also sets the
/// read and write pointers at the desired positions. This would be
/// helpful if the applications desires to create a new CDR stream
@@ -600,62 +682,76 @@ public:
int byte_order = ACE_CDR::BYTE_ORDER_NATIVE,
ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION);
/**
* These make a copy of the current stream state, but do not copy
* the internal buffer, so the same stream can be read multiple
* times efficiently.
*/
ACE_InputCDR (const ACE_InputCDR& rhs);
ACE_InputCDR& operator= (const ACE_InputCDR& rhs);
/// When interpreting indirected TypeCodes it is useful to make a
/// "copy" of the stream starting in the new position.
ACE_InputCDR (const ACE_InputCDR& rhs,
size_t size,
ACE_CDR::Long offset);
/// This creates an encapsulated stream, the first byte must be (per
/// the spec) the byte order of the encapsulation.
ACE_InputCDR (const ACE_InputCDR& rhs,
size_t size);
/// Create an input CDR from an output CDR.
ACE_InputCDR (const ACE_OutputCDR& rhs,
ACE_Allocator* buffer_allocator = 0,
ACE_Allocator* data_block_allocator = 0,
ACE_Allocator* message_block_allocator = 0);
/// Helper class to transfer the contents from one input CDR to
/// another without requiring any extra memory allocations, data
/// copies or too many temporaries.
struct ACE_Export Transfer_Contents
{
Transfer_Contents (ACE_InputCDR &rhs);
ACE_InputCDR &rhs_;
};
/// Transfer the contents from <rhs> to a new CDR
ACE_InputCDR (Transfer_Contents rhs);
/// Destructor
~ACE_InputCDR (void);
/// Disambiguate overloading when extracting octets, chars,
/// booleans, and bounded strings
//@{ @name Helper classes
struct ACE_Export to_boolean
{
explicit to_boolean (ACE_CDR::Boolean &b);
ACE_CDR::Boolean &ref_;
};
struct ACE_Export to_char
{
explicit to_char (ACE_CDR::Char &c);
ACE_CDR::Char &ref_;
};
struct ACE_Export to_wchar
{
explicit to_wchar (ACE_CDR::WChar &wc);
ACE_CDR::WChar &ref_;
};
struct ACE_Export to_octet
{
explicit to_octet (ACE_CDR::Octet &o);
ACE_CDR::Octet &ref_;
};
struct ACE_Export to_string
{
/**
@@ -670,6 +766,7 @@ public:
const ACE_CDR::Char *&val_;
ACE_CDR::ULong bound_;
};
struct ACE_Export to_wstring
{
/// The constructor taking a non-const wstring is
@@ -683,6 +780,7 @@ public:
ACE_CDR::ULong bound_;
};
//@}
/**
* Return @c false on failure and @c true on success.
*/
@@ -700,10 +798,12 @@ public:
ACE_CDR::Boolean read_float (ACE_CDR::Float &x);
ACE_CDR::Boolean read_double (ACE_CDR::Double &x);
ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x);
ACE_CDR::Boolean read_string (ACE_CDR::Char *&x);
ACE_CDR::Boolean read_string (ACE_CString &x);
ACE_CDR::Boolean read_wstring (ACE_CDR::WChar*& x);
//@}
/**
* The buffer @a x must be large enough to contain @a length
* elements.
@@ -737,6 +837,7 @@ public:
ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble* x,
ACE_CDR::ULong length);
//@}
/**
* Return @c false on failure and @c true on success.
*/
@@ -755,6 +856,7 @@ public:
ACE_CDR::Boolean skip_double (void);
ACE_CDR::Boolean skip_longdouble (void);
//@}
/**
* The next field must be a string, this method skips it. It is
* useful in parsing a TypeCode.
@@ -762,13 +864,16 @@ public:
*/
ACE_CDR::Boolean skip_wstring (void);
ACE_CDR::Boolean skip_string (void);
/// Skip @a n bytes in the CDR stream.
/**
* @return @c false on failure and @c true on success.
*/
ACE_CDR::Boolean skip_bytes (size_t n);
/// returns @c false if a problem has been detected.
bool good_bit (void) const;
/**
* @return The start of the message block chain for this CDR
* stream.
@@ -777,35 +882,43 @@ public:
* we are planning to change that.
*/
const ACE_Message_Block* start (void) const;
// = The following functions are useful to read the contents of the
// CDR stream from a socket or file.
/**
* Grow the internal buffer, reset @c rd_ptr to the first byte in
* the new buffer that is properly aligned, and set @c wr_ptr to @c
* rd_ptr @c + @c newsize
*/
int grow (size_t newsize);
/**
* After reading and partially parsing the contents the user can
* detect a change in the byte order, this method will let him/her
* change it.
*/
void reset_byte_order (int byte_order);
/// Re-initialize the CDR stream, copying the contents of the chain
/// of message_blocks starting from @a data.
void reset (const ACE_Message_Block *data,
int byte_order);
/// Steal the contents from the current CDR.
ACE_Message_Block *steal_contents (void);
/// Steal the contents of @a cdr and make a shallow copy into this
/// stream.
void steal_from (ACE_InputCDR &cdr);
/// Exchange data blocks with the caller of this method. The read
/// and write pointers are also exchanged.
/**
* @note We now do only with the start_ message block.
*/
void exchange_data_blocks (ACE_InputCDR &cdr);
/// Copy the data portion from the @c cdr to this cdr and return the
/// data content (ie. the ACE_Data_Block) from this CDR to the
/// caller.
@@ -814,15 +927,20 @@ public:
* returned ACE_Data_Block.
*/
ACE_Data_Block* clone_from (ACE_InputCDR &cdr);
/// Re-initialize the CDR stream, forgetting about the old contents
/// of the stream and allocating a new buffer (from the allocators).
void reset_contents (void);
/// Returns the current position for the @c rd_ptr.
char* rd_ptr (void);
/// Returns the current position for the @c wr_ptr.
char* wr_ptr (void);
/// Return how many bytes are left in the stream.
size_t length (void) const;
/**
* Utility function to allow the user more flexibility.
* Skips up to the nearest @a alignment-byte boundary.
@@ -831,18 +949,23 @@ public:
* @return 0 on success and -1 on failure.
*/
int align_read_ptr (size_t alignment);
/// If @c true then this stream is writing in non-native byte order.
/// This is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined.
bool do_byte_swap (void) const;
/// If @c do_byte_swap() returns @c false, this returns
/// ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER.
int byte_order (void) const;
/// Access the codeset translators. They can be nil!
ACE_Char_Codeset_Translator *char_translator (void) const;
ACE_WChar_Codeset_Translator *wchar_translator (void) const;
/// Set the codeset translators.
void char_translator (ACE_Char_Codeset_Translator *);
void wchar_translator (ACE_WChar_Codeset_Translator *);
/**
* Returns (in @a buf) the next position in the buffer aligned to
* @a size. It advances the Message_Block @c rd_ptr past the data
@@ -851,50 +974,65 @@ public:
*/
int adjust (size_t size,
char *&buf);
/// As above, but now the size and alignment requirements may be
/// different.
int adjust (size_t size,
size_t align,
char *&buf);
/// Set the underlying GIOP version..
void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor);
/// Set the underlying GIOP version..
void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor);
#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
/// Register and unregister our buffer size monitor.
void register_monitor (const char* id);
void unregister_monitor (void);
#endif /* ACE_HAS_MONITOR_POINTS==1 */
protected:
/// The start of the chain of message blocks, even though in the
/// current version the chain always has length 1.
ACE_Message_Block start_;
/// The CDR stream byte order does not match the one on the machine,
/// swapping is needed while reading.
bool do_byte_swap_;
/// set to @c false when an error occurs.
bool good_bit_;
/// The GIOP versions for this stream
ACE_CDR::Octet major_version_;
ACE_CDR::Octet minor_version_;
/// If not nil, invoke for translation of character and string data.
ACE_Char_Codeset_Translator *char_translator_;
ACE_WChar_Codeset_Translator *wchar_translator_;
#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
ACE::Monitor_Control::Size_Monitor *monitor_;
#endif /* ACE_HAS_MONITOR_POINTS==1 */
private:
ACE_CDR::Boolean read_1 (ACE_CDR::Octet *x);
ACE_CDR::Boolean read_2 (ACE_CDR::UShort *x);
ACE_CDR::Boolean read_4 (ACE_CDR::ULong *x);
ACE_CDR::Boolean read_8 (ACE_CDR::ULongLong *x);
ACE_CDR::Boolean read_16 (ACE_CDR::LongDouble *x);
// Several types can be read using the same routines, since TAO
// tries to use native types with known size for each CORBA type.
// We could use void* or char* to make the interface more
// consistent, but using native types let us exploit the strict
// alignment requirements of CDR streams and implement the
// operations using asignment.
/**
* Read an array of @a length elements, each of @a size bytes and the
* start aligned at a multiple of <align>. The elements are assumed
@@ -911,6 +1049,7 @@ private:
size_t size,
size_t align,
ACE_CDR::ULong length);
/**
* On those occasions when the native codeset for wchar is smaller than
* the size of a wchar_t, such as using UTF-16 with a 4-byte wchar_t, a
@@ -919,12 +1058,16 @@ private:
*/
ACE_CDR::Boolean read_wchar_array_i (ACE_CDR::WChar * x,
ACE_CDR::ULong length);
/// Move the rd_ptr ahead by @a offset bytes.
void rd_ptr (size_t offset);
/// Points to the continuation field of the current message block.
char* end (void);
};
// ****************************************************************
/**
* @class ACE_Char_Codeset_Translator
*
@@ -943,33 +1086,40 @@ class ACE_Export ACE_Char_Codeset_Translator
{
public:
virtual ~ACE_Char_Codeset_Translator ();
/// Read a single character from the stream, converting from the
/// stream codeset to the native codeset
virtual ACE_CDR::Boolean read_char (ACE_InputCDR&,
ACE_CDR::Char&) = 0;
/// Read a string from the stream, including the length, converting
/// the characters from the stream codeset to the native codeset
virtual ACE_CDR::Boolean read_string (ACE_InputCDR&,
ACE_CDR::Char *&) = 0;
/// Read an array of characters from the stream, converting the
/// characters from the stream codeset to the native codeset.
virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR&,
ACE_CDR::Char*,
ACE_CDR::ULong) = 0;
/// Write a single character to the stream, converting from the
/// native codeset to the stream codeset
virtual ACE_CDR::Boolean write_char (ACE_OutputCDR&,
ACE_CDR::Char) = 0;
/// Write a string to the stream, including the length, converting
/// from the native codeset to the stream codeset
virtual ACE_CDR::Boolean write_string (ACE_OutputCDR&,
ACE_CDR::ULong,
const ACE_CDR::Char*) = 0;
/// Write an array of characters to the stream, converting from the
/// native codeset to the stream codeset
virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR&,
const ACE_CDR::Char*,
ACE_CDR::ULong) = 0;
virtual ACE_CDR::ULong ncs () = 0;
virtual ACE_CDR::ULong tcs () = 0;
protected:
@@ -979,6 +1129,7 @@ protected:
ACE_CDR::Octet *x);
ACE_CDR::Boolean write_1 (ACE_OutputCDR& output,
const ACE_CDR::Octet *x);
/// Efficiently read @a length elements of size @a size each from
/// <input> into <x>; the data must be aligned to <align>.
ACE_CDR::Boolean read_array (ACE_InputCDR& input,
@@ -986,6 +1137,7 @@ protected:
size_t size,
size_t align,
ACE_CDR::ULong length);
/**
* Efficiently write @a length elements of size @a size from <x> into
* <output>. Before inserting the elements enough padding is added
@@ -997,6 +1149,7 @@ protected:
size_t size,
size_t align,
ACE_CDR::ULong length);
/**
* Exposes the stream implementation of <adjust>, this is useful in
* many cases to minimize memory allocations during marshaling.
@@ -1008,15 +1161,19 @@ protected:
size_t size,
size_t align,
char *&buf);
/// Used by derived classes to set errors in the CDR stream.
void good_bit (ACE_OutputCDR& out, bool bit);
/// Obtain the CDR Stream's major & minor version values.
ACE_CDR::Octet major_version (ACE_InputCDR& input);
ACE_CDR::Octet minor_version (ACE_InputCDR& input);
ACE_CDR::Octet major_version (ACE_OutputCDR& output);
ACE_CDR::Octet minor_version (ACE_OutputCDR& output);
};
// ****************************************************************
/**
* @class ACE_WChar_Codeset_Translator
*
@@ -1031,6 +1188,7 @@ class ACE_Export ACE_WChar_Codeset_Translator
{
public:
virtual ~ACE_WChar_Codeset_Translator ();
virtual ACE_CDR::Boolean read_wchar (ACE_InputCDR&,
ACE_CDR::WChar&) = 0;
virtual ACE_CDR::Boolean read_wstring (ACE_InputCDR&,
@@ -1046,6 +1204,7 @@ public:
virtual ACE_CDR::Boolean write_wchar_array (ACE_OutputCDR&,
const ACE_CDR::WChar*,
ACE_CDR::ULong) = 0;
virtual ACE_CDR::ULong ncs () = 0;
virtual ACE_CDR::ULong tcs () = 0;
protected:
@@ -1063,6 +1222,7 @@ protected:
const ACE_CDR::UShort *x);
ACE_CDR::Boolean write_4 (ACE_OutputCDR& output,
const ACE_CDR::ULong *x);
/// Efficiently read @a length elements of size @a size each from
/// <input> into <x>; the data must be aligned to <align>.
ACE_CDR::Boolean read_array (ACE_InputCDR& input,
@@ -1070,6 +1230,7 @@ protected:
size_t size,
size_t align,
ACE_CDR::ULong length);
/**
* Efficiently write @a length elements of size @a size from <x> into
* <output>. Before inserting the elements enough padding is added
@@ -1081,6 +1242,7 @@ protected:
size_t size,
size_t align,
ACE_CDR::ULong length);
/**
* Exposes the stream implementation of <adjust>, this is useful in
* many cases to minimize memory allocations during marshaling.
@@ -1092,30 +1254,40 @@ protected:
size_t size,
size_t align,
char *&buf);
/// Used by derived classes to set errors in the CDR stream.
void good_bit (ACE_OutputCDR& out, bool bit);
/// Obtain the CDR Stream's major & minor version values.
ACE_CDR::Octet major_version (ACE_InputCDR& input);
ACE_CDR::Octet minor_version (ACE_InputCDR& input);
ACE_CDR::Octet major_version (ACE_OutputCDR& output);
ACE_CDR::Octet minor_version (ACE_OutputCDR& output);
};
// @@ These operators should not be inlined since they force SString.h
// to be included in this header.
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
const ACE_CString &x);
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CString &x);
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
# include "ace/CDR_Stream.inl"
#else /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Not used by CORBA or TAO
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
ACE_CDR::Char x);
// CDR output operators for primitive types
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
ACE_CDR::Short x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
@@ -1134,7 +1306,9 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
ACE_CDR::Float x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
ACE_CDR::Double x);
// CDR output operator from helper classes
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
ACE_OutputCDR::from_boolean x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
@@ -1151,10 +1325,12 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
const ACE_CDR::Char* x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
const ACE_CDR::WChar* x);
// Not used by CORBA or TAO
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::Char &x);
// CDR input operators for primitive types
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::Short &x);
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
@@ -1173,7 +1349,9 @@ extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::Float &x);
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::Double &x);
// CDR input operator from helper classes
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_InputCDR::to_boolean x);
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
@@ -1190,23 +1368,36 @@ extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::Char*& x);
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::WChar*& x);
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* __ACE_INLINE__ */
#if defined (GEN_OSTREAM_OPS)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// ostream insertion operators for debugging code generated from IDL. All
// but these below are either in generated code itself or are unambiguous
// primitive types.
ACE_Export std::ostream& operator<< (std::ostream &os,
ACE_OutputCDR::from_boolean x);
ACE_Export std::ostream& operator<< (std::ostream &os,
ACE_OutputCDR::from_char x);
ACE_Export std::ostream& operator<< (std::ostream &os,
ACE_OutputCDR::from_wchar x);
ACE_Export std::ostream& operator<< (std::ostream &os,
ACE_OutputCDR::from_octet x);
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* GEN_OSTREAM_OPS */
#include /**/ "ace/post.h"
#endif /* ACE_CDR_STREAM_H */

Some files were not shown because too many files have changed in this diff Show More