view include/Fractal.h @ 3:0f4ad525f49a

Lot's of cleanup. Applied AbstractFactory to class Fractal and derivatives. Decoupled most objects. Removed remaining standard C function calls. Improved old_views handling.
author Eris Caffee <discordia@eldalin.com>
date Sat, 23 Oct 2010 04:24:48 -0500
parents 0684158d38a8
children df02a7de7fe2
line source
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) 2010 Sarah Eris Horsley Caffee
4 //
5 // mandelbrot - A simple Mandelbrot Set viewer.
6 //
7 // Fractal.h
8 // Fractal calculator virtual class definition. Actual fractals should
9 // implement this.
10 //
11 ////////////////////////////////////////////////////////////////////////////////
13 #ifndef FRACTAL_H
14 #define FRACTAL_H
16 #include <map>
17 #include <string>
19 // Need to define this via the pre-processor because if it's a staticaly
20 // initialized const string we still have no guarantee that it will be
21 // initialized before it is needed by a FractalCreator class.
22 // Do the same in all derived classes.
23 #define FRACTAL_TYPE_NAME "Fractal"
25 class Fractal
26 {
27 public:
28 Fractal();
30 virtual bool calc_set() = 0;
31 virtual bool init(SDL_Surface * surf) = 0;
33 double get_re_min();
34 double set_re_min(const double r_min);
36 double get_im_max();
37 double set_im_max(const double i_max);
39 double get_size();
40 double set_size(const double s);
42 unsigned int get_max_iter();
43 unsigned int set_max_iter(const unsigned int iter);
44 unsigned int inc_max_iter();
45 unsigned int dec_max_iter();
47 void set_calc_needed();
49 virtual const char * get_display_name();
50 virtual const char * get_type_name();
52 virtual bool get_option(std::string option, void * value) {};
53 virtual bool set_option(std::string option, void * value) {};
57 protected:
59 virtual void draw_pixel(int x, int y, Uint32 * color);
61 std::string display_name;
62 std::string type_name;
64 double re_min;
65 double im_max;
66 double size;
67 unsigned int max_iter;
68 bool calc_needed;
70 SDL_Surface * surface;
72 };
74 class FractalCreator
75 {
76 public:
77 virtual Fractal * create() const = 0;
78 };
80 std::map <std::string, FractalCreator *> & get_Fractal_map();
82 #endif