From c405302613d0f6f022c15f3e777f2d534bdf40a6 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 22 Sep 2013 10:16:15 -0700 Subject: [PATCH] Add operator<< overload for Object --- src/object.cc | 9 +++++++++ src/object.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/object.cc b/src/object.cc index 8e3fde4..1c09bfa 100644 --- a/src/object.cc +++ b/src/object.cc @@ -54,6 +54,15 @@ Object::set_origin(Vector3 v) origin = v; } + +std::ostream & +operator<<(std::ostream &os, const Object &o) +{ + // Stream objects like this: [Object origin] + os << "[Object " << o.origin << "]"; + return os; +} + #pragma mark - Shapes /* diff --git a/src/object.h b/src/object.h index af36e28..f143fbc 100644 --- a/src/object.h +++ b/src/object.h @@ -9,6 +9,8 @@ #ifndef __OBJECT_H__ #define __OBJECT_H__ +#include + #include "basics.h" #include "material.h" #include "texture.h" @@ -23,10 +25,14 @@ public: Vector3 get_origin() const; void set_origin(Vector3 v); + friend std::ostream &operator<<(std::ostream &os, const Object &o); + private: Vector3 origin; }; +std::ostream &operator<<(std::ostream &os, const Object &o); + class Shape : public Object