vtkSMRemoteObject.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
12 #ifndef vtkSMRemoteObject_h
13 #define vtkSMRemoteObject_h
14 
15 #include "vtkRemotingServerManagerModule.h" //needed for exports
16 #include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
17 #include "vtkSMSessionObject.h"
18 #include "vtkWeakPointer.h" // needed for vtkWeakPointer
19 
21 class vtkSMSession;
22 class vtkSMProxyLocator;
23 class vtkSMLoadStateContext;
24 
25 class VTKREMOTINGSERVERMANAGER_EXPORT vtkSMRemoteObject : public vtkSMSessionObject
26 {
27  // My friends are...
28  friend class vtkSMStateHelper; // To pull state
29  friend class vtkSMStateLoader; // To set GlobalId as the originals
30 
31 public:
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34 
36 
40  vtkSetMacro(Location, vtkTypeUInt32);
41  vtkGetMacro(Location, vtkTypeUInt32);
43 
48  void SetSession(vtkSMSession*) override;
49 
51 
55  virtual vtkTypeUInt32 GetGlobalID();
56  const char* GetGlobalIDAsString();
58 
63  bool HasGlobalID();
64 
66 
70  vtkBooleanMacro(Prototype, bool);
71  bool IsPrototype() { return this->Prototype; }
72  vtkSetMacro(Prototype, bool);
74 
81  virtual const vtkSMMessage* GetFullState() { return nullptr; }
82 
84 
91  virtual void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator)
92  {
93  (void)msg;
94  (void)locator;
95  }
97 
105  virtual void EnableLocalPushOnly();
106 
111  virtual void DisableLocalPushOnly();
112 
117  virtual bool IsLocalPushOnly() { return this->ClientOnlyLocationFlag; }
118 
119 protected:
124 
128  ~vtkSMRemoteObject() override;
129 
134  void PushState(vtkSMMessage* msg);
135 
141  bool PullState(vtkSMMessage* msg);
142 
146  void SetGlobalID(vtkTypeUInt32 guid);
147 
148  // Global-ID for this vtkSMRemoteObject. This is assigned when needed.
149  // Assigned at :
150  // - First push
151  // - or when the RemoteObject is created by the ProcessModule remotely.
152  // - or when state is loaded from protobuf messages
153  vtkTypeUInt32 GlobalID;
154 
155  // Location flag identify the processes on which the vtkSIObject
156  // corresponding to this vtkSMRemoteObject exist.
157  vtkTypeUInt32 Location;
158 
159  // Allow remote object to be discard for any state management such as
160  // Undo/Redo, Register/UnRegister (in ProxyManager) and so on...
161  bool Prototype;
162 
163  // Field that store the Disable/EnableLocalPushOnly() state information
165 
166  // Convenient method used to return either the local Location or a filtered
167  // version of it based on the ClientOnlyLocationFlag
168  vtkTypeUInt32 GetFilteredLocation();
169 
170 private:
171  vtkSMRemoteObject(const vtkSMRemoteObject&) = delete;
172  void operator=(const vtkSMRemoteObject&) = delete;
173 
174  char* GlobalIDString;
175 };
176 
190 class VTKREMOTINGSERVERMANAGER_EXPORT SIOBJECT
191 {
192  vtkSMRemoteObject* Reference;
193  friend VTKREMOTINGSERVERMANAGER_EXPORT vtkClientServerStream& operator<<(
194  vtkClientServerStream& stream, const SIOBJECT& manipulator);
195 
196 public:
198  : Reference(rmobject)
199  {
200  }
201 };
202 
203 VTKREMOTINGSERVERMANAGER_EXPORT vtkClientServerStream& operator<<(
204  vtkClientServerStream& stream, const SIOBJECT& manipulator);
205 
206 #endif // #ifndef vtkSMRemoteObject_h
vtkSMRemoteObject::IsPrototype
bool IsPrototype()
Allow user to set the remote object to be discard for Undo/Redo action.
Definition: vtkSMRemoteObject.h:71
vtkSMRemoteObject::LoadState
virtual void LoadState(const vtkSMMessage *msg, vtkSMProxyLocator *locator)
This method is used to initialise the object to the given state If the definitionOnly Flag is set to ...
Definition: vtkSMRemoteObject.h:91
vtkSMRemoteObject::ClientOnlyLocationFlag
bool ClientOnlyLocationFlag
Definition: vtkSMRemoteObject.h:164
vtkSMSessionObject::SetSession
virtual void SetSession(vtkSMSession *)
Get/Set the session on wihch this object exists.
vtkClientServerStream
Store messages for the interpreter.
Definition: vtkClientServerStream.h:23
vtkSMSessionObject.h
vtkSMRemoteObject::GlobalID
vtkTypeUInt32 GlobalID
Definition: vtkSMRemoteObject.h:153
SIOBJECT::SIOBJECT
SIOBJECT(vtkSMRemoteObject *rmobject)
Definition: vtkSMRemoteObject.h:197
vtkSMSession
Definition: vtkSMSession.h:22
vtkSMRemoteObject
baseclass for all proxy-objects that have counter parts on server as well as client processes.
Definition: vtkSMRemoteObject.h:25
vtkIndent
vtkSMMessage
vtkWeakPointer.h
vtkSMSessionObject
superclass for any server manager classes that are related to a session
Definition: vtkSMSessionObject.h:21
vtkSMRemoteObject::IsLocalPushOnly
virtual bool IsLocalPushOnly()
Let the session be aware that even if the Location is client only, the message should not be send to ...
Definition: vtkSMRemoteObject.h:117
vtkSMStateLoader
Utility class to load state from XML.
Definition: vtkSMStateLoader.h:28
operator<<
VTKREMOTINGSERVERMANAGER_EXPORT vtkClientServerStream & operator<<(vtkClientServerStream &stream, const SIOBJECT &manipulator)
vtkSMRemoteObject::Prototype
bool Prototype
Definition: vtkSMRemoteObject.h:161
vtkSMProxyLocator
is used to locate proxies referred to in state xmls while loading state files.
Definition: vtkSMProxyLocator.h:24
vtkSMRemoteObject::GetFullState
virtual const vtkSMMessage * GetFullState()
This method return the full object state that can be used to create that object from scratch.
Definition: vtkSMRemoteObject.h:81
vtkSMRemoteObject::Location
vtkTypeUInt32 Location
Definition: vtkSMRemoteObject.h:157
SIOBJECT
This defines a manipulator for the vtkClientServerStream that can be used to indicate to the interpre...
Definition: vtkSMRemoteObject.h:190
vtkSMSessionObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
vtkSMMessageMinimal.h