00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef SIMPLEEXECUTION__ 00011 #define SIMPLEEXECUTION__ 00012 00013 #include "AppConfig.h" 00014 00015 class ExecutableAgent; 00016 class PlugInArgList; 00017 class WizardItem; 00018 class WizardNode; 00019 class WizardObject; 00020 00021 #ifdef __cplusplus 00022 extern "C" 00023 { 00024 #endif 00025 /** \addtogroup simple_api */ 00026 /*@{*/ 00027 00028 /** 00029 * @file SimpleExecution.h 00030 * This file contains functions and type definitions for executing plugins and wizards. 00031 */ 00032 00033 /** 00034 * Create a new PlugIn handle. 00035 * 00036 * @param pName 00037 * The \c NULL terminated name of the plug-in to create. 00038 * @param batch 00039 * Create an interactive plug-in if this is 0 otherwise create a batch plug-in. 00040 * @return A new PlugIn or \c NULL if an error occured. 00041 * Must be freed with freePlugIn() if ownership is not explicitly transfered. 00042 * @see ExecutableResource 00043 */ 00044 EXPORT_SYMBOL ExecutableAgent* createPlugIn(const char* pName, int batch); 00045 00046 /** 00047 * Free a PlugIn handle created with createPlugIn(). 00048 * 00049 * Suitable for use as a cleanup callback. 00050 * 00051 * @param pPlugin 00052 * The PlugIn to free. No error checking is performed on this value 00053 * and a \c NULL will cause a NOOP. 00054 */ 00055 EXPORT_SYMBOL void freePlugIn(ExecutableAgent* pPlugin); 00056 00057 /** 00058 * Access the input argument list for a PlugIn. 00059 * 00060 * A SIMPLE_OTHER_FAILURE indicates std::logic_error was caught. 00061 * 00062 * @param pPlugin 00063 * The PlugIn whose argument list will be returned. 00064 * @return an input argument list or \c NULL if an error occurs. 00065 * @see ExecutableAgent::getInArgList() 00066 */ 00067 EXPORT_SYMBOL PlugInArgList* getPlugInInputArgList(ExecutableAgent* pPlugin); 00068 00069 /** 00070 * Access the output argument list for a PlugIn. 00071 * 00072 * A SIMPLE_OTHER_FAILURE indicates std::logic_error was caught. 00073 * 00074 * @param pPlugin 00075 * The PlugIn whose argument list will be returned. 00076 * @return an output argument list or \c NULL if an error occurs. 00077 * @see ExecutableAgent::getOutArgList() 00078 */ 00079 EXPORT_SYMBOL PlugInArgList* getPlugInOutputArgList(ExecutableAgent* pPlugin); 00080 00081 /** 00082 * Execute a PlugIn. 00083 * 00084 * A SIMPLE_OTHER_FAILURE indicates std::logic_error was caught. 00085 * 00086 * @param pPlugin 00087 * The PlugIn to execute. 00088 * @return 0 if execution failed, non-zero if execution succeeded. 00089 * The only simple API error set is SIMPLE_OTHER_FAILURE if 00090 * std::logic_error was caught. All other 0 returns indicate an 00091 * error in the PlugIn execution. 00092 * @see ExecutableAgent::execute() 00093 */ 00094 EXPORT_SYMBOL int executePlugIn(ExecutableAgent* pPlugin); 00095 00096 /** 00097 * Load a wizard from a file. 00098 * 00099 * @param pFilename 00100 * The \c NULL terminated filename of the wizard to load. 00101 * An attempt will be made to determine if this is an absolute 00102 * or relative path by first opening pFilename directly. If this 00103 * fails, the wizard path setting will be prepended to the filename 00104 * and this will be opened. 00105 * @return A new WizardObject or \c NULL if an error occured. 00106 * Must be freed with freeWizard(). 00107 */ 00108 EXPORT_SYMBOL WizardObject* loadWizard(const char* pFilename); 00109 00110 /** 00111 * Free a WizardObject created with loadWizard(). 00112 * 00113 * Suitable for use as a cleanup callback. 00114 * 00115 * @param pWizard 00116 * The wizard to free. No error checking is performed on this value 00117 * and a \c NULL will cause a NOOP. 00118 */ 00119 EXPORT_SYMBOL void freeWizard(WizardObject* pWizard); 00120 00121 /** 00122 * Get the name of a wizard. 00123 * 00124 * @param pWizard 00125 * The WizardObject to query. 00126 * @param pName 00127 * Buffer to store the name. This will be \c NULL terminated. 00128 * @param nameSize 00129 * The size of the Buffer. If the name is too long, an error 00130 * will be set. 00131 * If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned. 00132 * @return the actual length of the name. 00133 */ 00134 EXPORT_SYMBOL uint32_t getWizardName(WizardObject* pWizard, char* pName, uint32_t nameSize); 00135 00136 /** 00137 * Get the number of input nodes in a wizard. 00138 * 00139 * Input nodes correspond to value items in the wizard. 00140 * 00141 * @param pWizard 00142 * The WizardObject to query. 00143 * @return the number of input nodes. 0 may indicate an error. 00144 */ 00145 EXPORT_SYMBOL uint32_t getWizardInputNodeCount(WizardObject* pWizard); 00146 00147 /** 00148 * Get the number of output nodes in a wizard. 00149 * 00150 * Output nodes for value items are not counted. 00151 * 00152 * @param pWizard 00153 * The WizardObject to query. 00154 * @return the number of output nodes. 0 may indicate an error. 00155 */ 00156 EXPORT_SYMBOL uint32_t getWizardOutputNodeCount(WizardObject* pWizard); 00157 00158 /** 00159 * Get an input node. 00160 * 00161 * Input nodes correspond to value items in the wizard. 00162 * 00163 * @param pWizard 00164 * The WizardObject to query. 00165 * @param idx 00166 * The 0 based index of the input node. Must be less than the return value 00167 * of getWizardInputNodeCount(). 00168 * @return A WizardNode handle. 00169 */ 00170 EXPORT_SYMBOL WizardNode* getWizardInputNodeByIndex(WizardObject* pWizard, uint32_t idx); 00171 00172 /** 00173 * Get an input node with a given name. 00174 * 00175 * Input nodes correspond to value items in the wizard. The name is the name 00176 * associated with the value item. 00177 * 00178 * @param pWizard 00179 * The WizardObject to query. 00180 * @param pName 00181 * The \c NULL terminated name of the input node. 00182 * @return A WizardNode handle. 00183 */ 00184 EXPORT_SYMBOL WizardNode* getWizardInputNodeByName(WizardObject* pWizard, const char* pName); 00185 00186 /** 00187 * Get an output node. 00188 * 00189 * Output nodes for value items are not counted. 00190 * 00191 * @param pWizard 00192 * The WizardObject to query. 00193 * @param idx 00194 * The 0 based index of the output node. Must be less than the return value 00195 * of getWizardOutputNodeCount(). 00196 * @return A WizardNode handle. 00197 */ 00198 EXPORT_SYMBOL WizardNode* getWizardOutputNodeByIndex(WizardObject* pWizard, uint32_t idx); 00199 00200 /** 00201 * Get an output node with a given name. 00202 * 00203 * Output nodes for value items are not counted. The name is the name 00204 * of the wizard item followed by a | and the name of the output node. 00205 * Wizard item names which contain a | can't be accessed with the method, use 00206 * getWizardOutputNodeByIndex() instead. If there are multiple items with the 00207 * same name, the first one (ordered by execution order) will be selected. Use 00208 * getWizardOutputNodeByIndex() to access the other items. 00209 * For example: 00210 * Principal Component Analysis|Corrected Data Cube 00211 * 00212 * @param pWizard 00213 * The WizardObject to query. 00214 * @param pName 00215 * The \c NULL terminated name of the output node. 00216 * @return A WizardNode handle. 00217 */ 00218 EXPORT_SYMBOL WizardNode* getWizardOutputNodeByName(WizardObject* pWizard, const char* pName); 00219 00220 /** 00221 * Execute a wizard. 00222 * 00223 * @param pWizard 00224 * The wizard to execute. 00225 * @return 0 if execution failed, non-zero if execution succeeded. 00226 * The only simple API error set is SIMPLE_BAD_PARAMS. 00227 * All other 0 returns indicate an 00228 * error in the wizard execution. 00229 */ 00230 EXPORT_SYMBOL int executeWizard(WizardObject* pWizard); 00231 00232 /** 00233 * Get the name of a wizard node. 00234 * 00235 * @param pNode 00236 * The WizardNode to query. 00237 * @param pName 00238 * Buffer to store the name. This will be \c NULL terminated. 00239 * @param nameSize 00240 * The size of the Buffer. If the name is too long, an error 00241 * will be set. 00242 * If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned. 00243 * @return the actual length of the name. 00244 */ 00245 EXPORT_SYMBOL uint32_t getWizardNodeName(WizardNode* pNode, char* pName, uint32_t nameSize); 00246 00247 /** 00248 * Get the type string of a wizard node. 00249 * 00250 * @param pNode 00251 * The WizardNode to query. 00252 * @param pType 00253 * Buffer to store the type. This will be \c NULL terminated. 00254 * @param typeSize 00255 * The size of the Buffer. If the type is too long, an error 00256 * will be set. 00257 * If this is 0, the minimum size of the buffer including the trailing \c NULL will be returned. 00258 * @return the actual length of the type. 00259 */ 00260 EXPORT_SYMBOL uint32_t getWizardNodeType(WizardNode* pNode, char* pType, uint32_t typeSize); 00261 00262 /** 00263 * Get the value of a wizard node. 00264 * 00265 * @param pNode 00266 * The WizardNode to query. 00267 * @return A void* to the value. The type of this data is determined by getWizardNodeType(). 00268 * This value should not be directly modified. If you want to change the value, call 00269 * setWizardNodeValue(). 00270 */ 00271 EXPORT_SYMBOL void* getWizardNodeValue(WizardNode* pNode); 00272 00273 /** 00274 * Set the value of a wizard node. 00275 * 00276 * @param pNode 00277 * The WizardNode to query. 00278 * @param pValue 00279 * A void* to the value. The type of this data is determined by getWizardNodeType(). 00280 * @return A 0 if a failure occurs, a non-zero otherwise. 00281 */ 00282 EXPORT_SYMBOL int setWizardNodeValue(WizardNode* pNode, void* pValue); 00283 00284 /*@}*/ 00285 #ifdef __cplusplus 00286 } 00287 #endif 00288 00289 #endif