libfractal_a_SOURCES= \
libfractal/Fractal.h libfractal/Fractal.cpp libfractal/Registry.h \
+ libfractal/FractalMaths.h libfractal/Fractal-internals.h \
libfractal/Mandelbrots.cpp libfractal/Mandelbar.cpp \
libfractal/Mandeldrop.cpp libfractal/Misc.cpp
--- /dev/null
+/*
+ Fractal-internals.h: Definitions internal to libfractal
+ Copyright (C) 2010-3 Ross Younger
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef FRACTAL_INTERNALS_H_
+#define FRACTAL_INTERNALS_H_
+
+#include "FractalMaths.h"
+
+namespace Fractal {
+
+// Every source file that declares fractals must have a load_ function.
+// They are called in Fractal.cpp.
+void load_Mandelbrot();
+void load_Mandelbar();
+void load_Mandeldrop();
+void load_Misc();
+
+
+class Consts {
+public:
+ static const Value log2;
+ static const Value log3;
+ static const Value log4;
+ static const Value log5;
+};
+
+/*
+ * Mixin helper class. This enables a single templated fractal definition
+ * class to write the iteration code once and have it reused multiple times
+ * with different maths types.
+ */
+template <class IMPL>
+class MathsMixin : public IMPL {
+public:
+ virtual ~MathsMixin() {}
+
+ virtual void prepare_pixel(const Point coords, PointData& out) const {
+ IMPL::prepare_pixel_impl(coords,out);
+ }
+
+#define DO_PLOT(type,name,minpix) \
+ case Maths::MathsType::name: \
+ IMPL::template plot_pixel_impl<type>(maxiter,out); \
+ break;
+
+ virtual void plot_pixel(int maxiter, PointData& out, Maths::MathsType type) const {
+ switch(type) {
+ ALL_MATHS_TYPES(DO_PLOT)
+ case Maths::MathsType::MAX:
+ throw "Unhandled value type";
+ }
+ }
+};
+
+}; // namespace Fractal
+
+#endif /* FRACTAL_INTERNALS_H_ */
#include <vector>
#include <glib.h>
#include "Fractal.h"
+#include "Fractal-internals.h"
using namespace Fractal;
base_loaded = false;
}
+void Fractal::FractalImpl::reg() {
+ FractalCommon::registry.reg(name, this);
+ isRegistered = 1;
+}
+
+void Fractal::FractalImpl::dereg()
+{
+ if (isRegistered)
+ FractalCommon::registry.dereg(name);
+ isRegistered = false;
+}
+
+
struct MathsInfo {
Maths::MathsType val;
const char* name;
#define FRACTAL_H_
#include <string>
-#include <complex>
#include <map>
#include <iostream>
#include "Registry.h"
#include "config.h"
+#include "FractalMaths.h"
namespace Fractal {
-// Every source file that declares fractals must have a load_ function.
-// They are called in Fractal.cpp.
-void load_Mandelbrot();
-void load_Mandelbar();
-void load_Mandeldrop();
-void load_Misc();
-
-////////////////////////////////////////////////////////////////////////////
-// Maths types and traits
-
-typedef long double Value; // short for "fractal value"
-typedef std::complex<Value> Point; // "complex fractal point"
-
-#ifdef ENABLE_DOUBLE
-#define MAYBE_DO_DOUBLE(_DO) _DO(double,Double,0.00000000000000044408920985006L /* 4.44e-16 */)
-#else
-#define MAYBE_DO_DOUBLE(_DO)
-#endif
-
-#ifdef ENABLE_FLOAT
-#define MAYBE_DO_FLOAT(_DO) _DO(float, Float, 0.0000002384185791016)
-#else
-#define MAYBE_DO_FLOAT(_DO)
-#endif
-
-// Master list of all maths types we know about.
-// Format: _DO(type name, enum name, minimum pixel size)
-#define ALL_MATHS_TYPES(_DO) \
- MAYBE_DO_FLOAT(_DO) \
- MAYBE_DO_DOUBLE(_DO) \
- _DO(long double, LongDouble, 0.0000000000000000002168404345L /* 2.16e-19 */) \
-
-
-class Maths {
-public:
- enum class MathsType {
-#define DO_ENUM(type,name,minpix) name,
- ALL_MATHS_TYPES(DO_ENUM)
- MAX,
- };
-
- static const char* name(MathsType t); // Enum to name conversion
- static Value min_pixel_size(MathsType t); // Minimum pixel size lookup
- static Value smallest_min_pixel_size();
-};
-
-////////////////////////////////////////////////////////////////////////////
-
-class Consts {
-public:
- static const Value log2;
- static const Value log3;
- static const Value log4;
- static const Value log5;
-};
-
////////////////////////////////////////////////////////////////////////////
class PointData {
private:
bool isRegistered;
- void reg() { FractalCommon::registry.reg(name, this); isRegistered = 1; }
- void dereg()
- {
- if (isRegistered)
- FractalCommon::registry.dereg(name);
- isRegistered = false;
- }
-};
-
-/*
- * Mixin helper class. This enables a single templated fractal definition
- * class to write the iteration code once and have it reused multiple times
- * with different maths types.
- */
-template <class IMPL>
-class MathsMixin : public IMPL {
-public:
- virtual ~MathsMixin() {}
-
- virtual void prepare_pixel(const Point coords, PointData& out) const {
- IMPL::prepare_pixel_impl(coords,out);
- }
-
-#define DO_PLOT(type,name,minpix) \
- case Maths::MathsType::name: \
- IMPL::template plot_pixel_impl<type>(maxiter,out); \
- break;
-
- virtual void plot_pixel(int maxiter, PointData& out, Maths::MathsType type) const {
- switch(type) {
- ALL_MATHS_TYPES(DO_PLOT)
- case Maths::MathsType::MAX:
- throw "Unhandled value type";
- }
- }
+ void reg();
+ void dereg();
};
}; // namespace Fractal
-inline Fractal::Point operator/(const Fractal::Point& a, Fractal::Value b) {
- Fractal::Point rv(a);
- rv.real(real(rv)/b);
- rv.imag(imag(rv)/b);
- return rv;
-}
-
#endif /* FRACTAL_H_ */
--- /dev/null
+/*
+ FractalMaths.h: Maths types for the fractal library
+ Copyright (C) 2010-3 Ross Younger
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef FRACTALMATHS_H_
+#define FRACTALMATHS_H_
+
+#include <complex>
+
+namespace Fractal {
+
+////////////////////////////////////////////////////////////////////////////
+// Maths types and traits
+
+typedef long double Value; // short for "fractal value"
+typedef std::complex<Value> Point; // "complex fractal point"
+
+#ifdef ENABLE_DOUBLE
+#define MAYBE_DO_DOUBLE(_DO) _DO(double,Double,0.00000000000000044408920985006L /* 4.44e-16 */)
+#else
+#define MAYBE_DO_DOUBLE(_DO)
+#endif
+
+#ifdef ENABLE_FLOAT
+#define MAYBE_DO_FLOAT(_DO) _DO(float, Float, 0.0000002384185791016)
+#else
+#define MAYBE_DO_FLOAT(_DO)
+#endif
+
+// Master list of all maths types we know about.
+// Format: _DO(type name, enum name, minimum pixel size)
+#define ALL_MATHS_TYPES(_DO) \
+ MAYBE_DO_FLOAT(_DO) \
+ MAYBE_DO_DOUBLE(_DO) \
+ _DO(long double, LongDouble, 0.0000000000000000002168404345L /* 2.16e-19 */) \
+
+class Maths {
+public:
+ enum class MathsType {
+#define DO_ENUM(type,name,minpix) name,
+ ALL_MATHS_TYPES(DO_ENUM)
+ MAX,
+ };
+
+ static const char* name(MathsType t); // Enum to name conversion
+ static Value min_pixel_size(MathsType t); // Minimum pixel size lookup
+ static Value smallest_min_pixel_size();
+};
+
+}; // namespace Fractal
+
+////////////////////////////////////////////////////////////////////////////
+
+inline Fractal::Point operator/(const Fractal::Point& a, Fractal::Value b) {
+ Fractal::Point rv(a);
+ rv.real(real(rv)/b);
+ rv.imag(imag(rv)/b);
+ return rv;
+}
+
+#endif /* FRACTALMATHS_H_ */
*/
#include "Fractal.h"
+#include "Fractal-internals.h"
#include <iostream>
using namespace std;
*/
#include "Fractal.h"
+#include "Fractal-internals.h"
using namespace std;
using namespace Fractal;
*/
#include "Fractal.h"
+#include "Fractal-internals.h"
using namespace std;
using namespace Fractal;
*/
#include "Fractal.h"
+#include "Fractal-internals.h"
using namespace std;
using namespace Fractal;