1 % Specification Description for Unified Process Methodology
3 % Copyright (c) 2006-2007 Stephane GALLAND <galland@arakhne.org>
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.
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.
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.
20 % Creation date: 2006-04-27
22 % 2009-10-30 Clean code.
23 % 2007-03-19 Add localization.
26 \global\edef\upm@package@spec@ver{2009/10/30}
28 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
29 \ProvidesPackage{upmethodology-spec}[\upm@package@spec@ver]
31 \RequirePackage{upmethodology-p-common}
33 \RequirePackage[normalem]{ulem}
35 \RequirePackage{upmethodology-fmt}
36 \RequirePackage{upmethodology-code}
38 %------------------------------------
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}}
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}}
76 %----------------------------------------
78 %----------------------------------------
79 \DeclareOption{french}{%
82 \DeclareOption{francais}{%
85 \DeclareOption{english}{%
86 \upm@spec@lang@english
88 \ExecuteOptions{english}
92 %------------------------------------
93 % DETAILLED SPECIFICATION
94 %------------------------------------
96 \newlength{\upm@spec@detailspec@description@width}
97 \setlength{\upm@spec@detailspec@description@width}{3cm}
99 \newsavebox{\upm@spec@detailspec@savebox}
100 \newlength{\upm@spec@detailspec@itrn@width}
102 \newcounter{upm@detailspec@return@counter}
103 \newcounter{upm@detailspec@function@counter}
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
119 \newcommand{\upm@spec@head}[2]{#1}
120 \newcommand{\upm@spec@tail}[2]{#2}
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}%
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}{+}}{%
141 \global\upm@spec@modifier@has@publictrue%
142 \global\upm@spec@modifier@has@protectedfalse%
143 \global\upm@spec@modifier@has@privatefalse%
145 \ifthenelse{\equal{\upm@reserved@a}{=}}{%
147 \global\upm@spec@modifier@has@publicfalse%
148 \global\upm@spec@modifier@has@protectedtrue%
149 \global\upm@spec@modifier@has@privatefalse%
151 \ifthenelse{\equal{\upm@reserved@a}{\#}}{%
153 \global\upm@spec@modifier@has@publicfalse%
154 \global\upm@spec@modifier@has@protectedtrue%
155 \global\upm@spec@modifier@has@privatefalse%
157 \ifthenelse{\equal{\upm@reserved@a}{-}}{%
159 \global\upm@spec@modifier@has@publicfalse%
160 \global\upm@spec@modifier@has@protectedfalse%
161 \global\upm@spec@modifier@has@privatetrue%
163 \ifthenelse{\equal{\upm@reserved@a}{s}}{%
165 \global\upm@spec@modifier@has@statictrue%
167 \ifthenelse{\equal{\upm@reserved@a}{c}}{%
169 \global\upm@spec@modifier@has@consttrue%
171 \ifthenelse{\equal{\upm@reserved@a}{l}}{%
173 \global\upm@spec@modifier@has@finaltrue%
175 \ifthenelse{\equal{\upm@reserved@a}{a}}{%
177 \global\upm@spec@modifier@has@abstracttrue%
179 \ifthenelse{\equal{\upm@reserved@a}{r}}{%
181 \global\upm@spec@modifier@has@roottrue%
183 \expandafter\upm@spec@func@modifiers@scan{\upm@reserved@b}%
188 %\upm@spec@param@modifiers{modifiers}
189 \newcommand{\upm@spec@param@modifiers}[1]{%
190 \upm@ifnotempty{#1}{%
191 \ifthenelse{\equal{#1}{out}}{%
193 \upm@spec@lang@modifier@out%
195 \ifthenelse{\equal{#1}{inout}}{%
197 \upm@spec@lang@modifier@inout%
200 \upm@spec@lang@modifier@in%
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}}%
219 %\begin{upm@spec@detailspec}[width]{title}...\end{detailspec}
220 \newenvironment{upm@spec@detailspec}[2][\linewidth]{%
222 \setcounter{upm@detailspec@return@counter}{0}
223 \setcounter{upm@detailspec@function@counter}{0}
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{}
233 %\speccons[modifiers]{name}{prototype}
234 \newcommand{\speccons}[3][]{\specfunc[##1]{}{##2}{##3}}
237 %\specget[modifiers]{return_type}{name}
238 \newcommand{\specget}[3][]{\specfunc[c##1]{##2}{##3}{}}
241 %\specset[modifiers]{name}{prototype}
242 \newcommand{\specset}[3][]{\specfunc[##1]{\jvoid}{##2}{##3}{}}
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:\ }}
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%
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}}%
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%
270 \ifupm@spec@modifier@has@const%
271 \gdef\upm@spec@reserved@e{\upm@spec@lang@modifier@const}%
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}%
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}%
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}%
288 \protected@xdef\upm@spec@reserved@e{ \protect\{\upm@spec@reserved@e\protect\}}
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\\}%
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{}
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]}}}%
310 \protected@xdef\upm@spec@local@return{\upm@spec@local@return {\protect\tiny\protect\string[\theupm@detailspec@return@counter\protect\string]} \protect& ##1 \protect\\}%
314 %\specglobalreturn{description}
315 \newcommand{\specglobalreturn}[1]{\gdef\upm@spec@global@return{##1}}
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\\}
325 \newcommand{\specendhline}{\gdef\upm@detailspec@end@hline{\hline}}
329 \newcommand{\specstarthline}{\gdef\upm@detailspec@start@hline{\hline}}
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}
335 \begin{lrbox}{\upm@spec@detailspec@savebox}
336 \begin{minipage}[t]{\upm@spec@detailspec@itrn@width}%
341 \gdef\upm@detailspec@separator{}
342 \upm@spec@showreturnsfalse%
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%
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%
358 \upm@spec@showreturnstrue%
361 \ifthenelse{\equal{\upm@spec@detailspec@title}{\@empty}}{
362 \gdef\upm@spec@reserved@c{}
364 \gdef\upm@spec@reserved@c{\hline%
365 \multicolumn{4}{>{\columncolor{backtableheader}}l}{\color{fronttableheader}{\large\textsc{\upm@spec@detailspec@title}}} \\%
367 \gdef\upm@detailspec@start@hline{\hline}%
368 \upm@spec@showdescriptiontrue%
371 \upm@spec@showparamsfalse%
373 \upm@ifnotempty{\upm@spec@parameters}{%
374 \ifupm@spec@showdescription%
375 \gdef\upm@detailspec@separator{ & & & \\}%
377 \upm@ifnotempty{\upm@spec@functions}{%
378 \gdef\upm@detailspec@separator{ & & & \\}%
380 \upm@spec@showparamstrue%
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} \\%
395 \upm@detailspec@separator%
396 \ifupm@spec@showparams%
397 \multicolumn{4}{|X|}{%
398 \begin{tabularx}{\linewidth}{@{}l@{}lX@{}}%
399 \upm@spec@parameters%
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%
411 \upm@detailspec@end@hline%
412 \end{tabularx}\vspace{.5cm}%
414 \global\let\@arraycr\upm@arraycr
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%
432 %\begin{detailspec}}[width]{title}...\end{detailspec}....
433 \newenvironment{detailspec}[2][\linewidth]
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}%
441 \end{upm@spec@detailspec}%
445 %\begin{detailspec}}[width]{title}...\end{detailspec}....
446 \newenvironment{detailspec*}[2][\linewidth]
448 \upm@spec@showdescriptionfalse%
449 \gdef\upm@detailspec@start@hline{}%
450 \gdef\upm@detailspec@end@hline{}%
451 \begin{upm@spec@detailspec}[#1]{#2}%
454 \end{upm@spec@detailspec}%