VTK
dox/Filtering/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 "vtkObject.h"
00033 
00034 class vtkAlgorithm;
00035 class vtkAlgorithmOutput;
00036 class vtkAlgorithmToExecutiveFriendship;
00037 class vtkDataObject;
00038 class vtkExecutiveInternals;
00039 class vtkInformation;
00040 class vtkInformationExecutivePortKey;
00041 class vtkInformationExecutivePortVectorKey;
00042 class vtkInformationIntegerKey;
00043 class vtkInformationRequestKey;
00044 class vtkInformationKeyVectorKey;
00045 class vtkInformationVector;
00046 
00047 class VTK_FILTERING_EXPORT vtkExecutive : public vtkObject
00048 {
00049 public:
00050   vtkTypeMacro(vtkExecutive,vtkObject);
00051   void PrintSelf(ostream& os, vtkIndent indent);
00052 
00054   vtkAlgorithm* GetAlgorithm();
00055 
00057 
00059   virtual int ProcessRequest(vtkInformation* request,
00060                              vtkInformationVector** inInfo,
00061                              vtkInformationVector* outInfo);
00063 
00065 
00074   virtual int
00075   ComputePipelineMTime(vtkInformation* request,
00076                        vtkInformationVector** inInfoVec,
00077                        vtkInformationVector* outInfoVec,
00078                        int requestFromOutputPort,
00079                        unsigned long* mtime);
00081 
00083 
00085   virtual int Update();
00086   virtual int Update(int port);
00088 
00090 
00092   int GetNumberOfInputPorts();
00093   int GetNumberOfOutputPorts();
00095 
00097   int GetNumberOfInputConnections(int port);
00098 
00100   virtual vtkInformation* GetOutputInformation(int port);
00101 
00103   vtkInformationVector* GetOutputInformation();
00104 
00106   vtkInformation* GetInputInformation(int port, int connection);
00107 
00109   vtkInformationVector* GetInputInformation(int port);  
00110   
00112   vtkInformationVector** GetInputInformation();
00113 
00115   vtkExecutive* GetInputExecutive(int port, int connection);
00116 
00118 
00119   virtual vtkDataObject* GetOutputData(int port);
00120   virtual void SetOutputData(int port, vtkDataObject*, vtkInformation *info);
00121   virtual void SetOutputData(int port, vtkDataObject*);
00123 
00125 
00126   virtual vtkDataObject* GetInputData(int port, int connection);
00127   virtual vtkDataObject* GetInputData(int port, int connection, 
00128                                       vtkInformationVector **inInfoVec);
00130 
00132   virtual vtkAlgorithmOutput* GetProducerPort(vtkDataObject*);
00133 
00135 
00141   void SetSharedInputInformation(vtkInformationVector** inInfoVec);
00142   void SetSharedOutputInformation(vtkInformationVector* outInfoVec);
00144 
00146 
00147   virtual void Register(vtkObjectBase* o);
00148   virtual void UnRegister(vtkObjectBase* o);
00150 
00153   static vtkInformationExecutivePortKey* PRODUCER();
00154 
00157   static vtkInformationExecutivePortVectorKey* CONSUMERS();
00158 
00161   static vtkInformationIntegerKey* FROM_OUTPUT_PORT();
00162 
00164 
00166   static vtkInformationIntegerKey* ALGORITHM_BEFORE_FORWARD();
00167   static vtkInformationIntegerKey* ALGORITHM_AFTER_FORWARD();
00168   static vtkInformationIntegerKey* ALGORITHM_DIRECTION();
00169   static vtkInformationIntegerKey* FORWARD_DIRECTION();
00170   static vtkInformationKeyVectorKey* KEYS_TO_COPY();
00171   //BTX
00172   enum { RequestUpstream, RequestDownstream };
00173   enum { BeforeForward, AfterForward };
00174   //ETX
00176 
00178 
00180   virtual int CallAlgorithm(vtkInformation* request, int direction,
00181                             vtkInformationVector** inInfo,
00182                             vtkInformationVector* outInfo);
00184 
00185 protected:
00186   vtkExecutive();
00187   ~vtkExecutive();
00188 
00189   // Helper methods for subclasses.
00190   int InputPortIndexInRange(int port, const char* action);
00191   int OutputPortIndexInRange(int port, const char* action);
00192 
00193   // Called by methods to check for a recursive pipeline update.  A
00194   // request should be fulfilled without making another request.  This
00195   // is used to help enforce that behavior.  Returns 1 if no recursive
00196   // request is occurring, and 0 otherwise.  An error message is
00197   // produced automatically if 0 is returned.  The first argument is
00198   // the name of the calling method (the one that should not be
00199   // invoked recursively during an update).  The second argument is
00200   // the recursive request information object, if any.  It is used to
00201   // construct the error message.
00202   int CheckAlgorithm(const char* method, vtkInformation* request);
00203 
00204   virtual int ForwardDownstream(vtkInformation* request);
00205   virtual int ForwardUpstream(vtkInformation* request);
00206   virtual void CopyDefaultInformation(vtkInformation* request, int direction,
00207                                       vtkInformationVector** inInfo,
00208                                       vtkInformationVector* outInfo);
00209 
00210   // Reset the pipeline update values in the given output information object.
00211   virtual void ResetPipelineInformation(int port, vtkInformation*)=0;
00212 
00213   // Bring the existence of output data objects up to date.
00214   virtual int UpdateDataObject()=0;
00215 
00216   // Garbage collection support.
00217   virtual void ReportReferences(vtkGarbageCollector*);
00218 
00219   virtual void SetAlgorithm(vtkAlgorithm* algorithm);
00220 
00221   // The algorithm managed by this executive.
00222   vtkAlgorithm* Algorithm;
00223 
00224   // Flag set when the algorithm is processing a request.
00225   int InAlgorithm;
00226 
00227   // Pointers to an outside instance of input or output information.
00228   // No references are held.  These are used to implement internal
00229   // pipelines.
00230   vtkInformationVector** SharedInputInformation;
00231   vtkInformationVector* SharedOutputInformation;
00232 
00233 private:
00234   // Store an information object for each output port of the algorithm.
00235   vtkInformationVector* OutputInformation;
00236 
00237   // Internal implementation details.
00238   vtkExecutiveInternals* ExecutiveInternal;
00239 
00240   //BTX
00241   friend class vtkAlgorithmToExecutiveFriendship;
00242   //ETX
00243 private:
00244   vtkExecutive(const vtkExecutive&);  // Not implemented.
00245   void operator=(const vtkExecutive&);  // Not implemented.
00246 };
00247 
00248 #endif