30.06.2013 Aufrufe

Softwareentwicklung in C++ - ASC

Softwareentwicklung in C++ - ASC

Softwareentwicklung in C++ - ASC

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

278 10. Memory – e<strong>in</strong> kle<strong>in</strong>es Beispiel<br />

93 ∗/<br />

94 virtual OutputContext ∗ getOutputContextClone ( )<br />

95 {<br />

96 return ( output context . getClone ( ) ) ;<br />

97 }<br />

98 } ;<br />

99<br />

100<br />

101 #endif // s i m p l e o u t p u t h a n d l i n g h<br />

10.2.10 Displayable<br />

Die Klasse SimpleOutputHandl<strong>in</strong>g arbeitet ausschließlich mit Elementen der<br />

Klasse Displayable. Diese ist e<strong>in</strong>e abstrakte Basisklasse, von der man darstellbare<br />

Klassen entsprechend ableiten muss. Das Interface, das solche Klassen<br />

dann implementieren müssen, ist sehr e<strong>in</strong>fach:<br />

1 // s i m p l e d i s p l a y a b l e . h − a simple a b s t r a c t base f o r a<br />

2 // d i s p l a y a b l e o b j e c t<br />

3<br />

4 #ifndef s i m p l e d i s p l a y a b l e h<br />

5 #def<strong>in</strong>e s i m p l e d i s p l a y a b l e h<br />

6<br />

7 #<strong>in</strong>clude ” simple output context . h”<br />

8 class SimpleOutputHandl<strong>in</strong>g ;<br />

9<br />

10 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−<br />

11 /∗ The abstract base c l a s s f o r t e x t u a l l y d i s p l a y a b l e o b j e c t s ,<br />

12 ∗ as i t i s used by SimpleOutputHandl<strong>in</strong>g<br />

13 ∗/<br />

14<br />

15 class Displayable<br />

16 {<br />

17 public :<br />

18<br />

19 /∗ Destructor<br />

20 ∗ Just to make sure that a v i r t u a l d e s t r u c t o r e x i s t s<br />

21 ∗/<br />

22 virtual ˜ Displayable ( ) { }<br />

23<br />

24 /∗ This c a l l b a c k i s used to n o t i f y a d i s p l a y a b l e that i t<br />

25 ∗ has j u s t been r e g i s t e r e d with an output handler . I t can<br />

26 ∗ perform a l l necessary operations <strong>in</strong> t h i s method to<br />

27 ∗ be prepared to generate output .<br />

28 ∗ @param handler The handler that t h i s d i s p l a y a b l e was<br />

29 ∗ r e g i s t e r e d with .<br />

30 ∗/<br />

31 virtual void d i s p l a y a b l e R e g i s t e r e d (<br />

32 SimpleOutputHandl<strong>in</strong>g &handler ) = 0 ;<br />

33<br />

34 /∗ The c a l l b a c k that i s c a l l e d by SimpleOutputHandl<strong>in</strong>g when<br />

35 ∗ outputt<strong>in</strong>g the d i s p l a y a b l e s i s t r i g g e r e d .<br />

36 ∗ @param context The output context to write to .<br />

37 ∗/<br />

38 virtual void writeDisplayRep ( OutputContext &context ) = 0 ;<br />

39<br />

40 } ;<br />

41<br />

42 #endif // s i m p l e d i s p l a y a b l e h

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!