Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Servers/ServerManager/vtkSMProxy.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   ParaView
00004   Module:    $RCSfile: vtkSMProxy.h,v $
00005 
00006   Copyright (c) Kitware, Inc.
00007   All rights reserved.
00008   See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 =========================================================================*/
00102 #ifndef __vtkSMProxy_h
00103 #define __vtkSMProxy_h
00104 
00105 #include "vtkSMObject.h"
00106 #include "vtkClientServerID.h" // needed for vtkClientServerID
00107 
00108 //BTX
00109 struct vtkSMProxyInternals;
00110 //ETX
00111 class vtkPVXMLElement;
00112 class vtkSMProperty;
00113 class vtkSMPropertyIterator;
00114 class vtkSMProxyManager;
00115 
00116 class VTK_EXPORT vtkSMProxy : public vtkSMObject
00117 {
00118 public:
00119   static vtkSMProxy* New();
00120   vtkTypeRevisionMacro(vtkSMProxy, vtkSMObject);
00121   void PrintSelf(ostream& os, vtkIndent indent);
00122 
00124 
00127   vtkSetStringMacro(Name);
00128   vtkGetStringMacro(Name);
00130 
00135   void AddProperty(const char* name, vtkSMProperty* prop);
00136 
00138 
00140   vtkSMProperty* GetProperty(const char* name) 
00141     {
00142       return this->GetProperty(name, 0);
00143     }
00145 
00149   virtual void UpdateVTKObjects();
00150 
00162   virtual void UpdateSelfAndAllInputs();
00163 
00165 
00166   vtkGetStringMacro(VTKClassName);
00168 
00170 
00173   vtkSetStringMacro(VTKClassName);
00175 
00178   virtual void UnRegister(vtkObjectBase* obj);
00179 
00181   vtkClientServerID GetID(unsigned int idx);
00182 
00184   vtkClientServerID GetSelfID() { return this->SelfID; }
00185 
00188   unsigned int GetNumberOfIDs();
00189 
00191   vtkSMPropertyIterator* NewPropertyIterator();
00192 
00195   unsigned int GetNumberOfConsumers();
00196 
00199   vtkSMProxy* GetConsumerProxy(unsigned int idx);
00200 
00204   vtkSMProperty* GetConsumerProperty(unsigned int idx);
00205 
00207 
00209   vtkGetStringMacro(XMLName);
00211 
00213 
00216   vtkGetStringMacro(XMLGroup);
00218 
00223   virtual void UpdateInformation();
00224 
00227   virtual void UpdatePropertyInformation(vtkSMProperty* prop);
00228 
00234   virtual void MarkAllPropertiesAsModified();
00235   
00236 //BTX
00238   void SetServers(vtkTypeUInt32 servers);
00239  
00241   vtkTypeUInt32 GetServers();
00242 
00244 
00245   enum
00246     {
00247     COPY_PROXY_PROPERTY_VALUES_BY_REFERENCE=0,
00248     COPY_PROXY_PROPERTY_VALUES_BY_CLONING
00249     };
00251 //ETX
00252 
00254 
00262   void Copy(vtkSMProxy* src);
00263   void Copy(vtkSMProxy* src, const char* exceptionClass);
00264   virtual void Copy(vtkSMProxy* src, const char* exceptionClass, 
00265     int proxyPropertyCopyFlag);
00267   
00270   virtual void MarkConsumersAsModified();
00271 
00272 protected:
00273   vtkSMProxy();
00274   ~vtkSMProxy();
00275 
00278   vtkSMProperty* GetExposedProperty(const char* name);
00279 
00281   void ExposeProperty(const char* name);
00282 
00283 //BTX
00284   // These classes have been declared as friends to minimize the
00285   // public interface exposed by vtkSMProxy. Each of these classes
00286   // use a small subset of protected methods. This should be kept
00287   // as such.
00288   friend class vtkSMProperty;
00289   friend class vtkSMProxyManager;
00290   friend class vtkSMInputProperty;
00291   friend class vtkSMProxyProperty;
00292   friend class vtkSMPropertyIterator;
00293   friend class vtkSMProxyObserver;
00294   friend class vtkSMSourceProxy;
00295 //ETX
00296 
00298 
00300   vtkSetStringMacro(XMLName);
00302 
00304 
00307   vtkSetStringMacro(XMLGroup);
00309 
00313   virtual void CreateVTKObjects(int numObjects);
00314 
00317   void UnRegisterVTKObjects();
00318 
00319   // IDs are used to access server objects using the stream-based wrappers.
00320   // The following methods manage the IDs of objects maintained by the proxy.
00321   // Note that the IDs are assigned by the proxy at creation time. They
00322   // can not be set.
00323 
00329   virtual void SetID(unsigned int idx, vtkClientServerID id);
00330 
00331   // Server IDs determine on which server(s) the VTK objects are
00332   // instantiated. Use the following methods to set/get the server
00333   // IDs. Server IDs have to be set before the object is created.
00334   // Changing them after creation has no effect.
00335   // See vtkProcessModule.h for a list of all server types.
00336   // To add a server, OR it's value with the servers ivar.
00337 
00338 
00340   void SetServersSelf(vtkTypeUInt32 servers);
00341 
00342 //BTX
00343   // This is a convenience method that pushes the value of one property
00344   // to one server alone. This is most commonly used by sub-classes
00345   // to make calls on the server manager through the stream interface.
00346   // This method does not change the modified flag of the property.
00347   // If possible, use UpdateVTKObjects() instead of this.
00348   void PushProperty(const char* name, 
00349                     vtkClientServerID id, 
00350                     vtkTypeUInt32 servers);
00351 //ETX
00352 
00353   // Note on property modified flags:
00354   // The modified flag of each property associated with a proxy is
00355   // stored in the proxy object instead of in the property itself.
00356   // Here is a brief explanation of how modified flags are used:
00357   // 1. When a property is modified, the modified flag is set
00358   // 2. In UpdateVTKObjects(), the proxy visits all properties and
00359   //    calls AppendCommandToStream() on each modified property.
00360   //    It also resets the modified flag.
00361   // The reason why the modified flag is stored in the proxy instead
00362   // of property is in item 2 above. If multiple proxies were sharing the same
00363   // property, the first one would reset the modified flag in
00364   // UpdateVTKObjects() and then others would not call AppendCommandToStream()
00365   // in their turn. Therefore, each proxy has to keep track of all
00366   // properties it updated.
00367   // This is done by adding observers to the properties. When a property
00368   // is modified, it invokes all observers and the observers set the
00369   // appropriate flags in the proxies. 
00370 
00371 
00374   void RemoveAllObservers();
00375 
00377   void SetPropertyModifiedFlag(const char* name, int flag);
00378 
00380 
00385   void AddProperty(const char* subProxyName,
00386                    const char* name, 
00387                    vtkSMProperty* prop);
00389 
00391   void RemoveProperty(const char* name);
00392 
00394   void AddPropertyToSelf(const char* name, vtkSMProperty* prop);
00395 
00397   void AddSubProxy(const char* name, vtkSMProxy* proxy);
00398 
00400   void RemoveSubProxy(const char* name);
00401 
00403   vtkSMProxy* GetSubProxy(const char* name);
00404 
00407   void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
00408 
00410   void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
00411 
00413   void RemoveAllConsumers();
00414 
00416 
00418   vtkSMProperty* NewProperty(const char* name);
00419   vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
00421 
00424   virtual vtkSMProperty* GetProperty(const char* name, int selfOnly);
00425 
00427   virtual int ReadXMLAttributes(vtkSMProxyManager* pm, vtkPVXMLElement* element);
00428 
00429   int CreateSubProxiesAndProperties(vtkSMProxyManager* pm, 
00430     vtkPVXMLElement *element);
00431 
00432   char* Name;
00433   char* VTKClassName;
00434   char* XMLGroup;
00435   char* XMLName;
00436   int ObjectsCreated;
00437   vtkTypeUInt32 Servers;
00438   int DoNotModifyProperty;
00439 
00440   // Avoids calls to UpdateVTKObjects in UpdateVTKObjects.
00441   // UpdateVTKObjects call it self recursively until no
00442   // properties are modified.
00443   int InUpdateVTKObjects;
00444 
00445   // Flag used to help speed up UpdateVTKObjects and ArePropertiesModified
00446   // calls.
00447   int SelfPropertiesModified;
00448   // Indicates if any properties are modified.
00449   int ArePropertiesModified(int selfOnly = 0);
00450 
00451   vtkClientServerID SelfID;
00452 
00453   void SetXMLElement(vtkPVXMLElement* element);
00454   vtkPVXMLElement* XMLElement;
00455 
00456   // the name is the name with which the proxy was registered with pxm.
00457   // However, the proxy, uses SelfID to create a name for itself while 
00458   // saving the state.
00459   virtual void SaveState(const char* name, ostream* file, vtkIndent indent);
00460 
00461   void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement *element);
00462   void SetupExposedProperties(vtkSMProxy* subproxy, vtkPVXMLElement *element);
00463   
00464 
00465   int CreateProxyHierarchy(vtkSMProxyManager* pm, vtkPVXMLElement* element);
00466 
00467 private:
00468   vtkSMProxyInternals* Internals;
00469 
00470   vtkSMProxy(const vtkSMProxy&); // Not implemented
00471   void operator=(const vtkSMProxy&); // Not implemented
00472 };
00473 
00474 #endif

Generated on Tue May 30 12:31:48 2006 for ParaView by doxygen 1.3.5