Browse Source

better output methods

David Rose 22 years ago
parent
commit
6dfe2d4a49

+ 12 - 12
panda/src/chan/animControl.cxx

@@ -362,6 +362,18 @@ get_part() const {
   return DCAST(PartBundle, _part);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: AnimControl::output
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void AnimControl::
+output(ostream &out) const {
+  out << "AnimControl(" << get_part()->get_name()
+      << ", " << get_anim()->get_name() << ")";
+}
+
+
 
 ////////////////////////////////////////////////////////////////////
 //     Function: AnimControl::advance_time
@@ -457,18 +469,6 @@ mark_channels() {
   _marked_frame = get_frame();
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: AnimControl::output
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-void AnimControl::
-output(ostream &out) const {
-  out << "AnimControl(" << get_part()->get_name()
-      << ", " << get_anim()->get_name() << ")";
-}
-
-
 
 ////////////////////////////////////////////////////////////////////
 //     Function: AnimControl::insert_event_action

+ 2 - 2
panda/src/chan/animControl.h

@@ -74,6 +74,8 @@ PUBLISHED:
   PartBundle *get_part() const;
   INLINE AnimBundle *get_anim() const;
 
+  void output(ostream &out) const;
+
 public:
   // The following functions aren't really part of the public
   // interface; they're just public so we don't have to declare a
@@ -86,8 +88,6 @@ public:
 
   INLINE int get_channel_index() const;
 
-  void output(ostream &out) const;
-
 private:
 
   enum ActionType {

+ 7 - 0
panda/src/chan/animControlCollection.I

@@ -239,3 +239,10 @@ get_num_frames(const string &anim_name) const {
   }
   return control->get_num_frames();
 }
+
+INLINE ostream &
+operator << (ostream &out, const AnimControlCollection &collection) {
+  collection.output(out);
+  return out;
+}
+

+ 23 - 0
panda/src/chan/animControlCollection.cxx

@@ -229,3 +229,26 @@ which_anim_playing() const {
 
   return result;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: AnimControlCollection::output
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void AnimControlCollection::
+output(ostream &out) const {
+  out << _controls.size() << " anims.";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: AnimControlCollection::write
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void AnimControlCollection::
+write(ostream &out) const {
+  Controls::const_iterator ci;
+  for (ci = _controls.begin(); ci != _controls.end(); ++ci) {
+    out << (*ci).first << ": " << *(*ci).second << "\n";
+  }
+}

+ 7 - 3
panda/src/chan/animControlCollection.h

@@ -23,10 +23,9 @@
 
 #include "animControl.h"
 
-#include <event.h>
-#include <pt_Event.h>
+#include "event.h"
+#include "pt_Event.h"
 
-#include <string>
 #include "pmap.h"
 
 ////////////////////////////////////////////////////////////////////
@@ -84,6 +83,9 @@ PUBLISHED:
 
   string which_anim_playing() const;
 
+  void output(ostream &out) const;
+  void write(ostream &out) const;
+
 private:
   typedef pmap<string,  PT(AnimControl) > Controls;
   Controls _controls;
@@ -91,6 +93,8 @@ private:
   AnimControl *_last_started_control;
 };
 
+INLINE ostream &operator << (ostream &out, const AnimControlCollection &collection);
+
 #include "animControlCollection.I"
 
 #endif