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.

221 return ( d e l e t o r ) ;<br />

222 }<br />

223<br />

224 /∗ This i s the c a l l b a c k implementation<br />

225 ∗ @param obj The po<strong>in</strong>ter to the o b j e c t to be deleted<br />

226 ∗/<br />

227 virtual void deleteObject ( void ∗ obj )<br />

228 {<br />

229 delete static cast(obj ) ;<br />

230 }<br />

231 } ;<br />

232<br />

233<br />

234 #endif // c o n c r e t e o b j e c t d e l e t o r s h<br />

10.2.6 ArgumentHandler<br />

10.2 Das DDD 271<br />

Neben dem Vector ist auch die Basisklasse ArgumentHandler und alles, was<br />

sich rund um diese Klasse herum abspielt, e<strong>in</strong> relativ abgeschlossenes Thema<br />

für sich. Also wenden wir uns ihr gleich e<strong>in</strong>mal zu. Der ArgumentHandler ist<br />

ganz e<strong>in</strong>fach nur e<strong>in</strong>e abstrakte Basis, über die das Commandl<strong>in</strong>eHandl<strong>in</strong>g die<br />

e<strong>in</strong>zelnen Parameter zur Auswertung weitergeben kann. Dementsprechend<br />

e<strong>in</strong>fach ist auch dieses Interface:<br />

1 // simple argument handler . h − i n t e r f a c e f o r an argument handler<br />

2<br />

3 #ifndef simple argument handler h<br />

4 #def<strong>in</strong>e simple argument handler h<br />

5<br />

6 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−<br />

7 /∗ An abstract base c l a s s of a very simple argument handler .<br />

8 ∗ A concrete implementation of a handler has to be derived from<br />

9 ∗ t h i s base and obta<strong>in</strong>s n o t i f i c a t i o n s f o r every s i n g l e argument .<br />

10 ∗/<br />

11<br />

12 class ArgumentHandler<br />

13 {<br />

14 public :<br />

15<br />

16 /∗ Destructor<br />

17 ∗ The d e s t r u c t o r i s j u s t implemented to make sure that a v i r t u a l<br />

18 ∗ d e s t r u c t o r e x i s t s<br />

19 ∗/<br />

20 virtual ˜ ArgumentHandler ( ) { }<br />

21<br />

22 /∗ This method i s a c a l l b a c k used to n o t i f y the handler o f an<br />

23 ∗ argument that was obta<strong>in</strong>ed .<br />

24 ∗ @param <strong>in</strong>dex The <strong>in</strong>dex of the argument . All arguments are<br />

25 ∗ numbered <strong>in</strong> a consecutive order s t a r t i n g at 0 .<br />

26 ∗ @param arg A po<strong>in</strong>ter to the argument that was obta<strong>in</strong>ed . This<br />

27 ∗ parameter i s declared as a void ∗ , because argument<br />

28 ∗ n o t i f i c a t i o n s are performed <strong>in</strong> a typed manner .<br />

29 ∗ Depend<strong>in</strong>g on the expected argument type the t r i g g e r<br />

30 ∗ c l a s s of a n o t i f i c a t i o n has to perform the accord<strong>in</strong>g<br />

31 ∗ conversion . I f e . g . an i n t argument i s expected<br />

32 ∗ the n o t i f i c a t i o n i s done with an i n t ∗ .<br />

33 ∗/<br />

34 virtual void argumentNotification ( u<strong>in</strong>t32 <strong>in</strong>dex , const void ∗ arg ) = 0 ;<br />

35 } ;

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

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!