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 WIZARDITEM_H 00011 #define WIZARDITEM_H 00012 00013 #include "Serializable.h" 00014 #include "WizardNode.h" 00015 00016 #include <string> 00017 #include <vector> 00018 00019 class WizardObject; 00020 00021 /** 00022 * A single wizard task. 00023 * 00024 * A WizardItem object defines a single task that is executed from within a wizard. The 00025 * item has a name and a type for the unique identifiers. The available types are as 00026 * follows: 00027 * 00028 * <table> 00029 * <tr><td><b>Type</b></td><td><b>%Description</b></td></tr> 00030 * <tr><td>Algorithm</td><td>A plug-in typically used for processing data.</td></tr> 00031 * <tr><td>%Exporter</td><td>A plug-in to save data to a file.</td></tr> 00032 * <tr><td>%Georeference</td><td>A georeferencing algorithm.</td></tr> 00033 * <tr><td>%Importer</td><td>A plug-in to load data from a file.</td></tr> 00034 * <tr><td>Value</td><td>A specific data value that is stored as a DataVariant.</td></tr> 00035 * <tr><td>Viewer</td><td>A plug-in to uniquely display data.</td></tr> 00036 * <tr><td>Wizard</td><td>A plug-in used to execute other plug-ins and services. Many of these 00037 * items allow for a run-time selection and execution of a method in the DesktopServices 00038 * interface.</td></tr> 00039 * </table> 00040 * 00041 * An item is designated to run either in batch mode or interactive mode. The 00042 * getBatchMode() method queries this state. 00043 * 00044 * The item contains input and output nodes that define the required input data and the 00045 * generated output data. The nodes can be retrieved using getInputNodes() and 00046 * getOutputNodes() or with getInputNode() and getOutputNode() if the name and type of 00047 * the node are known. 00048 * 00049 * @see WizardNode 00050 */ 00051 class WizardItem : public Serializable 00052 { 00053 public: 00054 /** 00055 * Returns the item name. 00056 * 00057 * @return The item name. 00058 * 00059 * @see getType() 00060 */ 00061 virtual const std::string& getName() const = 0; 00062 00063 /** 00064 * Returns the item type. 00065 * 00066 * @return The item type. 00067 * 00068 * @see getName() 00069 */ 00070 virtual const std::string& getType() const = 0; 00071 00072 /** 00073 * Returns the batch mode operation state of the item. 00074 * 00075 * @return TRUE if the item is set to run in batch mode. FALSE if the item is 00076 * set to run in interactive mode. 00077 */ 00078 virtual bool getBatchMode() const = 0; 00079 00080 /** 00081 * Returns whether the item supports the current batch/interactive mode. 00082 * 00083 * @return TRUE if the item supports the current mode. FALSE if the item does 00084 * not support the current mode. 00085 * 00086 * @see getBatchMode() 00087 */ 00088 virtual bool isCurrentModeSupported() const = 0; 00089 00090 /** 00091 * Retrieves a single input node. 00092 * 00093 * @param name 00094 * The input node name. 00095 * @param type 00096 * The input node type. 00097 * 00098 * @return A pointer to the input node. NULL is returned if no input node exists 00099 * with the given name and type. 00100 * 00101 * @see getInputNodes(), getOutputNode() 00102 */ 00103 virtual WizardNode* getInputNode(const std::string& name, const std::string& type) const = 0; 00104 00105 /** 00106 * Retrieves all input nodes. 00107 * 00108 * @return A reference to a vector containing the input node pointers. 00109 * 00110 * @see getInputNode(), getOutputNodes() 00111 */ 00112 virtual const std::vector<WizardNode*>& getInputNodes() const = 0; 00113 00114 /** 00115 * Retrieves a single output node. 00116 * 00117 * @param name 00118 * The output node name. 00119 * @param type 00120 * The output node type. 00121 * 00122 * @return A pointer to the output node. NULL is returned if no output node exists 00123 * with the given name and type. 00124 * 00125 * @see getOutputNodes(), getInputNode() 00126 */ 00127 virtual WizardNode* getOutputNode(const std::string& name, const std::string& type) const = 0; 00128 00129 /** 00130 * Retrieves all output nodes. 00131 * 00132 * @return A reference to a vector containing the output node pointers. 00133 * 00134 * @see getOutputNode(), getInputNodes() 00135 */ 00136 virtual const std::vector<WizardNode*>& getOutputNodes() const = 0; 00137 00138 /** 00139 * Queries whether an item is directly or indirectly connected to this item. 00140 * 00141 * This method provides a recursive search for the connected item by searching the 00142 * entire chain of items connected to the reference item. The input flag specifies 00143 * whether to search the chain of input node or output node connections. 00144 * 00145 * @param pItem 00146 * The item to query for a connection 00147 * @param bInputNode 00148 * TRUE to search items connected to the input nodes and FALSE to search 00149 * items connected to the output nodes. 00150 * 00151 * @return TRUE if the item is connected. FALSE if the item is not connected or the 00152 * item does not exist. 00153 * 00154 * @see getConnectedItems() 00155 */ 00156 virtual bool isItemConnected(WizardItem* pItem, bool bInputNode) const = 0; 00157 00158 /** 00159 * Retrieves wizard items connected to the input or output nodes of this item. 00160 * 00161 * @param bInputNode 00162 * TRUE to return items connected to the input nodes and FALSE to return 00163 * items connected to the output nodes. 00164 * @param connectedItems 00165 * A vector that is populated with pointers to the wizard items connected 00166 * with this one. 00167 * 00168 * @see isItemConnected() 00169 */ 00170 virtual void getConnectedItems(bool bInputNode, std::vector<WizardItem*>& connectedItems) const = 0; 00171 00172 /** 00173 * Returns the parent wizard containing this item. 00174 * 00175 * @return The parent wizard. 00176 */ 00177 virtual WizardObject* getWizard() = 0; 00178 00179 /** 00180 * Returns the parent wizard containing this item. 00181 * 00182 * @return The parent wizard. 00183 */ 00184 virtual const WizardObject* getWizard() const = 0; 00185 00186 protected: 00187 /** 00188 * A plug-in cannot create this object; it can only retrieve an already existing 00189 * object from WizardObject. The WizardObject will manage any instances 00190 * of this object. 00191 */ 00192 virtual ~WizardItem() {} 00193 }; 00194 00195 #endif