VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkExecutive.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00032 #ifndef vtkExecutive_h 00033 #define vtkExecutive_h 00034 00035 #include "vtkCommonExecutionModelModule.h" // For export macro 00036 #include "vtkObject.h" 00037 00038 class vtkAlgorithm; 00039 class vtkAlgorithmOutput; 00040 class vtkAlgorithmToExecutiveFriendship; 00041 class vtkDataObject; 00042 class vtkExecutiveInternals; 00043 class vtkInformation; 00044 class vtkInformationExecutivePortKey; 00045 class vtkInformationExecutivePortVectorKey; 00046 class vtkInformationIntegerKey; 00047 class vtkInformationRequestKey; 00048 class vtkInformationKeyVectorKey; 00049 class vtkInformationVector; 00050 00051 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExecutive : public vtkObject 00052 { 00053 public: 00054 vtkTypeMacro(vtkExecutive,vtkObject); 00055 void PrintSelf(ostream& os, vtkIndent indent); 00056 00058 vtkAlgorithm* GetAlgorithm(); 00059 00061 00063 virtual int ProcessRequest(vtkInformation* request, 00064 vtkInformationVector** inInfo, 00065 vtkInformationVector* outInfo); 00067 00069 00078 virtual int 00079 ComputePipelineMTime(vtkInformation* request, 00080 vtkInformationVector** inInfoVec, 00081 vtkInformationVector* outInfoVec, 00082 int requestFromOutputPort, 00083 unsigned long* mtime); 00085 00087 virtual int UpdateInformation() {return 1;} 00088 00090 00092 virtual int Update(); 00093 virtual int Update(int port); 00095 00097 00099 int GetNumberOfInputPorts(); 00100 int GetNumberOfOutputPorts(); 00102 00104 int GetNumberOfInputConnections(int port); 00105 00107 virtual vtkInformation* GetOutputInformation(int port); 00108 00110 vtkInformationVector* GetOutputInformation(); 00111 00113 vtkInformation* GetInputInformation(int port, int connection); 00114 00116 vtkInformationVector* GetInputInformation(int port); 00117 00119 vtkInformationVector** GetInputInformation(); 00120 00122 vtkExecutive* GetInputExecutive(int port, int connection); 00123 00125 00126 virtual vtkDataObject* GetOutputData(int port); 00127 virtual void SetOutputData(int port, vtkDataObject*, vtkInformation *info); 00128 virtual void SetOutputData(int port, vtkDataObject*); 00130 00132 00133 virtual vtkDataObject* GetInputData(int port, int connection); 00134 virtual vtkDataObject* GetInputData(int port, int connection, 00135 vtkInformationVector **inInfoVec); 00137 00149 void SetSharedInputInformation(vtkInformationVector** inInfoVec); 00150 void SetSharedOutputInformation(vtkInformationVector* outInfoVec); 00152 00154 00155 virtual void Register(vtkObjectBase* o); 00156 virtual void UnRegister(vtkObjectBase* o); 00158 00161 static vtkInformationExecutivePortKey* PRODUCER(); 00162 00165 static vtkInformationExecutivePortVectorKey* CONSUMERS(); 00166 00169 static vtkInformationIntegerKey* FROM_OUTPUT_PORT(); 00170 00172 00174 static vtkInformationIntegerKey* ALGORITHM_BEFORE_FORWARD(); 00175 static vtkInformationIntegerKey* ALGORITHM_AFTER_FORWARD(); 00176 static vtkInformationIntegerKey* ALGORITHM_DIRECTION(); 00177 static vtkInformationIntegerKey* FORWARD_DIRECTION(); 00178 static vtkInformationKeyVectorKey* KEYS_TO_COPY(); 00179 //BTX 00180 enum { RequestUpstream, RequestDownstream }; 00181 enum { BeforeForward, AfterForward }; 00182 //ETX 00184 00186 00188 virtual int CallAlgorithm(vtkInformation* request, int direction, 00189 vtkInformationVector** inInfo, 00190 vtkInformationVector* outInfo); 00192 00193 protected: 00194 vtkExecutive(); 00195 ~vtkExecutive(); 00196 00197 // Helper methods for subclasses. 00198 int InputPortIndexInRange(int port, const char* action); 00199 int OutputPortIndexInRange(int port, const char* action); 00200 00201 // Called by methods to check for a recursive pipeline update. A 00202 // request should be fulfilled without making another request. This 00203 // is used to help enforce that behavior. Returns 1 if no recursive 00204 // request is occurring, and 0 otherwise. An error message is 00205 // produced automatically if 0 is returned. The first argument is 00206 // the name of the calling method (the one that should not be 00207 // invoked recursively during an update). The second argument is 00208 // the recursive request information object, if any. It is used to 00209 // construct the error message. 00210 int CheckAlgorithm(const char* method, vtkInformation* request); 00211 00212 virtual int ForwardDownstream(vtkInformation* request); 00213 virtual int ForwardUpstream(vtkInformation* request); 00214 virtual void CopyDefaultInformation(vtkInformation* request, int direction, 00215 vtkInformationVector** inInfo, 00216 vtkInformationVector* outInfo); 00217 00218 // Reset the pipeline update values in the given output information object. 00219 virtual void ResetPipelineInformation(int port, vtkInformation*)=0; 00220 00221 // Bring the existence of output data objects up to date. 00222 virtual int UpdateDataObject()=0; 00223 00224 // Garbage collection support. 00225 virtual void ReportReferences(vtkGarbageCollector*); 00226 00227 virtual void SetAlgorithm(vtkAlgorithm* algorithm); 00228 00229 // The algorithm managed by this executive. 00230 vtkAlgorithm* Algorithm; 00231 00232 // Flag set when the algorithm is processing a request. 00233 int InAlgorithm; 00234 00235 // Pointers to an outside instance of input or output information. 00236 // No references are held. These are used to implement internal 00237 // pipelines. 00238 vtkInformationVector** SharedInputInformation; 00239 vtkInformationVector* SharedOutputInformation; 00240 00241 private: 00242 // Store an information object for each output port of the algorithm. 00243 vtkInformationVector* OutputInformation; 00244 00245 // Internal implementation details. 00246 vtkExecutiveInternals* ExecutiveInternal; 00247 00248 //BTX 00249 friend class vtkAlgorithmToExecutiveFriendship; 00250 //ETX 00251 private: 00252 vtkExecutive(const vtkExecutive&); // Not implemented. 00253 void operator=(const vtkExecutive&); // Not implemented. 00254 }; 00255 00256 #endif