Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Common/KWCommon/vtkKWArguments.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWArguments.h,v $
00004 
00005   Copyright (c) Kitware, Inc.
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00023 #ifndef __vtkKWArguments_h
00024 #define __vtkKWArguments_h
00025 
00026 #include "vtkObject.h"
00027 
00028 class vtkKWArgumentsInternal;
00029 
00030 class VTK_EXPORT vtkKWArguments : public vtkObject
00031 {
00032 public:
00033   static vtkKWArguments* New();
00034   vtkTypeRevisionMacro(vtkKWArguments,vtkObject);
00035   void PrintSelf(ostream& os, vtkIndent indent);
00036 
00037 
00038   //BTX
00039 
00041 
00042   enum ArgumentTypeEnum { 
00043     NO_ARGUMENT,    // The option takes no argument             --foo
00044     CONCAT_ARGUMENT,// The option takes argument after no space --foobar
00045     SPACE_ARGUMENT, // The option takes argument after space    --foo bar
00046     EQUAL_ARGUMENT  // The option takes argument after equal    --foo=bar
00047   };
00049 
00050   enum VariableTypeEnum {
00051     NO_VARIABLE_TYPE = 0, // The variable is not specified
00052     INT_TYPE,             // The variable is integer (int)
00053     DOUBLE_TYPE,          // The variable is float (double)
00054     STRING_TYPE           // The variable is string (char*)
00055   };
00056 
00057   // These are prototypes for callbacks.
00058   typedef int(*CallbackType)(const char* argument, const char* value, 
00059     void* call_data);
00060   typedef int(*ErrorCallbackType)(const char* argument, void* client_data);
00061 
00062   struct CallbackStructure
00063     {
00064     const char* Argument;
00065     int ArgumentType;
00066     CallbackType Callback;
00067     void* CallData;
00068     void* Variable;
00069     int VariableType;
00070     const char* Help;
00071     };
00072   
00075   void Initialize(int argc, char* argv[]);
00076 
00077   //ETX
00078   
00080 
00083   void Initialize();
00084   void AddArgument(const char* arg);
00086 
00088   int Parse();
00089 
00091 
00095   void AddCallback(const char* argument, ArgumentTypeEnum type, CallbackType callback, 
00096                    void* call_data, const char* help);
00097   void AddCallback(const char* argument, ArgumentTypeEnum type, const char* help)
00098     {
00099     this->AddCallback(argument, type, 0, 0, help);
00100     }
00102 
00104 
00106   void AddHandler(const char* argument, ArgumentTypeEnum type, VariableTypeEnum vtype, void* variable, const char* help);
00107   void AddHandler(const char* argument, ArgumentTypeEnum type, int* variable, const char* help);
00108   void AddHandler(const char* argument, ArgumentTypeEnum type, double* variable, const char* help);
00109   void AddHandler(const char* argument, ArgumentTypeEnum type, char** variable, const char* help);
00110   void AddBooleanHandler(const char* argument, int* variable, const char* help);
00112 
00115   void AddCallbacks(CallbackStructure* callbacks);
00116 
00118 
00119   void SetClientData(void* client_data);
00120   void SetUnknownArgumentCallback(ErrorCallbackType callback);
00122 
00125   void GetRemainingArguments(int* argc, char*** argv);
00126 
00128 
00130   vtkGetStringMacro(Help);
00131   const char* GetHelp(const char* arg);
00133 
00135 
00136   vtkSetMacro(LineLength, unsigned int);
00137   vtkGetMacro(LineLength, unsigned int);
00139 
00141 
00143   int IsSpecified(const char* arg);
00144   const char* GetValue(const char* arg);
00146 
00147 protected:
00148   vtkKWArguments();
00149   ~vtkKWArguments();
00150 
00151   vtkSetStringMacro(Help);
00152   void GenerateHelp();
00153 
00154   //BTX
00155   typedef vtkKWArgumentsInternal Internal;
00156   //ETX
00157   Internal* Internals;
00158   char* Help;
00159 
00160   unsigned int LineLength;
00161 
00162 private:
00163   vtkKWArguments(const vtkKWArguments&); // Not implemented
00164   void operator=(const vtkKWArguments&); // Not implemented
00165 };
00166 
00167 
00168 #endif
00169 
00170 
00171 
00172 
00173 

Generated on Tue May 30 12:31:37 2006 for ParaView by doxygen 1.3.5