浏览代码

output() method

David Rose 23 年之前
父节点
当前提交
e04b7aa893
共有 3 个文件被更改,包括 20 次插入0 次删除
  1. 6 0
      panda/src/express/thread.I
  2. 10 0
      panda/src/express/thread.cxx
  3. 4 0
      panda/src/express/thread.h

+ 6 - 0
panda/src/express/thread.I

@@ -156,3 +156,9 @@ INLINE void Thread::
 sleep(double seconds) {
   ThreadImpl::sleep(seconds);
 }
+
+INLINE ostream &
+operator << (ostream &out, const Thread &thread) {
+  thread.output(out);
+  return out;
+}

+ 10 - 0
panda/src/express/thread.cxx

@@ -28,3 +28,13 @@ TypeHandle Thread::_type_handle;
 Thread::
 ~Thread() {
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: Thread::Destructor
+//       Access: Public, Virtual
+//  Description:
+////////////////////////////////////////////////////////////////////
+void Thread::
+output(ostream &out) const {
+  out << get_type() << " " << get_name();
+}

+ 4 - 0
panda/src/express/thread.h

@@ -61,6 +61,8 @@ public:
   INLINE static bool is_threading_supported();
   INLINE static void sleep(double seconds);
 
+  virtual void output(ostream &out) const;
+
 private:
   bool _started;
   string _name;
@@ -82,6 +84,8 @@ private:
   static TypeHandle _type_handle;
 };
 
+INLINE ostream &operator << (ostream &out, const Thread &thread);
+
 #include "thread.I"
 
 #endif