Преглед на файлове

Clean up ctkCmdLineModuleParameter and friends.

Sascha Zelzer преди 12 години
родител
ревизия
0cec71997d

+ 2 - 2
Libs/CommandLineModules/Core/ctkCmdLineModuleDescription.h

@@ -40,8 +40,8 @@ class ctkCmdLineModuleParameter;
  * \ingroup CommandLineModulesCore
  *
  * The parameters can be used for automated GUI generation or execution
- * of the module, and are directly related to the XML schema used to define
- * a command line module.
+ * of the module, and are directly related to the XML description used to
+ * describe the command line module parameters.
  */
 class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleDescription
 {

+ 3 - 47
Libs/CommandLineModules/Core/ctkCmdLineModuleParameter.cpp

@@ -27,7 +27,7 @@ limitations under the License.
 
 //----------------------------------------------------------------------------
 ctkCmdLineModuleParameterPrivate::ctkCmdLineModuleParameterPrivate()
-  : Hidden(false), Constraints(false), Index(-1), Multiple(false), Aggregate("false")
+  : Hidden(false), Constraints(false), Index(-1), Multiple(false)
 {}
 
 //----------------------------------------------------------------------------
@@ -81,13 +81,6 @@ QString ctkCmdLineModuleParameter::tag() const
   return d->Tag;
 }
 
-////----------------------------------------------------------------------------
-//QString ctkCmdLineModuleParameter::cppType() const
-//{
-//  Q_D(const ctkCmdLineModuleParameter);
-//  return d->CPPType;
-//}
-
 //----------------------------------------------------------------------------
 QString ctkCmdLineModuleParameter::type() const
 {
@@ -95,12 +88,6 @@ QString ctkCmdLineModuleParameter::type() const
 }
 
 //----------------------------------------------------------------------------
-QString ctkCmdLineModuleParameter::reference() const
-{
-  return d->Reference;
-}
-
-//----------------------------------------------------------------------------
 bool ctkCmdLineModuleParameter::hidden() const
 {
   return d->Hidden;
@@ -109,9 +96,8 @@ bool ctkCmdLineModuleParameter::hidden() const
 //----------------------------------------------------------------------------
 bool ctkCmdLineModuleParameter::isReturnParameter() const
 {
-  // could check for tag == float, int, float-vector, ...
-  if (d->Channel == "output"
-      && !this->isFlagParameter() && !this->isIndexParameter())
+  if (d->Channel == "output" && this->isIndexParameter() &&
+      this->index() == 1000)
   {
     return true;
   }
@@ -131,19 +117,6 @@ bool ctkCmdLineModuleParameter::isIndexParameter() const
 }
 
 //----------------------------------------------------------------------------
-QString ctkCmdLineModuleParameter::argType() const
-{
-  return d->ArgType;
-}
-
-////----------------------------------------------------------------------------
-//QString ctkCmdLineModuleParameter::stringToType() const
-//{
-//  Q_D(const ctkCmdLineModuleParameter);
-//  return d->StringToType;
-//}
-
-//----------------------------------------------------------------------------
 QString ctkCmdLineModuleParameter::name() const
 {
  return d->Name;
@@ -270,12 +243,6 @@ bool ctkCmdLineModuleParameter::multiple() const
 }
 
 //----------------------------------------------------------------------------
-QString ctkCmdLineModuleParameter::aggregate() const
-{
-  return d->Aggregate;
-}
-
-//----------------------------------------------------------------------------
 QString ctkCmdLineModuleParameter::fileExtensionsAsString() const
 {
   return d->FileExtensionsAsString;
@@ -300,12 +267,6 @@ QStringList ctkCmdLineModuleParameter::elements() const
 }
 
 //----------------------------------------------------------------------------
-//QStringList& ctkCmdLineModuleParameter::elements()
-//{
-//  return d->Elements;
-//}
-
-//----------------------------------------------------------------------------
 QTextStream& operator<<(QTextStream& os, const ctkCmdLineModuleParameter& parameter)
 {
   os << "    Parameter" << '\n';
@@ -314,11 +275,7 @@ QTextStream& operator<<(QTextStream& os, const ctkCmdLineModuleParameter& parame
   os << "      " << "Description: " << parameter.description() << '\n';
   os << "      " << "Label: " << parameter.label() << '\n';
   os << "      " << "Type: " << parameter.type() << '\n';
-  os << "      " << "Reference: " << parameter.reference() << '\n';
   os << "      " << "Hidden: " << (parameter.hidden() ? "true" : "false") << '\n';
-  //os << "      " << "CPPType: " << parameter.cppType() << '\n';
-  os << "      " << "ArgType: " << parameter.argType() << '\n';
-  //os << "      " << "StringToType: " << parameter.stringToType() << '\n';
   os << "      " << "Default: " << parameter.defaultValue() << '\n';
   os << "      " << "Elements: " << parameter.elements().join(", ") << '\n';
   os << "      " << "Constraints: " << (parameter.constraints() ? "true" : "false") << '\n';
@@ -334,7 +291,6 @@ QTextStream& operator<<(QTextStream& os, const ctkCmdLineModuleParameter& parame
   os << "      " << "Channel: " << parameter.channel() << '\n';
   os << "      " << "Index: " << parameter.index() << '\n';
   os << "      " << "Multiple: " << (parameter.multiple() ? "true" : "false") << '\n';
-  os << "      " << "Aggregate: " << parameter.aggregate() << '\n';
   os << "      " << "FileExtensions: " << parameter.fileExtensionsAsString() << '\n';
   os << "      " << "CoordinateSystem: " << parameter.coordinateSystem() << '\n';
   return os;

+ 113 - 17
Libs/CommandLineModules/Core/ctkCmdLineModuleParameter.h

@@ -36,10 +36,10 @@ struct ctkCmdLineModuleParameterPrivate;
  * \ingroup CommandLineModulesCore
  *
  *
- * ctkCmdLineModuleParameter describes a single parameters to a
+ * ctkCmdLineModuleParameter describes a single parameter for a
  * module. Information on the parameter type, name, flag, label,
  * description, channel, index, default, and constraints can be
- * stored.
+ * retrieved.
  */
 class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleParameter
 {
@@ -51,76 +51,172 @@ public:
 
   ctkCmdLineModuleParameter& operator=(const ctkCmdLineModuleParameter& other);
 
+  /**
+   * @return The tag name, e.g. "integer" or "image".
+   */
   QString tag() const;
 
-//  QString cppType() const;
-
+  /**
+   * @return The type of the parameter, e.g. "scalar" or "vector" for image parameters.
+   */
   QString type() const;
 
-  QString reference() const;
-
+  /**
+   * @return <code>true</code> if the parameter is declared hidden, <code>false</code>
+   *         otherwise.
+   */
   bool hidden() const;
 
-  // Simple return types are parameters on output channel with no
-  // flags and without a specified index
+  /**
+   * Simple return types are parameters on the output channel with no
+   * flags and with a dummy index of 1000.
+   *
+   * @return <code>true</code> if the parameter is a simple return type,
+   *         <code>false</code> otherwise.
+   */
   bool isReturnParameter() const;
 
-  // Has a flag or a long flag?
+  /**
+   * @return <code>true</code> if the parameter has a flag (long or short),
+   *         <code>false</code> otherwise.
+   */
   bool isFlagParameter() const;
 
-  // Is an index type?
+  /**
+   * @return <code>true</code> if the parameter has an index, <code>false</code> otherwise.
+   */
   bool isIndexParameter() const;
 
-  QString argType() const;
-
-  //void setStringToType(const QString& stringToType);
-  //QString stringToType() const;
-
+  /**
+   * @return The parameter name.
+   */
   QString name() const;
 
+  /**
+   * @return The (possibly empty) long flag for this parameter.
+   */
   QString longFlag() const;
 
+  /**
+   * @return A (possibly empty) comma separated string of aliases for the long flag.
+   */
   QString longFlagAliasesAsString() const;
+
+  /**
+   * @return A (possibly empty) list of long flag aliases.
+   */
   QStringList longFlagAliases() const;
 
+  /**
+   * @return A (possibly empty) comma separated string of deprecated long flag aliases.
+   */
   QString deprecatedLongFlagAliasesAsString() const;
+
+  /**
+   * @return A (possibly empty) list of deprectated long flag aliases.
+   */
   QStringList deprecatedLongFlagAliases() const;
 
+  /**
+   * @return The human-readable name of this parameter.
+   */
   QString label() const;
 
+  /**
+   * @return <code>true</code> if this parameter imposes constraints on the set of allowed values.
+   */
   bool constraints() const;
 
+  /**
+   * @return The maximum value constraint.
+   */
   QString maximum() const;
 
+  /**
+   * @return The minimum value constraint.
+   */
   QString minimum() const;
 
+  /**
+   * @return The value step size constraint.
+   */
   QString step() const;
 
+  /**
+   * @return A longer description of this parameter.
+   */
   QString description() const;
 
+  /**
+   * @return The string "input" for input parameters and "output" for output parameters.
+   */
   QString channel() const;
 
+  /**
+   * @return The parameter index or <code>-1</code> if this is not an indexed parameter.
+   * @sa flag()
+   * @sa longFlag()
+   */
   int index() const;
 
+  /**
+   * @return The default value.
+   */
   QString defaultValue() const;
 
+  /**
+   * @return The (possibly empty) flag for this parameter.
+   * @sa index()
+   */
   QString flag() const;
 
+  /**
+   * @return A (possibly empty) comma separated string of flag aliases.
+   */
   QString flagAliasesAsString() const;
+
+  /**
+   * @return A (possibly empty) list of flag aliases.
+   */
   QStringList flagAliases() const;
 
+  /**
+   * @return A (possibly empty) comma separated string of deprecated flag aliases.
+   */
   QString deprecatedFlagAliasesAsString() const;
+
+  /**
+   * @return A (possibly empty) list of deprecated flag aliases.
+   */
   QStringList deprecatedFlagAliases() const;
 
+  /**
+   * @return <code>true</code> if this parameter can appear multiple time in the argument list,
+   *         <code>false</code> otherwise.
+   */
   bool multiple() const;
 
-  QString aggregate() const;
-
+  /**
+   * @return A (possibly empty) comma separated list of file extensions (e.g. "*.nrrd,*.mhd") for
+   *         the "file", "image", or "geometry" parameter tags.
+   */
   QString fileExtensionsAsString() const;
+
+  /**
+   * @return A (possibly empty) list of file extensions.
+   * @sa fileExtensionsAsString()
+   */
   QStringList fileExtensions() const;
 
+  /**
+   * @return The coordinate system (either "lps", "ras", oder "ijk") for the "point" or "region"
+   *         parameter tags.
+   */
   QString coordinateSystem() const;
 
+  /**
+   * @return The list of valid elements for enumeration parameters (e.g. "string-enumeration").
+   */
   QStringList elements() const;
 
 private:

+ 0 - 5
Libs/CommandLineModules/Core/ctkCmdLineModuleParameter_p.h

@@ -39,12 +39,8 @@ struct ctkCmdLineModuleParameterPrivate : public QSharedData
   QString Name;
   QString Description;
   QString Label;
-  //QString CPPType;
   QString Type;
-  QString Reference;
   bool Hidden;
-  QString ArgType;
-  //QString StringToType;
   QString Default;
   QString Flag;
   QString LongFlag;
@@ -55,7 +51,6 @@ struct ctkCmdLineModuleParameterPrivate : public QSharedData
   QString Channel;
   int Index;
   int Multiple;
-  QString Aggregate;
   QString FileExtensionsAsString;
   QStringList FileExtensions;
   QString CoordinateSystem;