1 /**
2 * This module defines the notion of a $(RENDERER). A $(RENDERER) is responsible
3 * for "rendering" the $(I ca's) $(LATTICE) in a way that humans can appriciate.
4 * While a $(RENDERER) is not "mathematicly" part of a $(I cellular automaton), it
5 * is here for obvious reasons.
6 *
7 * This module provides templates for testing whether a given object is a $(RENDERER),
8 * and what kind of $(RENDERER) it is.
9 *
10 * $(CALIB_ABSTRACT_DESC)
11 */
12 
13 module caLib_abstract.renderer;
14 
15 /**
16 * Returns `true` if T is a $(B Renderer) defined as having the primitives:
17 * `void render()` $(BR)
18 * `string[] getScreenshootFormats()`
19 * `void screendshot(string path, string format)`
20 * `string[] getRecordingFormats()`
21 * `void startRecording(string path, string format)`
22 * `void stopRecording()`
23 * `void moveViewport(int xDir, int yDir)`
24 * `void zoom(int factor)`
25 *
26 * A $(B Renderer) is the most basic form of a $(RENDERER).
27 */
28 enum isRenderer(T) =
29 	is(typeof(T.init.render()) : void) &&
30 	is(typeof(T.init.screenshot("")) : void) &&
31 	is(typeof(T.init.startRecording("", uint.init)) : void) &&
32 	is(typeof(T.init.stopRecording()) : void) &&
33 	is(typeof(T.init.moveViewport(int.init, int.init)) : void) &&
34 	is(typeof(T.init.zoom(int.init)) : void);
35 
36 unittest
37 {
38 	static assert( isRenderer!Renderer);
39 	static assert(!isRenderer!string);
40 }
41 
42 
43 version(unittest)
44 {
45 	struct Renderer
46 	{
47 		void render() {}
48 
49 		void screenshot(string path) {}
50 		
51 		void startRecording(string path, uint framerate) {}
52 		void stopRecording() {}
53 
54 		void moveViewport(int xDir, int yDir) {}
55 		void zoom(int factor) {}
56 	}
57 }