vtkMRMLCommandLineModuleNode.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __vtkMRMLCommandLineModuleNode_h
00015 #define __vtkMRMLCommandLineModuleNode_h
00016
00018 #include "vtkMRML.h"
00019 #include "vtkMRMLNode.h"
00020 #include "vtkMRMLStorageNode.h"
00021
00023 #include "vtkMatrix4x4.h"
00024 #include "vtkTransform.h"
00025
00027 #include "ModuleDescription.h"
00028
00029 #include "vtkMRMLCLIWin32Header.h"
00030
00031
00032 class ModuleDescriptionMap;
00033
00034
00035 class VTK_MRML_CLI_EXPORT vtkMRMLCommandLineModuleNode : public vtkMRMLNode
00036 {
00037 public:
00038 static vtkMRMLCommandLineModuleNode *New();
00039 vtkTypeMacro(vtkMRMLCommandLineModuleNode,vtkMRMLNode);
00040 void PrintSelf(ostream& os, vtkIndent indent);
00041
00042 virtual vtkMRMLNode* CreateNodeInstance();
00043
00046 virtual void ReadXMLAttributes( const char** atts);
00047
00050 virtual void WriteXML(ostream& of, int indent);
00051
00054 virtual void Copy(vtkMRMLNode *node);
00055
00058 virtual const char* GetNodeTagName()
00059 {return "CommandLineModule";};
00060
00064 const ModuleDescription& GetModuleDescription() const
00065 { return ModuleDescriptionObject; }
00066 ModuleDescription& GetModuleDescription()
00067 { return ModuleDescriptionObject; }
00068 void SetModuleDescription(const ModuleDescription& description);
00069
00070
00071
00072 typedef enum { Idle=0, Scheduled=1, Running=2, Completed=3, CompletedWithErrors=4, Cancelled=5 } StatusType;
00073
00074
00079
00080 void SetStatus(StatusType status, bool modify=true);
00081 StatusType GetStatus();
00082
00083 const char* GetStatusString() {
00084 switch (this->m_Status)
00085 {
00086 case Idle: return "Idle";
00087 case Scheduled: return "Scheduled";
00088 case Running: return "Running";
00089 case Completed: return "Completed";
00090 case CompletedWithErrors: return "CompletedWithErrors";
00091 case Cancelled: return "Cancelled";
00092 }
00093 return "Unknown";
00094 }
00095
00099
00100 bool ReadParameterFile(const std::string& filename);
00101
00102 bool ReadParameterFile(const char *filename);
00103
00110
00111 bool WriteParameterFile(const std::string& filename, bool withHandlesToBulkParameters = true);
00112
00113 bool WriteParameterFile(const char *filename, bool withHandlesToBulkParameters = true);
00114
00117
00118 void SetParameterAsString(const std::string& name, const std::string& value);
00119 void SetParameterAsInt(const std::string& name, int value);
00120 void SetParameterAsBool(const std::string& name, bool value);
00121 void SetParameterAsDouble(const std::string& name, double value);
00122 void SetParameterAsFloat(const std::string& name, float value);
00123
00124 std::string GetParameterAsString(const std::string &name) const;
00125
00126
00128 void SetParameterAsString(const char *name, const char *value)
00129 {this->SetParameterAsString(std::string(name), std::string(value));}
00130 void SetParameterAsInt(const char *name, const int value)
00131 {this->SetParameterAsInt(std::string(name), value);}
00132 void SetParameterAsBool(const char *name, const int value)
00133 {this->SetParameterAsBool(std::string(name), (value == 0 ? false : true));}
00134 void SetParameterAsDouble(const char *name, const double value)
00135 {this->SetParameterAsDouble(std::string(name), value);}
00136 void SetParameterAsFloat(const char *name, const float value)
00137 {this->SetParameterAsFloat(std::string(name), value);}
00138 const char* GetParameterAsString(const char* name) const
00139 {
00140 std::string stringName = name;
00141 return this->GetParameterAsString(stringName).c_str();
00142 }
00143 int GetNumberOfRegisteredModules ();
00144 void AbortProcess () {
00145 this->GetModuleDescription().GetProcessInformation()->Abort = 1;
00146 }
00147 const char* GetRegisteredModuleNameByIndex ( int idx );
00148 void SetModuleDescription ( const char *name ) { this->SetModuleDescription ( this->GetRegisteredModuleDescription ( name ) ); }
00149 const char* GetModuleVersion () { return this->GetModuleDescription().GetVersion().c_str(); };
00150 const char* GetModuleTitle () { return this->GetModuleDescription().GetTitle().c_str(); };
00151 const char* GetModuleTarget () { return this->GetModuleDescription().GetTarget().c_str(); };
00152 const char* GetModuleType () { return this->GetModuleDescription().GetType().c_str(); };
00153 unsigned int GetNumberOfParameterGroups () { return (int)this->GetModuleDescription().GetParameterGroups().size(); }
00154 unsigned int GetNumberOfParametersInGroup ( unsigned int group ) {
00155 if ( group >= this->GetModuleDescription().GetParameterGroups().size() ) { return 0; }
00156 return (unsigned int)this->GetModuleDescription().GetParameterGroups()[group].GetParameters().size();
00157 }
00158 const char* GetParameterGroupLabel ( unsigned int group ) { return this->GetModuleDescription().GetParameterGroups()[group].GetLabel().c_str(); }
00159 const char* GetParameterGroupDescription ( unsigned int group ) { return this->GetModuleDescription().GetParameterGroups()[group].GetDescription().c_str(); }
00160 const char* GetParameterGroupAdvanced ( unsigned int group ) { return this->GetModuleDescription().GetParameterGroups()[group].GetAdvanced().c_str(); }
00161
00162 const char* GetParameterTag ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetTag().c_str(); }
00163 const char* GetParameterType ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetType().c_str(); }
00164 const char* GetParameterArgType ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetArgType().c_str(); }
00165 const char* GetParameterName ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetName().c_str(); }
00166 const char* GetParameterLongFlag ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetLongFlag().c_str(); }
00167 const char* GetParameterLabel ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetLabel().c_str(); }
00168 const char* GetParameterConstraints ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetConstraints().c_str(); }
00169 const char* GetParameterMaximum ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetMaximum().c_str(); }
00170 const char* GetParameterMinimum ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetMinimum().c_str(); }
00171 const char* GetParameterDescription ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetDescription().c_str(); }
00172 const char* GetParameterChannel ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetChannel().c_str(); }
00173 const char* GetParameterIndex ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetIndex().c_str(); }
00174 const char* GetParameterDefault ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetDefault().c_str(); }
00175 const char* GetParameterFlag ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetFlag().c_str(); }
00176 const char* GetParameterMultiple ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetMultiple().c_str(); }
00177 const char* GetParameterFileExtensions ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetFileExtensionsAsString().c_str(); }
00178 const char* GetParameterCoordinateSystem ( unsigned int group, unsigned int param ) { return this->GetModuleDescription().GetParameterGroups()[group].GetParameters()[param].GetCoordinateSystem().c_str(); }
00179
00182
00183 static void RegisterModuleDescription(ModuleDescription md);
00184 static bool HasRegisteredModule(const std::string& name);
00185 static ModuleDescription GetRegisteredModuleDescription(const std::string& name);
00186 static void ClearRegisteredModules();
00188
00189 private:
00190 vtkMRMLCommandLineModuleNode();
00191 ~vtkMRMLCommandLineModuleNode();
00192 vtkMRMLCommandLineModuleNode(const vtkMRMLCommandLineModuleNode&);
00193 void operator=(const vtkMRMLCommandLineModuleNode&);
00194
00195 ModuleDescription ModuleDescriptionObject;
00196
00197 static ModuleDescriptionMap *RegisteredModules;
00198
00199
00200 StatusType m_Status;
00201
00202
00203 };
00204
00205 #endif
00206