VTK
dox/Common/ExecutionModel/vtkExecutive.h
Go to the documentation of this file.
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 =========================================================================*/
00029 #ifndef __vtkExecutive_h
00030 #define __vtkExecutive_h
00031 
00032 #include "vtkCommonExecutionModelModule.h" // For export macro
00033 #include "vtkObject.h"
00034 
00035 class vtkAlgorithm;
00036 class vtkAlgorithmOutput;
00037 class vtkAlgorithmToExecutiveFriendship;
00038 class vtkDataObject;
00039 class vtkExecutiveInternals;
00040 class vtkInformation;
00041 class vtkInformationExecutivePortKey;
00042 class vtkInformationExecutivePortVectorKey;
00043 class vtkInformationIntegerKey;
00044 class vtkInformationRequestKey;
00045 class vtkInformationKeyVectorKey;
00046 class vtkInformationVector;
00047 
00048 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExecutive : public vtkObject
00049 {
00050 public:
00051   vtkTypeMacro(vtkExecutive,vtkObject);
00052   void PrintSelf(ostream& os, vtkIndent indent);
00053 
00055   vtkAlgorithm* GetAlgorithm();
00056 
00058 
00060   virtual int ProcessRequest(vtkInformation* request,
00061                              vtkInformationVector** inInfo,
00062                              vtkInformationVector* outInfo);
00064 
00066 
00075   virtual int
00076   ComputePipelineMTime(vtkInformation* request,
00077                        vtkInformationVector** inInfoVec,
00078                        vtkInformationVector* outInfoVec,
00079                        int requestFromOutputPort,
00080                        unsigned long* mtime);
00082 
00084   virtual int UpdateInformation() {return 1;}
00085 
00087 
00089   virtual int Update();
00090   virtual int Update(int port);
00092 
00094 
00096   int GetNumberOfInputPorts();
00097   int GetNumberOfOutputPorts();
00099 
00101   int GetNumberOfInputConnections(int port);
00102 
00104   virtual vtkInformation* GetOutputInformation(int port);
00105 
00107   vtkInformationVector* GetOutputInformation();
00108 
00110   vtkInformation* GetInputInformation(int port, int connection);
00111 
00113   vtkInformationVector* GetInputInformation(int port);
00114 
00116   vtkInformationVector** GetInputInformation();
00117 
00119   vtkExecutive* GetInputExecutive(int port, int connection);
00120 
00122 
00123   virtual vtkDataObject* GetOutputData(int port);
00124   virtual void SetOutputData(int port, vtkDataObject*, vtkInformation *info);
00125   virtual void SetOutputData(int port, vtkDataObject*);
00127 
00129 
00130   virtual vtkDataObject* GetInputData(int port, int connection);
00131   virtual vtkDataObject* GetInputData(int port, int connection,
00132                                       vtkInformationVector **inInfoVec);
00134 
00146   void SetSharedInputInformation(vtkInformationVector** inInfoVec);
00147   void SetSharedOutputInformation(vtkInformationVector* outInfoVec);
00149 
00151 
00152   virtual void Register(vtkObjectBase* o);
00153   virtual void UnRegister(vtkObjectBase* o);
00155 
00158   static vtkInformationExecutivePortKey* PRODUCER();
00159 
00162   static vtkInformationExecutivePortVectorKey* CONSUMERS();
00163 
00166   static vtkInformationIntegerKey* FROM_OUTPUT_PORT();
00167 
00169 
00171   static vtkInformationIntegerKey* ALGORITHM_BEFORE_FORWARD();
00172   static vtkInformationIntegerKey* ALGORITHM_AFTER_FORWARD();
00173   static vtkInformationIntegerKey* ALGORITHM_DIRECTION();
00174   static vtkInformationIntegerKey* FORWARD_DIRECTION();
00175   static vtkInformationKeyVectorKey* KEYS_TO_COPY();
00176   //BTX
00177   enum { RequestUpstream, RequestDownstream };
00178   enum { BeforeForward, AfterForward };
00179   //ETX
00181 
00183 
00185   virtual int CallAlgorithm(vtkInformation* request, int direction,
00186                             vtkInformationVector** inInfo,
00187                             vtkInformationVector* outInfo);
00189 
00190 protected:
00191   vtkExecutive();
00192   ~vtkExecutive();
00193 
00194   // Helper methods for subclasses.
00195   int InputPortIndexInRange(int port, const char* action);
00196   int OutputPortIndexInRange(int port, const char* action);
00197 
00198   // Called by methods to check for a recursive pipeline update.  A
00199   // request should be fulfilled without making another request.  This
00200   // is used to help enforce that behavior.  Returns 1 if no recursive
00201   // request is occurring, and 0 otherwise.  An error message is
00202   // produced automatically if 0 is returned.  The first argument is
00203   // the name of the calling method (the one that should not be
00204   // invoked recursively during an update).  The second argument is
00205   // the recursive request information object, if any.  It is used to
00206   // construct the error message.
00207   int CheckAlgorithm(const char* method, vtkInformation* request);
00208 
00209   virtual int ForwardDownstream(vtkInformation* request);
00210   virtual int ForwardUpstream(vtkInformation* request);
00211   virtual void CopyDefaultInformation(vtkInformation* request, int direction,
00212                                       vtkInformationVector** inInfo,
00213                                       vtkInformationVector* outInfo);
00214 
00215   // Reset the pipeline update values in the given output information object.
00216   virtual void ResetPipelineInformation(int port, vtkInformation*)=0;
00217 
00218   // Bring the existence of output data objects up to date.
00219   virtual int UpdateDataObject()=0;
00220 
00221   // Garbage collection support.
00222   virtual void ReportReferences(vtkGarbageCollector*);
00223 
00224   virtual void SetAlgorithm(vtkAlgorithm* algorithm);
00225 
00226   // The algorithm managed by this executive.
00227   vtkAlgorithm* Algorithm;
00228 
00229   // Flag set when the algorithm is processing a request.
00230   int InAlgorithm;
00231 
00232   // Pointers to an outside instance of input or output information.
00233   // No references are held.  These are used to implement internal
00234   // pipelines.
00235   vtkInformationVector** SharedInputInformation;
00236   vtkInformationVector* SharedOutputInformation;
00237 
00238 private:
00239   // Store an information object for each output port of the algorithm.
00240   vtkInformationVector* OutputInformation;
00241 
00242   // Internal implementation details.
00243   vtkExecutiveInternals* ExecutiveInternal;
00244 
00245   //BTX
00246   friend class vtkAlgorithmToExecutiveFriendship;
00247   //ETX
00248 private:
00249   vtkExecutive(const vtkExecutive&);  // Not implemented.
00250   void operator=(const vtkExecutive&);  // Not implemented.
00251 };
00252 
00253 #endif