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 * `void screendshot(string path)` 19 * `void startRecording(string path)` 20 * `void stopRecording()` 21 * 22 * A $(B Renderer) is the most basic form of a $(RENDERER). 23 */ 24 enum isRenderer(T) = 25 is(typeof(T.init.render()) : void) && 26 is(typeof(T.init.screenshot("")) : void) && 27 is(typeof(T.init.startRecording("", uint.init)) : void) && 28 is(typeof(T.init.stopRecording()) : void); 29 30 unittest 31 { 32 static assert( isRenderer!Renderer); 33 static assert(!isRenderer!string); 34 } 35 36 37 38 /// Example of a $(B Renderer) 39 struct Renderer 40 { 41 void render() {} 42 43 void screenshot(string path) {} 44 45 void startRecording(string path, uint framerate) {} 46 void stopRecording() {} 47 } 48 49 /// 50 unittest 51 { 52 static assert( isRenderer!Renderer); 53 static assert(!isRenderer!string); 54 }