summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhuangming <huangminghuang@users.noreply.github.com>2004-01-24 00:10:31 +0000
committerhuangming <huangminghuang@users.noreply.github.com>2004-01-24 00:10:31 +0000
commitbed52302604f719847162489a62b210cd04298af (patch)
tree5098fa99bddf2d0d685033bf5550854fd0797409
parentbc741dd19c37df5852781cd9d95f434984899caa (diff)
downloadATCD-bed52302604f719847162489a62b210cd04298af.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp60
-rw-r--r--TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h72
-rw-r--r--TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl70
-rw-r--r--TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h34
-rw-r--r--TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl15
5 files changed, 251 insertions, 0 deletions
diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp
new file mode 100644
index 00000000000..570ccf9d170
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp
@@ -0,0 +1,60 @@
+//$Id$
+#include "Log.h"
+
+#if !defined(__ACE_INLINE__)
+#include "Log.inl"
+#endif /* __ACE_INLINE__ */
+
+namespace TAO_FTRTEC {
+
+ unsigned int Log::log_level_;
+
+#ifndef NDEBUG
+ Log::Log (unsigned int log_level, const ACE_TCHAR* format, ...)
+ {
+ if (log_level_ >= log_level) {
+ va_list p;
+ va_start(p, format);
+ char str[1024];
+ ACE_OS::vsprintf(str, format, p);
+ ACE_DEBUG((LM_DEBUG, str));
+ va_end(p);
+ }
+ }
+
+ char buffer [1024*100];
+ char* now=buffer;
+
+ void TimeLogger::set_message(const char* msg)
+ {
+ msg_ = msg;
+ }
+
+ void TimeLogger::start()
+ {
+ start_time_ = ACE_OS::gettimeofday ();
+ }
+
+ void TimeLogger::stop()
+ {
+ ACE_Time_Value stop = ACE_OS::gettimeofday ();
+ ACE_Time_Value result = stop - start_time_;
+
+ int time_in_usec = result.sec()*1000000+result.usec();
+ int n = ACE_OS::snprintf(now, buffer-now+sizeof(buffer),
+ "%s %d , start = %d.%06d, stop = %d.%06d\n",
+ msg_, time_in_usec, start_time_.sec(), start_time_.usec(),
+ stop.sec(), stop.usec());
+ now+=n;
+ }
+
+ void TimeLogger::output()
+ {
+ ACE_DEBUG((LM_DEBUG, buffer));
+ buffer[0] = '\0';
+ now = buffer;
+ }
+
+#endif
+
+}
diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h
new file mode 100644
index 00000000000..9b55041d3d8
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+//=============================================================================
+/**
+ * @file Log.h
+ *
+ * $Id$
+ *
+ * @author Huang-Ming Huang <hh1@cse.wustl.edu>
+ */
+//=============================================================================
+#ifndef FTRTEC_LOG_H
+#define FTRTEC_LOG_H
+
+#include /**/ "ace/pre.h"
+#include "ftrtevent_export.h"
+#include "ace/OS.h"
+#include "ace/Log_Msg.h"
+
+namespace TAO_FTRTEC {
+
+ class TAO_FtRtEvent_Export Trace
+ {
+ public:
+ Trace(const char* msg);
+ ~Trace();
+ private:
+ const char* msg_;
+ };
+
+ class TAO_FtRtEvent_Export TimeLogger
+ {
+ public:
+ void set_message(const char* msg);
+ void start();
+ void stop();
+ static void output();
+ private:
+ const char* msg_;
+ ACE_Time_Value start_time_;
+ };
+
+ class TAO_FtRtEvent_Export TimeAutoLogger : public TimeLogger
+ {
+ public:
+ TimeAutoLogger(const char* msg) { set_message(msg); start(); }
+ ~TimeAutoLogger() { stop(); }
+ };
+
+ /**
+ * A utility class for logging messages.
+ */
+ class TAO_FtRtEvent_Export Log
+ {
+ public:
+ Log (unsigned int log_level, const ACE_TCHAR* format, ...);
+ static void level(unsigned int log_level);
+ static unsigned int level();
+ static void hexdump(unsigned int log_level, const char* buf, size_t len, const char* msg);
+ private:
+ friend class Trace;
+ static unsigned log_level_;
+ };
+}
+
+#define FTRTEC_TRACE(x) TAO_FTRTEC::Trace __ftrtec_trace_obj(x)
+#define FTRTEC_LOGTIME(x) TAO_FTRTEC::TimeAutoLogger __ftrtec_time_logger(x)
+#if defined(__ACE_INLINE__)
+#include "Log.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif
diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl
new file mode 100644
index 00000000000..07ec051f99a
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl
@@ -0,0 +1,70 @@
+// $Id$
+
+namespace TAO_FTRTEC {
+#ifndef NDEBUG
+ ACE_INLINE
+ Trace::Trace(const char* msg)
+ : msg_(msg)
+ {
+ if (Log::log_level_ >=5)
+ ACE_DEBUG((LM_DEBUG, "Enter %s\n",msg));
+ }
+
+ ACE_INLINE
+ Trace::~Trace()
+ {
+ if (Log::log_level_ >=5)
+ ACE_DEBUG((LM_DEBUG, "Leave %s\n",msg_));
+ }
+
+ ACE_INLINE
+ void Log::level(unsigned int log_level)
+ {
+ log_level_ = log_level;
+ }
+
+ ACE_INLINE
+ unsigned int Log::level()
+ {
+ return log_level_;
+ }
+
+ ACE_INLINE
+ void Log::hexdump(unsigned int level, const char* buf, size_t len, const char* msg)
+ {
+ if (Log::log_level_ >= level)
+ ACE_HEX_DUMP((LM_DEBUG, buf, len, msg));
+ }
+#else // NDEBUG
+ ACE_INLINE
+ Trace::Trace(const char* )
+ {
+ }
+
+ ACE_INLINE
+ Trace::~Trace()
+ {
+ }
+
+ ACE_INLINE
+ Log::Log (unsigned int, const ACE_TCHAR*, ...)
+ {
+ }
+
+ ACE_INLINE
+ void Log::level(unsigned int )
+ {
+ }
+
+ ACE_INLINE
+ unsigned int Log::level()
+ {
+ return 0;
+ }
+
+ ACE_INLINE
+ void Log::hexdump(unsigned int, const char*, size_t, const char*)
+ {
+ }
+#endif
+}
diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h
new file mode 100644
index 00000000000..7f0cfb993fb
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//=============================================================================
+/**
+ * @file Safe_InputCDR.h
+ *
+ * $Id$
+ *
+ * @author Huang-Ming Huang <hh1@cse.wustl.edu>
+ */
+//=============================================================================
+#ifndef SAFE_INPUTCDR_H
+#define SAFE_INPUTCDR_H
+#include /**/ "ace/pre.h"
+
+#include "tao/CDR.h"
+
+class Safe_InputCDR : public TAO_InputCDR
+{
+public:
+ /**
+ * Create an input stream from an arbitrary buffer.
+ *
+ * This contructor will work no matter the buffer is aligned properly
+ * or not. If the buffer is not properly aligned, it will make a copy
+ * of the buffer.
+ */
+ Safe_InputCDR(const char* buf, int size);
+};
+
+
+#include "Safe_InputCDR.inl"
+
+#include /**/ "ace/post.h"
+#endif
diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl
new file mode 100644
index 00000000000..5a0a41e0716
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl
@@ -0,0 +1,15 @@
+// $Id$
+
+inline
+Safe_InputCDR::Safe_InputCDR(const char* buf, int size)
+: TAO_InputCDR((ACE_Message_Block*)0)
+{
+ if (ACE_ptr_align_binary(buf, ACE_CDR::MAX_ALIGNMENT) != buf) {
+ ACE_CDR::grow(&start_,size);
+ this->start_.copy(buf, size);
+ }
+ else {
+ this->start_.init(buf,size);
+ this->start_.wr_ptr(size);
+ }
+};