iRoCS Toolbox  1.1.0
HelpExtractor.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title:
26 ** $RCSfile$
27 ** $Revision: 2825 $$Name$
28 ** $Date: 2009-09-15 17:04:15 +0200 (Tue, 15 Sep 2009) $
29 ** Copyright: GPL $Author: ronneber $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.3 2004/09/13 10:03:00 ronneber
38 ** - documentation update
39 **
40 ** Revision 1.2 2004/09/08 14:28:20 ronneber
41 ** - adapted to new ParamInfo class
42 **
43 ** Revision 1.1 2004/08/26 08:36:58 ronneber
44 ** initital import
45 **
46 **
47 **
48 **************************************************************************/
49 #ifndef HELPEXTRACTOR_HH
50 #define HELPEXTRACTOR_HH
51 
52 #ifdef HAVE_CONFIG_H
53 #include <config.hh>
54 #endif
55 
56 #include <string>
57 #include <map>
58 #include <set>
59 
60 #include "TList.hh"
61 #include "ParamInfo.hh"
62 
63 namespace svt
64 {
65 
66  /*======================================================================*/
77  /*======================================================================*/
78  template<typename LIST>
80  {
81 
82  /*======================================================================*/
90  /*======================================================================*/
91  static void collectParamInfos( std::vector<ParamInfo>& help)
92  {
93  /*-------------------------------------------------------------
94  * Extract help from current item
95  *-------------------------------------------------------------*/
96  LIST::val_t::getParamInfos( help);
97 
98  /*-------------------------------------------------------------
99  * recursive call HelpExtractor::collectParamInfos for next item
100  *-------------------------------------------------------------*/
102  help);
103  }
104 
105  /*======================================================================*/
117  /*======================================================================*/
119  std::string longKey, std::string shortKey)
120  {
121  ParamInfo help( longKey, shortKey);
123  return help;
124  }
125 
126 
127 
128 
129  /*======================================================================*/
137  /*======================================================================*/
138  static void getNamesDescriptions( ParamInfo& help)
139  {
140 
141  /*-------------------------------------------------------------
142  * Extract name and description from current item
143  *-------------------------------------------------------------*/
144  std::string name = LIST::val_t::name();
145  std::string description = LIST::val_t::description();
146  help.addAlternative( name, description);
147 
148  /*-------------------------------------------------------------
149  * recursive call HelpExtractor::getNamesDescriptions
150  * for next item
151  *-------------------------------------------------------------*/
153  getNamesDescriptions( help);
154  }
155  };
156 
157 
158 
159  /*-----------------------------------------------------------------------
160  * partial specialization for TList's end
161  *-----------------------------------------------------------------------*/
162  template<>
164  {
165  static void collectParamInfos( std::vector<ParamInfo>&)
166  {}
167 
169  std::string longKey, std::string shortKey)
170  {
171  return ParamInfo( longKey,shortKey, "xxx", "no algorithms available" );
172  }
173 
175  {}
176 
177 
178  };
179 
180  /*-----------------------------------------------------------------------
181  * partial specialization for TTList items
182  *-----------------------------------------------------------------------*/
183  template<template<typename> class X, typename Y>
184  struct HelpExtractor<svt::TTList<X,Y> >
185  {
186 
187  /*======================================================================*/
195  /*======================================================================*/
196  static void collectParamInfos( std::vector<ParamInfo>& help)
197  {
198  /*-------------------------------------------------------------
199  * Extract help from current item
200  *-------------------------------------------------------------*/
201  svt::TTList<X,Y>::template Traits<int>::val_t::getParamInfos( help);
202 
203  /*-------------------------------------------------------------
204  * recursive call HelpExtractor::collectParamInfos for next item
205  *-------------------------------------------------------------*/
207  help);
208  }
209 
210 
211  /*======================================================================*/
223  /*======================================================================*/
225  std::string longKey, std::string shortKey)
226  {
227  ParamInfo help( longKey, shortKey);
229  return help;
230  }
231 
232 
233  /*======================================================================*/
241  /*======================================================================*/
242  static void getNamesDescriptions( ParamInfo& help)
243  {
244 
245  /*-------------------------------------------------------------
246  * Extract name and description from current item
247  *-------------------------------------------------------------*/
248  std::string name = svt::TTList<X,Y>::template Traits<int>::val_t::name();
249  std::string desc = svt::TTList<X,Y>::template Traits<int>::val_t::description();
250  help.addAlternative( name, desc);
251 
252  /*-------------------------------------------------------------
253  * recursive call HelpExtractor::getNamesDescriptions
254  * for next item
255  *-------------------------------------------------------------*/
257  getNamesDescriptions( help);
258  }
259  };
260 
261 
262 
263 
264 }
265 #endif
static void getNamesDescriptions(ParamInfo &)
static void getNamesDescriptions(ParamInfo &help)
recursive extract name() and description() for TList items
static void collectParamInfos(std::vector< ParamInfo > &help)
recursive getParamInfos() for TList items
static void collectParamInfos(std::vector< ParamInfo > &help)
recursive getParamInfos() for TList items
static ParamInfo createParamInfoFromNamesDescriptions(std::string longKey, std::string shortKey)
recursive creating of ParamInfo - Alternatives from name() and description() methods from all element...
static ParamInfo createParamInfoFromNamesDescriptions(std::string longKey, std::string shortKey)
static void collectParamInfos(std::vector< ParamInfo > &)
void addAlternative(const std::string &value, const std::string &helpText)
Definition: ParamInfo.hh:126
The HelpExtractor class contains methods to extract the ParamInfo&#39;s and name() / Descriptions form al...
The ParamInfo class contains informations about one parameter like key, help text, guiHints etc.
Definition: ParamInfo.hh:82
static void getNamesDescriptions(ParamInfo &help)
recursive extract name() and description() for TList items
static ParamInfo createParamInfoFromNamesDescriptions(std::string longKey, std::string shortKey)
recursive creating of ParamInfo - Alternatives from name() and description() methods from all element...