]> AND Private Git Repository - these_kahina.git/blob - upmethodology-spec.sty
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
je viens de rajouter les fichiers qui manquent
[these_kahina.git] / upmethodology-spec.sty
1 % Specification Description for Unified Process Methodology
2 %
3 % Copyright (c) 2006-2007 Stephane GALLAND <galland@arakhne.org>
4
5 % This program is free library; you can redistribute it and/or modify
6 % it under the terms of the GNU Lesser General Public License as
7 % published by the Free Software Foundation; either version 3 of the
8 % License, or any later version.
9 %
10 % This library is distributed in the hope that it will be useful, but
11 % WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 % Lesser General Public License for more details.
14 %
15 % You should have received a copy of the GNU Lesser General Public
16 % License along with this library; see the file COPYING.  If not,
17 % write to the Free Software Foundation, Inc., 59 Temple Place - Suite
18 % 330, Boston, MA 02111-1307, USA.
19 %
20 % Creation date: 2006-04-27
21 % Modifications:
22 %   2009-10-30   Clean code.
23 %   2007-03-19   Add localization.
24 %
25
26 \global\edef\upm@package@spec@ver{2009/10/30}
27
28 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
29 \ProvidesPackage{upmethodology-spec}[\upm@package@spec@ver]
30
31 \RequirePackage{upmethodology-p-common}
32
33 \RequirePackage[normalem]{ulem}
34
35 \RequirePackage{upmethodology-fmt}
36 \RequirePackage{upmethodology-code}
37
38 %------------------------------------
39 % LOCALIZATION
40 %------------------------------------
41 \def\upm@spec@lang@english {
42   \gdef\upm@lang@@{\message{**** upmethodology-spec is using English language ****}}%
43   \gdef\upm@spec@lang@description{Description}
44   \gdef\upm@spec@lang@returned@values{returned value(s)}
45   \gdef\upm@spec@lang@except@for{Except for}
46   \gdef\upm@spec@lang@modifier@public{{\tiny+}}
47   \gdef\upm@spec@lang@modifier@protected{{\tiny\#}}
48   \gdef\upm@spec@lang@modifier@private{{\tiny--}}
49   \gdef\upm@spec@lang@modifier@static##1{{\uline{##1}}}
50   \gdef\upm@spec@lang@modifier@const{query}
51   \gdef\upm@spec@lang@modifier@final{isLeaf}
52   \gdef\upm@spec@lang@modifier@abstract{abstract}
53   \gdef\upm@spec@lang@modifier@root{isRoot}
54   \gdef\upm@spec@lang@modifier@inout{\ensuremath{\leftrightarrow}}
55   \gdef\upm@spec@lang@modifier@in{\ensuremath{\rightarrow}}
56   \gdef\upm@spec@lang@modifier@out{\ensuremath{\leftarrow}}
57 }
58 \def\upm@spec@lang@french {
59   \gdef\upm@lang@@{\message{**** upmethodology-spec is using French language ****}}%
60   \gdef\upm@spec@lang@description{Description}
61   \gdef\upm@spec@lang@returned@values{valeur(s) retourn\'ee(s)}
62   \gdef\upm@spec@lang@except@for{Except\'e pour}
63   \gdef\upm@spec@lang@modifier@public{{\tiny+}}
64   \gdef\upm@spec@lang@modifier@protected{{\tiny\#}}
65   \gdef\upm@spec@lang@modifier@private{{\tiny--}}
66   \gdef\upm@spec@lang@modifier@static##1{{\uline{##1}}}
67   \gdef\upm@spec@lang@modifier@const{requ\^ete}
68   \gdef\upm@spec@lang@modifier@final{estFeuille}
69   \gdef\upm@spec@lang@modifier@abstract{abstra\^{\i}t}
70   \gdef\upm@spec@lang@modifier@root{estRacine}
71   \gdef\upm@spec@lang@modifier@inout{\ensuremath{\leftrightarrow}}
72   \gdef\upm@spec@lang@modifier@in{\ensuremath{\rightarrow}}
73   \gdef\upm@spec@lang@modifier@out{\ensuremath{\leftarrow}}
74 }
75
76 %----------------------------------------
77 % OPTIONS
78 %----------------------------------------
79 \DeclareOption{french}{%
80   \upm@spec@lang@french
81 }
82 \DeclareOption{francais}{%
83   \upm@spec@lang@french
84 }
85 \DeclareOption{english}{%
86   \upm@spec@lang@english
87 }
88 \ExecuteOptions{english}
89 \ProcessOptions
90 \upm@lang@@
91
92 %------------------------------------
93 % DETAILLED SPECIFICATION
94 %------------------------------------
95
96 \newlength{\upm@spec@detailspec@description@width}
97 \setlength{\upm@spec@detailspec@description@width}{3cm}
98
99 \newsavebox{\upm@spec@detailspec@savebox}
100 \newlength{\upm@spec@detailspec@itrn@width}
101
102 \newcounter{upm@detailspec@return@counter}
103 \newcounter{upm@detailspec@function@counter}
104
105 \newif\ifupm@spec@showdescription
106 \newif\ifupm@spec@showparams
107 \newif\ifupm@spec@showreturns
108 \newif\ifupm@spec@firstparam
109 \newif\ifupm@spec@modifier@has@static
110 \newif\ifupm@spec@modifier@has@const
111 \newif\ifupm@spec@modifier@has@final
112 \newif\ifupm@spec@modifier@has@abstract
113 \newif\ifupm@spec@modifier@has@root
114 \newif\ifupm@spec@modifier@has@public
115 \newif\ifupm@spec@modifier@has@protected
116 \newif\ifupm@spec@modifier@has@private
117 \newif\ifupm@spec@tmp@a
118
119 \newcommand{\upm@spec@head}[2]{#1}
120 \newcommand{\upm@spec@tail}[2]{#2}
121
122 %-----
123 %\upm@spec@func@modifiers{modifiers}
124 \newcommand{\upm@spec@func@modifiers}[1]{%
125         \global\upm@spec@modifier@has@staticfalse%
126         \global\upm@spec@modifier@has@constfalse%
127         \global\upm@spec@modifier@has@finalfalse%
128         \global\upm@spec@modifier@has@abstractfalse%
129         \global\upm@spec@modifier@has@rootfalse%
130         \global\upm@spec@modifier@has@publicfalse%
131         \global\upm@spec@modifier@has@protectedfalse%
132         \global\upm@spec@modifier@has@privatefalse%
133         \upm@spec@func@modifiers@scan{#1}%
134 }
135 \newcommand{\upm@spec@func@modifiers@scan}[1]{%
136         \upm@ifnotempty{#1}{%
137                 \edef\upm@reserved@a{\upm@spec@head #1\@empty\@empty}%
138                 \edef\upm@reserved@b{\upm@spec@tail #1\@empty\@empty}%
139                 \ifthenelse{\equal{\upm@reserved@a}{+}}{%
140                         %public
141                         \global\upm@spec@modifier@has@publictrue%
142                         \global\upm@spec@modifier@has@protectedfalse%
143                         \global\upm@spec@modifier@has@privatefalse%
144                 }{%
145                 \ifthenelse{\equal{\upm@reserved@a}{=}}{%
146                         %protected
147                         \global\upm@spec@modifier@has@publicfalse%
148                         \global\upm@spec@modifier@has@protectedtrue%
149                         \global\upm@spec@modifier@has@privatefalse%
150                 }{%
151                 \ifthenelse{\equal{\upm@reserved@a}{\#}}{%
152                         %protected
153                         \global\upm@spec@modifier@has@publicfalse%
154                         \global\upm@spec@modifier@has@protectedtrue%
155                         \global\upm@spec@modifier@has@privatefalse%
156                 }{%
157                 \ifthenelse{\equal{\upm@reserved@a}{-}}{%
158                         %protected
159                         \global\upm@spec@modifier@has@publicfalse%
160                         \global\upm@spec@modifier@has@protectedfalse%
161                         \global\upm@spec@modifier@has@privatetrue%
162                 }{%
163                 \ifthenelse{\equal{\upm@reserved@a}{s}}{%
164                         %static
165                         \global\upm@spec@modifier@has@statictrue%
166                 }{%
167                 \ifthenelse{\equal{\upm@reserved@a}{c}}{%
168                         %query / const
169                         \global\upm@spec@modifier@has@consttrue%
170                 }{%
171                 \ifthenelse{\equal{\upm@reserved@a}{l}}{%
172                         %isLeaf
173                         \global\upm@spec@modifier@has@finaltrue%
174                 }{%
175                 \ifthenelse{\equal{\upm@reserved@a}{a}}{%
176                         %abstract
177                         \global\upm@spec@modifier@has@abstracttrue%
178                 }{%
179                 \ifthenelse{\equal{\upm@reserved@a}{r}}{%
180                         %isRoot
181                         \global\upm@spec@modifier@has@roottrue%
182                 }{}}}}}}}}}%
183                 \expandafter\upm@spec@func@modifiers@scan{\upm@reserved@b}%
184         }%
185 }
186
187 %-----
188 %\upm@spec@param@modifiers{modifiers}
189 \newcommand{\upm@spec@param@modifiers}[1]{%
190         \upm@ifnotempty{#1}{%
191                 \ifthenelse{\equal{#1}{out}}{%
192                         %out
193                         \upm@spec@lang@modifier@out%
194                 }{
195                 \ifthenelse{\equal{#1}{inout}}{%
196                         %inout
197                         \upm@spec@lang@modifier@inout%
198                 }{
199                         %in
200                         \upm@spec@lang@modifier@in%
201                 }}
202         }%
203 }
204
205 %-----
206 \def\upm@spec@trim#1{#1}
207 \newcommand{\upm@spec@splitparams}[1]{%
208         \upm@ifnotempty{#1}{%
209                 \upm@spec@firstparamtrue
210                 \@for\reserved@a:=#1\do{%
211                         \ifupm@spec@firstparam\upm@spec@firstparamfalse\else, \fi%
212                         \mbox{\upm@spec@trim{\reserved@a}}%
213                 }%
214                 \upm@spec@trim
215         }%
216 }
217
218 %-----
219 %\begin{upm@spec@detailspec}[width]{title}...\end{detailspec}
220 \newenvironment{upm@spec@detailspec}[2][\linewidth]{%
221
222         \setcounter{upm@detailspec@return@counter}{0}
223         \setcounter{upm@detailspec@function@counter}{0}
224
225         \gdef\upm@spec@detailspec@width{#1}
226         \gdef\upm@spec@detailspec@title{#2}
227         \gdef\upm@spec@functions{}
228         \gdef\upm@spec@parameters{}
229         \gdef\upm@spec@global@return{}
230         \gdef\upm@spec@local@return{}
231
232         %-----
233         %\speccons[modifiers]{name}{prototype}
234         \newcommand{\speccons}[3][]{\specfunc[##1]{}{##2}{##3}}
235
236         %-----
237         %\specget[modifiers]{return_type}{name}
238         \newcommand{\specget}[3][]{\specfunc[c##1]{##2}{##3}{}}
239
240         %-----
241         %\specset[modifiers]{name}{prototype}
242         \newcommand{\specset}[3][]{\specfunc[##1]{\jvoid}{##2}{##3}{}}
243
244         %-----
245         %\specfunc[modifiers]{return_type}{name}{prototype}
246         \newcommand{\specfunc}[4][+]{%
247                 \addtocounter{upm@detailspec@function@counter}{1}%
248                 \protected@xdef\upm@spec@reserved@a{\protect\csname upm@detailspec@return@ptr@\theupm@detailspec@function@counter\endcsname}%
249                 \gdef\upm@spec@reserved@b{}
250                 \upm@ifnotempty{##2}{\gdef\upm@spec@reserved@b{\string:\ }}
251
252                 \gdef\upm@spec@reserved@c{}%
253                 \upm@spec@func@modifiers{##1}%
254                 \ifupm@spec@modifier@has@private\gdef\upm@spec@reserved@c{\upm@spec@lang@modifier@private}%
255                 \else\ifupm@spec@modifier@has@protected\gdef\upm@spec@reserved@c{\upm@spec@lang@modifier@protected}%
256                 \else\gdef\upm@spec@reserved@c{\upm@spec@lang@modifier@public}\fi\fi%
257
258                 \gdef\upm@spec@reserved@d{##3}%
259                 \ifupm@spec@modifier@has@static%
260                         \protected@xdef\upm@spec@reserved@d{\protect\upm@spec@lang@modifier@static{\upm@spec@reserved@d}}%
261                 \fi%
262
263                 \gdef\upm@spec@reserved@e{}%
264                 \upm@spec@tmp@afalse%
265                 \ifupm@spec@modifier@has@const\upm@spec@tmp@atrue\fi%
266                 \ifupm@spec@modifier@has@final\upm@spec@tmp@atrue\fi%
267                 \ifupm@spec@modifier@has@abstract\upm@spec@tmp@atrue\fi%
268                 \ifupm@spec@modifier@has@root\upm@spec@tmp@atrue\fi%
269                 \ifupm@spec@tmp@a%
270                         \ifupm@spec@modifier@has@const%
271                                 \gdef\upm@spec@reserved@e{\upm@spec@lang@modifier@const}%
272                         \fi
273                         \ifupm@spec@modifier@has@final%
274                                 \upm@ifnotempty{\upm@spec@reserved@e}{%
275                                 \xdef\upm@spec@reserved@e{\upm@spec@reserved@e,}}%
276                                 \protected@xdef\upm@spec@reserved@e{\upm@spec@reserved@e\protect\upm@spec@lang@modifier@final}%
277                         \fi
278                         \ifupm@spec@modifier@has@abstract%
279                                 \upm@ifnotempty{\upm@spec@reserved@e}{%
280                                 \xdef\upm@spec@reserved@e{\upm@spec@reserved@e,}}%
281                                 \protected@xdef\upm@spec@reserved@e{\upm@spec@reserved@e\protect\upm@spec@lang@modifier@abstract}%
282                         \fi
283                         \ifupm@spec@modifier@has@root%
284                                 \upm@ifnotempty{\upm@spec@reserved@e}{%
285                                 \xdef\upm@spec@reserved@e{\upm@spec@reserved@e,}}%
286                                 \protected@xdef\upm@spec@reserved@e{\upm@spec@reserved@e\protect\upm@spec@lang@modifier@root}%
287                         \fi
288                         \protected@xdef\upm@spec@reserved@e{ \protect\{\upm@spec@reserved@e\protect\}}
289                 \fi%
290
291                 \protected@xdef\upm@spec@functions{\upm@spec@functions {\upm@spec@reserved@c}\protect&%
292                         {\upm@spec@reserved@d}\protect&%
293                         \string(\protect&\protect\upm@spec@splitparams{##4}\string) {\upm@spec@reserved@b##2{\upm@spec@reserved@a}{\upm@spec@reserved@e}}\protect\\}%
294
295                 \global\let\upm@spec@reserved@a\relax
296                 \global\let\upm@spec@reserved@b\relax
297                 \global\let\upm@spec@reserved@c\relax
298                 \global\let\upm@spec@reserved@d\relax
299                 \global\let\upm@spec@reserved@e\relax
300                 \expandafter\gdef\csname upm@detailspec@return@ptr@\theupm@detailspec@function@counter\endcsname{}
301         }
302
303         %-----
304         %\specreturn{description}
305         \newcommand{\specreturn}[1]{%
306                 \addtocounter{upm@detailspec@return@counter}{1}%
307                 \expandafter\protected@xdef\csname upm@detailspec@return@ptr@\theupm@detailspec@function@counter\endcsname{%
308                         {\protect\tiny\protect\ensuremath{_{\protect\string[\theupm@detailspec@return@counter\protect\string]}}}%
309                 }%
310                 \protected@xdef\upm@spec@local@return{\upm@spec@local@return {\protect\tiny\protect\string[\theupm@detailspec@return@counter\protect\string]} \protect& ##1 \protect\\}%
311         }
312
313         %-----
314         %\specglobalreturn{description}
315         \newcommand{\specglobalreturn}[1]{\gdef\upm@spec@global@return{##1}}
316
317         %-----
318         %\specparam[in|inout|out]{name}{description}
319         \newcommand{\specparam}[3][in]{%
320                 \protected@xdef\upm@spec@parameters{\upm@spec@parameters \protect\upm@spec@param@modifiers{##1} \protect& {##2:} \protect& {##3} \protect\\}
321         }
322
323         %-----
324         %\specendhline
325         \newcommand{\specendhline}{\gdef\upm@detailspec@end@hline{\hline}}
326
327         %-----
328         %\specstarthline
329         \newcommand{\specstarthline}{\gdef\upm@detailspec@start@hline{\hline}}
330
331         \setlength{\upm@spec@detailspec@itrn@width}{#1}
332         \addtolength{\upm@spec@detailspec@itrn@width}{-\the\upm@spec@detailspec@description@width}
333         \addtolength{\upm@spec@detailspec@itrn@width}{-2\tabcolsep}
334
335         \begin{lrbox}{\upm@spec@detailspec@savebox}
336         \begin{minipage}[t]{\upm@spec@detailspec@itrn@width}%
337 }{%
338         \end{minipage}
339         \end{lrbox}%
340
341         \gdef\upm@detailspec@separator{}
342         \upm@spec@showreturnsfalse%
343
344         \ifthenelse{\equal{\upm@spec@global@return}{\@empty}}{%
345                 \gdef\upm@detailspec@return@section{}
346                 \upm@ifnotempty{\upm@spec@local@return}{
347                         \gdef\upm@detailspec@separator{ & & & \\}
348                         \protected@xdef\upm@detailspec@return@section{\upm@spec@local@return}%
349                         \upm@spec@showreturnstrue%
350                 }%
351         }{%
352                 \upm@ifnotempty{\upm@spec@local@return}{%
353                 \gdef\upm@detailspec@separator{ & & & \\}
354                 \gdef\upm@spec@reserved@a{ \upm@spec@lang@except@for:\protect\upm@spec@local@return}}%
355                 \protected@xdef\upm@detailspec@return@section{%
356                         \upm@spec@global@return\upm@spec@reserved@a%
357                 }%
358                 \upm@spec@showreturnstrue%
359         }
360
361         \ifthenelse{\equal{\upm@spec@detailspec@title}{\@empty}}{
362                 \gdef\upm@spec@reserved@c{}
363         }{
364                 \gdef\upm@spec@reserved@c{\hline%
365                         \multicolumn{4}{>{\columncolor{backtableheader}}l}{\color{fronttableheader}{\large\textsc{\upm@spec@detailspec@title}}} \\%
366                 }
367                 \gdef\upm@detailspec@start@hline{\hline}%
368                 \upm@spec@showdescriptiontrue%
369         }
370
371         \upm@spec@showparamsfalse%
372
373         \upm@ifnotempty{\upm@spec@parameters}{%
374                 \ifupm@spec@showdescription%
375                 \gdef\upm@detailspec@separator{ & & & \\}%
376                 \fi%
377                 \upm@ifnotempty{\upm@spec@functions}{%
378                 \gdef\upm@detailspec@separator{ & & & \\}%
379                 }%
380                 \upm@spec@showparamstrue%
381         }%
382
383         \vspace{.5cm}\noindent\begin{tabularx}{\the\upm@spec@detailspec@width}{|clr@{}>{\raggedright\arraybackslash}X|}
384                 \upm@spec@reserved@c%
385                 \upm@detailspec@start@hline%
386                 \ifupm@spec@showdescription
387                 \multicolumn{4}{|X|}{%
388                         \begin{tabularx}{\linewidth}{@{}lX@{}}%
389                         \upm@spec@lang@description: & \usebox{\upm@spec@detailspec@savebox} \\%
390                         \end{tabularx}%
391                 } \\%
392                 \hline%
393                 \fi
394                 \upm@spec@functions%
395                 \upm@detailspec@separator%
396                 \ifupm@spec@showparams%
397                 \multicolumn{4}{|X|}{%
398                         \begin{tabularx}{\linewidth}{@{}l@{}lX@{}}%
399                         \upm@spec@parameters%
400                         \end{tabularx}%
401                 } \\%
402                 \fi%
403                 \ifupm@spec@showreturns%
404                 \multicolumn{4}{|X|}{%
405                         \textit{\upm@spec@lang@returned@values}: \newline%
406                         \begin{tabularx}{\linewidth}{@{}lX@{}}%
407                         \upm@detailspec@return@section%
408                         \end{tabularx}%
409                 } \\%
410                 \fi%
411                 \upm@detailspec@end@hline%
412         \end{tabularx}\vspace{.5cm}%
413
414         \global\let\@arraycr\upm@arraycr
415
416         \global\let\upm@spec@detailspec@width\relax%
417         \global\let\upm@spec@detailspec@title\relax%
418         \global\let\upm@spec@functions\relax%
419         \global\let\upm@spec@parameters\relax%
420         \global\let\upm@spec@global@return\relax%
421         \global\let\upm@spec@local@return\relax%
422         \global\let\upm@detailspec@return@section\relax%
423         \global\let\upm@spec@reserved@a\relax%
424         \global\let\upm@spec@reserved@b\relax%
425         \global\let\upm@spec@reserved@c\relax%
426         \global\let\upm@detailspec@separator\relax%
427         \global\let\upm@detailspec@start@hline\relax%
428         \global\let\upm@detailspec@end@hline\relax%
429 }
430
431 %-----
432 %\begin{detailspec}}[width]{title}...\end{detailspec}....
433 \newenvironment{detailspec}[2][\linewidth]
434 {%
435         \upm@spec@showdescriptiontrue%
436         \gdef\upm@detailspec@start@hline{\hline}%
437         \gdef\upm@detailspec@end@hline{\hline}%
438         \begin{upm@spec@detailspec}[#1]{#2}%
439 }
440 {%
441         \end{upm@spec@detailspec}%
442 }
443
444 %-----
445 %\begin{detailspec}}[width]{title}...\end{detailspec}....
446 \newenvironment{detailspec*}[2][\linewidth]
447 {%
448         \upm@spec@showdescriptionfalse%
449         \gdef\upm@detailspec@start@hline{}%
450         \gdef\upm@detailspec@end@hline{}%
451         \begin{upm@spec@detailspec}[#1]{#2}%
452 }
453 {%
454         \end{upm@spec@detailspec}%
455 }
456
457 \endinput