00001 // -*- C++ -*- 00002 // 00003 // $Id: Log_Record.inl 84183 2009-01-19 08:50:16Z johnnyw $ 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_ = ACE_HTONL (this->length_); 00024 this->type_ = ACE_HTONL (this->type_); 00025 // Make sure we don't enclose the sec() and usec() fields until 00026 // they've been normalized. 00027 // secs_ is commented out because it can be 64 bits. This method is 00028 // deprecated; use the CDR operations instead. 00029 // this->secs_ = ACE_HTONL (this->secs_); 00030 this->usecs_ = ACE_HTONL (this->usecs_); 00031 this->pid_ = ACE_HTONL (this->pid_); 00032 } 00033 00034 ACE_INLINE void 00035 ACE_Log_Record::decode (void) 00036 { 00037 ACE_TRACE ("ACE_Log_Record::decode"); 00038 #if !defined (ACE_LACKS_NTOHL) 00039 ACE_Time_Value tv (this->secs_, 00040 ntohl (this->usecs_)); 00041 00042 this->secs_ = tv.sec (); 00043 this->usecs_ = tv.usec (); 00044 this->type_ = ntohl (this->type_); 00045 this->pid_ = ntohl (this->pid_); 00046 this->length_ = ntohl (this->length_); 00047 #endif /* ACE_LACKS_NTOHL */ 00048 } 00049 00050 ACE_INLINE ACE_UINT32 00051 ACE_Log_Record::type (void) const 00052 { 00053 ACE_TRACE ("ACE_Log_Record::type"); 00054 return this->type_; 00055 } 00056 00057 ACE_INLINE void 00058 ACE_Log_Record::type (ACE_UINT32 t) 00059 { 00060 ACE_TRACE ("ACE_Log_Record::type"); 00061 this->type_ = t; 00062 } 00063 00064 ACE_INLINE long 00065 ACE_Log_Record::length (void) const 00066 { 00067 ACE_TRACE ("ACE_Log_Record::length"); 00068 return (long) this->length_; 00069 } 00070 00071 ACE_INLINE void 00072 ACE_Log_Record::length (long l) 00073 { 00074 ACE_TRACE ("ACE_Log_Record::length"); 00075 this->length_ = static_cast<ACE_UINT32> (l); 00076 } 00077 00078 ACE_INLINE ACE_Time_Value 00079 ACE_Log_Record::time_stamp (void) const 00080 { 00081 ACE_TRACE ("ACE_Log_Record::time_stamp"); 00082 return ACE_Time_Value (this->secs_, (long) this->usecs_); 00083 } 00084 00085 ACE_INLINE void 00086 ACE_Log_Record::time_stamp (const ACE_Time_Value &ts) 00087 { 00088 ACE_TRACE ("ACE_Log_Record::time_stamp"); 00089 this->secs_ = ts.sec (); 00090 this->usecs_ = (ACE_UINT32) ts.usec (); 00091 } 00092 00093 ACE_INLINE long 00094 ACE_Log_Record::pid (void) const 00095 { 00096 ACE_TRACE ("ACE_Log_Record::pid"); 00097 return (long) this->pid_; 00098 } 00099 00100 ACE_INLINE void 00101 ACE_Log_Record::pid (long p) 00102 { 00103 ACE_TRACE ("ACE_Log_Record::pid"); 00104 this->pid_ = (ACE_UINT32) p; 00105 } 00106 00107 ACE_INLINE const ACE_TCHAR * 00108 ACE_Log_Record::msg_data (void) const 00109 { 00110 ACE_TRACE ("ACE_Log_Record::msg_data"); 00111 return this->msg_data_; 00112 } 00113 00114 ACE_INLINE size_t 00115 ACE_Log_Record::msg_data_len (void) const 00116 { 00117 ACE_TRACE ("ACE_Log_Record::msg_data_len"); 00118 return ACE_OS::strlen (this->msg_data_) + 1; 00119 } 00120 00121 ACE_END_VERSIONED_NAMESPACE_DECL