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