File: vtkSMCollaborationManager.h

package info (click to toggle)
paraview 5.4.1%2Bdfsg4-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 218,616 kB
  • sloc: cpp: 2,331,508; ansic: 322,365; python: 111,051; xml: 79,203; tcl: 47,013; yacc: 4,877; java: 4,438; perl: 3,238; sh: 2,920; lex: 1,908; f90: 748; makefile: 273; pascal: 228; objc: 83; fortran: 31
file content (183 lines) | stat: -rw-r--r-- 5,234 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*=========================================================================

  Program:   ParaView
  Module:    vtkSMCollaborationManager.h

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/**
 * @class   vtkSMCollaborationManager
 * @brief   Class used to broadcast message from
 * one client to the others.
 *
 * This class allow to trigger protobuf messages on all the clients that are
 * connected to the server. Those clients can attach listeners and
 * handle those message in the way they want.
 * The message sender do not receive its message again, only other clients do.
 *
 * To listen collaboration notification messages you should have a code
 * that look like that:
 *
 * collaborationManager->AddObserver(
 *          vtkSMCollaborationManager::CollaborationNotification,
 *          callback);
 *
 * void callback(vtkObject* src, unsigned long event, void* method, void* data)
 * {
 *   vtkSMMessage* msg = reinterpret_cast<vtkSMMessage*>(data);
 *   => do what you want with the message
 * }
*/

#ifndef vtkSMCollaborationManager_h
#define vtkSMCollaborationManager_h

#include "vtkPVServerManagerCoreModule.h" //needed for exports
#include "vtkSMMessageMinimal.h"          // needed for vtkSMMessage
#include "vtkSMRemoteObject.h"

class vtkSMProxyLocator;

class VTKPVSERVERMANAGERCORE_EXPORT vtkSMCollaborationManager : public vtkSMRemoteObject
{
public:
  /**
   * Return the GlobalID that should be used to refer to the TimeKeeper
   */
  static vtkTypeUInt32 GetReservedGlobalID();

  static vtkSMCollaborationManager* New();
  vtkTypeMacro(vtkSMCollaborationManager, vtkSMRemoteObject);
  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;

  /**
   * Get the global unique id for this object. If none is set and the session is
   * valid, a new global id will be assigned automatically.
   */
  virtual vtkTypeUInt32 GetGlobalID() VTK_OVERRIDE;

  /**
   * Override the session setting in order to update only once our current
   * local user id
   */
  virtual void SetSession(vtkSMSession*) VTK_OVERRIDE;

  /**
   * This method is used promote a new Master user. Master/Slave user doesn't
   * buy you anything here. It just provide you the information, and it is your
   * call to prevent slaves users to do or achieve some actions inside your client.
   * When you call that method a SMMessage is also propagated to the other client
   * so they could follow who is the Master without fetching the information again.
   */
  virtual void PromoteToMaster(int clientId);

  /**
   * Share the decision that user should follow that given user if master or
   * follow someone else on your own
   */
  virtual void FollowUser(int clientId);

  /**
   * Return the local followed user
   */
  int GetFollowedUser();

  /**
   * Return true if the current client is the master
   */
  virtual bool IsMaster();

  /**
   * Return the userId of the current master
   */
  virtual int GetMasterId();

  /**
   * Return the id of the current client
   */
  virtual int GetUserId();

  /**
   * Return the id of the nth connected client.
   * In the list you will find yourself as well.
   */
  virtual int GetUserId(int index);

  /**
   * return the name of the provided userId
   */
  virtual const char* GetUserLabel(int userID);

  /**
   * Update ou local user name
   */
  virtual void SetUserLabel(const char* userName);

  /**
   * Update any user name
   */
  virtual void SetUserLabel(int userId, const char* userName);

  /**
   * return the number of currently connected clients. This size is used to bound
   * the GetUserId() method.
   */
  virtual int GetNumberOfConnectedClients();

  /**
   * Request an update of the user list from the server. (A pull request is done)
   */
  void UpdateUserInformations();

  enum EventType
  {
    CollaborationNotification = 12345,
    UpdateUserName = 12346,
    UpdateUserList = 12347,
    UpdateMasterUser = 12348,
    FollowUserCamera = 12349,
    CameraChanged = 12350
  };

  /**
   * Send message to other clients which will trigger Observer
   */
  void SendToOtherClients(vtkSMMessage* msg);

  /**
   * This method return the state of the connected clients
   */
  virtual const vtkSMMessage* GetFullState() VTK_OVERRIDE;

  /**
   * This method is used to either load its internal connected clients
   * informations or to forward messages across clients
   */
  virtual void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator) VTK_OVERRIDE;

protected:
  /**
   * Default constructor.
   */
  vtkSMCollaborationManager();

  /**
   * Destructor.
   */
  virtual ~vtkSMCollaborationManager();

private:
  class vtkInternal;
  vtkInternal* Internal;

  vtkSMCollaborationManager(const vtkSMCollaborationManager&) VTK_DELETE_FUNCTION;
  void operator=(const vtkSMCollaborationManager&) VTK_DELETE_FUNCTION;
};
#endif // #ifndef vtkSMCollaborationManager_h