summaryrefslogtreecommitdiffstats
path: root/libdimensionxx/dimensionxx/camera.hpp
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-07 04:23:05 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-07 04:23:05 +0000
commit81c84a38992ce8e38106d86ce85ac3e88ed91a31 (patch)
tree08fb5913e141b7e208737b799b45921d477d45cc /libdimensionxx/dimensionxx/camera.hpp
parentd7b7b4b3391cf99ca63d8311eac3957df7a862ed (diff)
downloaddimension-81c84a38992ce8e38106d86ce85ac3e88ed91a31.tar.xz
Add shallow copy semantics to Camera's, Object's, and Scene's.
Diffstat (limited to 'libdimensionxx/dimensionxx/camera.hpp')
-rw-r--r--libdimensionxx/dimensionxx/camera.hpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/libdimensionxx/dimensionxx/camera.hpp b/libdimensionxx/dimensionxx/camera.hpp
index 950e16d..a883969 100644
--- a/libdimensionxx/dimensionxx/camera.hpp
+++ b/libdimensionxx/dimensionxx/camera.hpp
@@ -29,12 +29,15 @@ namespace Dimension
class Camera
{
public:
- // No-op, made pure virtual
- virtual ~Camera() = 0;
+ // No-op
+ virtual ~Camera();
// Camera callback
virtual Line ray(const Canvas& canvas, unsigned int x, unsigned int y);
+ // Shallow-copy a derived camera
+ virtual Camera* copy() const = 0;
+
// Access the wrapped C camera.
dmnsn_camera* dmnsn();
const dmnsn_camera* dmnsn() const;
@@ -42,15 +45,22 @@ namespace Dimension
protected:
// No-op
Camera();
+ // Shallow-copy
+ Camera(const Camera& camera);
// Wrap an existing camera
explicit Camera(dmnsn_camera* camera);
- dmnsn_camera* m_camera;
+ // Is m_camera unique?
+ bool unique() const;
+
+ // Set the wrapped C camera
+ void dmnsn(dmnsn_camera* camera);
private:
- // Copying prohibited
- Camera(const Camera&);
+ // Copy-assignment prohibited
Camera& operator=(const Camera&);
+
+ std::tr1::shared_ptr<dmnsn_camera*> m_camera;
};
// A custom camera abstract base class, for creating your own camera types