summaryrefslogtreecommitdiffstats
path: root/libdimensionxx
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-16 01:16:09 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-16 01:16:09 +0000
commit8f01c5394dcce8f5d4e7102dacfcdea9d1f7b021 (patch)
tree4092a281882e34ac53ec15d582dcbf2cb0d408c0 /libdimensionxx
parent1928016fe7aa439d4bfb61d3a7e7b7399ca7a229 (diff)
downloaddimension-8f01c5394dcce8f5d4e7102dacfcdea9d1f7b021.tar.xz
Add destructor callbacks for polymorphic C types, and use their base
dmnsn_delete_*() function.
Diffstat (limited to 'libdimensionxx')
-rw-r--r--libdimensionxx/camera.cpp8
-rw-r--r--libdimensionxx/cameras.cpp8
-rw-r--r--libdimensionxx/dimensionxx/camera.hpp2
-rw-r--r--libdimensionxx/dimensionxx/cameras.hpp2
-rw-r--r--libdimensionxx/dimensionxx/object.hpp2
-rw-r--r--libdimensionxx/dimensionxx/objects.hpp4
-rw-r--r--libdimensionxx/object.cpp8
-rw-r--r--libdimensionxx/objects.cpp16
8 files changed, 17 insertions, 33 deletions
diff --git a/libdimensionxx/camera.cpp b/libdimensionxx/camera.cpp
index b44173c..5786055 100644
--- a/libdimensionxx/camera.cpp
+++ b/libdimensionxx/camera.cpp
@@ -22,9 +22,13 @@
namespace Dimension
{
- // Virtual no-op destructor
+ // Virtual destructor
Camera::~Camera()
- { }
+ {
+ if (unique()) {
+ dmnsn_delete_camera(dmnsn());
+ }
+ }
// Return the result of the dmnsn_camera*'s ray callback
Line
diff --git a/libdimensionxx/cameras.cpp b/libdimensionxx/cameras.cpp
index ca571be..5d84c4f 100644
--- a/libdimensionxx/cameras.cpp
+++ b/libdimensionxx/cameras.cpp
@@ -31,14 +31,6 @@ namespace Dimension
}
}
- // Delete a perspective camera, if we're the last reference
- Perspective_Camera::~Perspective_Camera()
- {
- if (unique()) {
- dmnsn_delete_perspective_camera(dmnsn());
- }
- }
-
// Get the transformation matrix
Matrix
Perspective_Camera::trans()
diff --git a/libdimensionxx/dimensionxx/camera.hpp b/libdimensionxx/dimensionxx/camera.hpp
index d8743ce..fa13a7e 100644
--- a/libdimensionxx/dimensionxx/camera.hpp
+++ b/libdimensionxx/dimensionxx/camera.hpp
@@ -29,7 +29,7 @@ namespace Dimension
class Camera
{
public:
- // No-op
+ // Delete the camera
virtual ~Camera();
// Camera callback
diff --git a/libdimensionxx/dimensionxx/cameras.hpp b/libdimensionxx/dimensionxx/cameras.hpp
index 1764ac5..364ea4c 100644
--- a/libdimensionxx/dimensionxx/cameras.hpp
+++ b/libdimensionxx/dimensionxx/cameras.hpp
@@ -30,7 +30,7 @@ namespace Dimension
{
public:
Perspective_Camera(const Matrix& trans);
- ~Perspective_Camera();
+ // ~Perspective_Camera();
// Get/set the transformation matrix
Matrix trans();
diff --git a/libdimensionxx/dimensionxx/object.hpp b/libdimensionxx/dimensionxx/object.hpp
index 30dadf8..6505162 100644
--- a/libdimensionxx/dimensionxx/object.hpp
+++ b/libdimensionxx/dimensionxx/object.hpp
@@ -29,7 +29,7 @@ namespace Dimension
class Object
{
public:
- // No-op
+ // Delete the object
virtual ~Object();
// Get/set the transformation matrix
diff --git a/libdimensionxx/dimensionxx/objects.hpp b/libdimensionxx/dimensionxx/objects.hpp
index f86b2b3..15c072b 100644
--- a/libdimensionxx/dimensionxx/objects.hpp
+++ b/libdimensionxx/dimensionxx/objects.hpp
@@ -30,7 +30,7 @@ namespace Dimension
{
public:
Sphere();
- ~Sphere();
+ // ~Sphere();
// Shallow-copy the sphere
Object* copy();
@@ -46,7 +46,7 @@ namespace Dimension
{
public:
Cube();
- ~Cube();
+ // ~Cube();
// Shallow-copy the cube
Object* copy();
diff --git a/libdimensionxx/object.cpp b/libdimensionxx/object.cpp
index e5384db..9c28e22 100644
--- a/libdimensionxx/object.cpp
+++ b/libdimensionxx/object.cpp
@@ -22,9 +22,13 @@
namespace Dimension
{
- // Virtual no-op destructor
+ // Virtual destructor
Object::~Object()
- { }
+ {
+ if (unique()) {
+ dmnsn_delete_object(dmnsn());
+ }
+ }
// Get the transformation matrix
Matrix
diff --git a/libdimensionxx/objects.cpp b/libdimensionxx/objects.cpp
index 2272586..7bedd92 100644
--- a/libdimensionxx/objects.cpp
+++ b/libdimensionxx/objects.cpp
@@ -31,14 +31,6 @@ namespace Dimension
}
}
- // Delete a sphere
- Sphere::~Sphere()
- {
- if (unique()) {
- dmnsn_delete_sphere(dmnsn());
- }
- }
-
// Shallow copy a sphere
Object*
Sphere::copy()
@@ -60,14 +52,6 @@ namespace Dimension
}
}
- // Delete a sphere
- Cube::~Cube()
- {
- if (unique()) {
- dmnsn_delete_cube(dmnsn());
- }
- }
-
// Shallow copy a cube
Object*
Cube::copy()