00001 // -*- C++ -*- 00002 // 00003 // Log_Record.inl,v 4.5 2006/05/16 22:27:33 wotte Exp 00004 00005 #include "ace/Global_Macros.h" 00006 #include "ace/os_include/arpa/os_inet.h" 00007 #include "ace/Time_Value.h" 00008 #include "ace/OS_NS_string.h" 00009 00010 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00011 00012 ACE_INLINE 00013 ACE_Log_Record::~ACE_Log_Record (void) 00014 { 00015 if (this->msg_data_) 00016 delete[] this->msg_data_; 00017 } 00018 00019 ACE_INLINE void 00020 ACE_Log_Record::encode (void) 00021 { 00022 ACE_TRACE ("ACE_Log_Record::encode"); 00023 this->length_ = htonl (this->length_); 00024 this->type_ = htonl (this->type_); 00025 // Make sure we don't enclose the sec() and usec() fields until 00026 // they've been normalized. 00027 this->secs_ = htonl (this->secs_); 00028 this->usecs_ = htonl (this->usecs_); 00029 this->pid_ = htonl (this->pid_); 00030 } 00031 00032 ACE_INLINE void 00033 ACE_Log_Record::decode (void) 00034 { 00035 ACE_TRACE ("ACE_Log_Record::decode"); 00036 ACE_Time_Value tv (ntohl (this->secs_), 00037 ntohl (this->usecs_)); 00038 00039 this->secs_ = tv.sec (); 00040 this->usecs_ = tv.usec (); 00041 this->type_ = ntohl (this->type_); 00042 this->pid_ = ntohl (this->pid_); 00043 this->length_ = ntohl (this->length_); 00044 } 00045 00046 ACE_INLINE ACE_UINT32 00047 ACE_Log_Record::type (void) const 00048 { 00049 ACE_TRACE ("ACE_Log_Record::type"); 00050 return this->type_; 00051 } 00052 00053 ACE_INLINE void 00054 ACE_Log_Record::type (ACE_UINT32 t) 00055 { 00056 ACE_TRACE ("ACE_Log_Record::type"); 00057 this->type_ = t; 00058 } 00059 00060 ACE_INLINE long 00061 ACE_Log_Record::length (void) const 00062 { 00063 ACE_TRACE ("ACE_Log_Record::length"); 00064 return (long) this->length_; 00065 } 00066 00067 ACE_INLINE void 00068 ACE_Log_Record::length (long l) 00069 { 00070 ACE_TRACE ("ACE_Log_Record::length"); 00071 this->length_ = static_cast<ACE_UINT32> (l); 00072 } 00073 00074 ACE_INLINE ACE_Time_Value 00075 ACE_Log_Record::time_stamp (void) const 00076 { 00077 ACE_TRACE ("ACE_Log_Record::time_stamp"); 00078 return ACE_Time_Value ((long) this->secs_, (long) this->usecs_); 00079 } 00080 00081 ACE_INLINE void 00082 ACE_Log_Record::time_stamp (const ACE_Time_Value &ts) 00083 { 00084 ACE_TRACE ("ACE_Log_Record::time_stamp"); 00085 this->secs_ = (ACE_UINT32) ts.sec (); 00086 this->usecs_ = (ACE_UINT32) ts.usec (); 00087 } 00088 00089 ACE_INLINE long 00090 ACE_Log_Record::pid (void) const 00091 { 00092 ACE_TRACE ("ACE_Log_Record::pid"); 00093 return (long) this->pid_; 00094 } 00095 00096 ACE_INLINE void 00097 ACE_Log_Record::pid (long p) 00098 { 00099 ACE_TRACE ("ACE_Log_Record::pid"); 00100 this->pid_ = (ACE_UINT32) p; 00101 } 00102 00103 ACE_INLINE const ACE_TCHAR * 00104 ACE_Log_Record::msg_data (void) const 00105 { 00106 ACE_TRACE ("ACE_Log_Record::msg_data"); 00107 return this->msg_data_; 00108 } 00109 00110 ACE_INLINE void 00111 ACE_Log_Record::set_msg_data_ptr (ACE_TCHAR *data) 00112 { 00113 this->msg_data_ = data; 00114 } 00115 00116 ACE_INLINE size_t 00117 ACE_Log_Record::msg_data_len (void) const 00118 { 00119 ACE_TRACE ("ACE_Log_Record::msg_data_len"); 00120 return ACE_OS::strlen (this->msg_data_) + 1; 00121 } 00122 00123 ACE_END_VERSIONED_NAMESPACE_DECL