summaryrefslogtreecommitdiffstats
path: root/libdimensionxx
diff options
context:
space:
mode:
Diffstat (limited to 'libdimensionxx')
-rw-r--r--libdimensionxx/Makefile.am2
-rw-r--r--libdimensionxx/dimensionxx.hpp3
-rw-r--r--libdimensionxx/dimensionxx/cube.hpp30
-rw-r--r--libdimensionxx/dimensionxx/object.hpp2
-rw-r--r--libdimensionxx/dimensionxx/objects.hpp45
-rw-r--r--libdimensionxx/object.cpp5
-rw-r--r--libdimensionxx/objects.cpp54
7 files changed, 139 insertions, 2 deletions
diff --git a/libdimensionxx/Makefile.am b/libdimensionxx/Makefile.am
index 6b53858..b35ec97 100644
--- a/libdimensionxx/Makefile.am
+++ b/libdimensionxx/Makefile.am
@@ -24,6 +24,7 @@ nobase_include_HEADERS = dimensionxx.hpp \
dimensionxx/cookie.hpp \
dimensionxx/geometry.hpp \
dimensionxx/object.hpp \
+ dimensionxx/objects.hpp \
dimensionxx/png.hpp \
dimensionxx/progress.hpp
@@ -36,6 +37,7 @@ libdimensionxx_la_SOURCES = $(nobase_include_HEADERS) \
color.cpp \
error.cpp \
object.cpp \
+ objects.cpp \
png.cpp \
progress.cpp
diff --git a/libdimensionxx/dimensionxx.hpp b/libdimensionxx/dimensionxx.hpp
index d8df782..c413d87 100644
--- a/libdimensionxx/dimensionxx.hpp
+++ b/libdimensionxx/dimensionxx.hpp
@@ -31,7 +31,8 @@
#include <dimensionxx/geometry.hpp>
#include <dimensionxx/color.hpp>
#include <dimensionxx/canvas.hpp>
-#include <dimensionxx/object.hpp>
#include <dimensionxx/png.hpp>
+#include <dimensionxx/object.hpp>
+#include <dimensionxx/objects.hpp>
#endif /* DIMENSIONXX_HPP */
diff --git a/libdimensionxx/dimensionxx/cube.hpp b/libdimensionxx/dimensionxx/cube.hpp
new file mode 100644
index 0000000..9452c88
--- /dev/null
+++ b/libdimensionxx/dimensionxx/cube.hpp
@@ -0,0 +1,30 @@
+/*************************************************************************
+ * Copyright (C) 2008 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The Dimension Library. *
+ * *
+ * The Dimension Library is free software; you can redistribute it and/ *
+ * or modify it under the terms of the GNU Lesser General Public License *
+ * as published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Library is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this program. If not, see *
+ * <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Cube wrapper
+
+#ifndef DIMENSIONXX_CUBE_HPP
+#define DIMENSIONXX_CUBE_HPP
+
+namespace Dimension
+{
+}
+
+#endif /* DIMENSIONXX_CUBE_HPP */
diff --git a/libdimensionxx/dimensionxx/object.hpp b/libdimensionxx/dimensionxx/object.hpp
index 40dcb25..6eaca83 100644
--- a/libdimensionxx/dimensionxx/object.hpp
+++ b/libdimensionxx/dimensionxx/object.hpp
@@ -43,7 +43,7 @@ namespace Dimension
// No-op
Object();
// Wrap an existing object.
- explicit Object(dmnsn_object* object) : m_object(object) { }
+ explicit Object(dmnsn_object* object);
dmnsn_object* m_object;
diff --git a/libdimensionxx/dimensionxx/objects.hpp b/libdimensionxx/dimensionxx/objects.hpp
new file mode 100644
index 0000000..5d5fe46
--- /dev/null
+++ b/libdimensionxx/dimensionxx/objects.hpp
@@ -0,0 +1,45 @@
+/*************************************************************************
+ * Copyright (C) 2008 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The Dimension Library. *
+ * *
+ * The Dimension Library is free software; you can redistribute it and/ *
+ * or modify it under the terms of the GNU Lesser General Public License *
+ * as published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Library is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this program. If not, see *
+ * <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+// Object wrappers.
+
+#ifndef DIMENSIONXX_OBJECTS_HPP
+#define DIMENSIONXX_OBJECTS_HPP
+
+namespace Dimension
+{
+ // Sphere object
+ class Sphere : public Object
+ {
+ public:
+ Sphere();
+ virtual ~Sphere();
+ };
+
+ // A cube
+ class Cube : public Object
+ {
+ public:
+ Cube();
+ virtual ~Cube();
+ };
+}
+
+#endif /* DIMENSIONXX_OBJECTS_HPP */
diff --git a/libdimensionxx/object.cpp b/libdimensionxx/object.cpp
index 33aeb85..61a887c 100644
--- a/libdimensionxx/object.cpp
+++ b/libdimensionxx/object.cpp
@@ -58,6 +58,11 @@ namespace Dimension
Object::Object()
{ }
+ // Protected manual constructor
+ Object::Object(dmnsn_object *object)
+ : m_object(object)
+ { }
+
// Custom object callbacks
namespace {
dmnsn_array *
diff --git a/libdimensionxx/objects.cpp b/libdimensionxx/objects.cpp
new file mode 100644
index 0000000..1a63494
--- /dev/null
+++ b/libdimensionxx/objects.cpp
@@ -0,0 +1,54 @@
+/*************************************************************************
+ * Copyright (C) 2008 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The Dimension Library. *
+ * *
+ * The Dimension Library is free software; you can redistribute it and/ *
+ * or modify it under the terms of the GNU Lesser General Public License *
+ * as published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Library is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this program. If not, see *
+ * <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+#include "dimensionxx.hpp"
+
+namespace Dimension
+{
+ // Create a sphere
+ Sphere::Sphere()
+ : Object(dmnsn_new_sphere())
+ {
+ if (!m_object) {
+ throw Dimension_Error("Failed to allocate sphere.");
+ }
+ }
+
+ // Delete a sphere
+ Sphere::~Sphere()
+ {
+ dmnsn_delete_sphere(m_object);
+ }
+
+ // Create a cube
+ Cube::Cube()
+ : Object(dmnsn_new_cube())
+ {
+ if (!m_object) {
+ throw Dimension_Error("Failed to allocate sphere.");
+ }
+ }
+
+ // Delete a sphere
+ Cube::~Cube()
+ {
+ dmnsn_delete_cube(m_object);
+ }
+}