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.

59 ∗ are not known yet )<br />

60 ∗/<br />

61 static const u<strong>in</strong>t32 HIGHEST ARG TYPE = UINT32 ARG;<br />

62<br />

63 private :<br />

64<br />

65 /∗ Copy construction i s not allowed<br />

66 ∗/<br />

67 Commandl<strong>in</strong>eHandl<strong>in</strong>g ( const Commandl<strong>in</strong>eHandl<strong>in</strong>g & s r c ) :<br />

68 types ( 0 , DontDelete : : getInstance ( ) ) ,<br />

69 handlers ( 0 , DontDelete : : getInstance ( ) ) { }<br />

70<br />

71 public :<br />

72<br />

10.2 Das DDD 275<br />

73 /∗ Standard Constructor<br />

74 ∗ @param max num args S p e c i f i e s the maximum number o f arguments<br />

75 ∗ that may be declared f o r t h i s i n s t a n c e o f the handler<br />

76 ∗/<br />

77 explicit Commandl<strong>in</strong>eHandl<strong>in</strong>g ( <strong>in</strong>t32 max num args ) :<br />

78 types ( max num args , U<strong>in</strong>t32Deletor : : getInstance ( ) ) ,<br />

79 handlers ( max num args , DontDelete : : getInstance ( ) ) ,<br />

80 max num args ( max num args ) {}<br />

81<br />

82 /∗ Destructor<br />

83 ∗ 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 />

84 ∗/<br />

85 virtual ˜ Commandl<strong>in</strong>eHandl<strong>in</strong>g ( ) { }<br />

86<br />

87 /∗ This method i s used to d e c l a r e an argument that has to be<br />

88 ∗ handled .<br />

89 ∗ @param <strong>in</strong>dex The <strong>in</strong>dex of the argument to be handled . I f<br />

90 ∗ the <strong>in</strong>dex i s out of range i t i s ignored ( j u s t because<br />

91 ∗ exceptions are not known yet ) .<br />

92 ∗ @param type The type of the argument . Valid types are the<br />

93 ∗ ones that e x i s t as constants above .<br />

94 ∗ @param handler The handler that has to be c a l l e d f o r the<br />

95 ∗ declared argument . I f t h i s handler i s a 0 po<strong>in</strong>ter<br />

96 ∗ then the operation i s ignored ( j u s t because<br />

97 ∗ exceptions are not known yet ) .<br />

98 ∗/<br />

99 virtual void declareArgument ( u<strong>in</strong>t32 <strong>in</strong>dex , u<strong>in</strong>t32 type ,<br />

100 ArgumentHandler ∗ handler ) ;<br />

101<br />

102 /∗ This method i s c a l l e d a f t e r the i n i t i a l i z a t i o n phase to<br />

103 ∗ t r i g g e r handl<strong>in</strong>g of the commandl<strong>in</strong>e . I t takes the arguments<br />

104 ∗ one by one , converts them to the types declared f o r them<br />

105 ∗ and c a l l s the appropriate handlers .<br />

106 ∗ @param num args The number of arguments passed on<br />

107 ∗ @param args The arguments as obta<strong>in</strong>ed from the commandl<strong>in</strong>e<br />

108 ∗/<br />

109 virtual void handleCommandl<strong>in</strong>e ( <strong>in</strong>t32 num args ,<br />

110 char ∗ args [ ] ) ;<br />

111 } ;<br />

112<br />

113<br />

114 #endif // simple commandl<strong>in</strong>e handl<strong>in</strong>g h<br />

10.2.9 SimpleOutputHandl<strong>in</strong>g<br />

Bevor wir die Klasse SimpleOutputHandl<strong>in</strong>g näher betrachten, möchte ich<br />

noch anmerken, dass diese deshalb <strong>in</strong> der hier angeführten Form geschrieben<br />

wurde, da der Umgang mit allgeme<strong>in</strong>en Output Streams derzeit noch nicht

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

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!