-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtkZeqManager.h
141 lines (107 loc) · 3.52 KB
/
vtkZeqManager.h
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
/*=========================================================================
Project : pv-zeq
Module : vtkZeqManager.h
Authors:
John Biddiscombe
=========================================================================*/
// .NAME vtkZeqManager - Zeq Convenience Manager Class
// .SECTION Description
#ifndef __vtkZeqManager_h
#define __vtkZeqManager_h
#include "vtkObject.h"
#include "vtkSmartPointer.h" // for smartpointers
#include <lunchbox/servus.h>
#include <lunchbox/rng.h>
#include <zeq/zeq.h>
#include <zeq/hbp/hbp.h>
#include <boost/lexical_cast.hpp>
typedef boost::shared_ptr< zeq::Subscriber > SubscriberPtr;
typedef std::vector< SubscriberPtr > Subscribers;
class vtkMultiProcessController;
#include "vtkUnsignedIntArray.h"
//BTX
//ETX
#define VTK_ZEQ_MANAGER_DEFAULT_NOTIFICATION_PORT 11112
#define VTK_ZEQ_NOTIFICATION_CONNECTED 0
#define VTK_ZEQ_NOTIFICATION_EVENT 1
// So far this class is a placeholder and does not perform any function
class VTK_EXPORT vtkZeqManager : public vtkObject
{
public:
//BTX
struct vtkZeqManagerInternals;
vtkZeqManagerInternals *ZeqManagerInternals;
typedef std::function<void (const zeq::Event&)> zeq_callback;
//ETX
struct event_data {
zeq::uint128_t Type;
size_t Size;
};
static vtkZeqManager *New();
vtkTypeMacro(vtkZeqManager,vtkObject);
void Start();
// Description:
// Set/Get the controller use in compositing (set to
// the global controller by default)
// If not using the default, this must be called before any
// other methods.
virtual void SetController(vtkMultiProcessController* controller);
vtkGetObjectMacro(Controller, vtkMultiProcessController);
void *NotificationThread();
// Description:
// Signal/Wait for the pipeline update to be finished (only valid when
// a new notification has been received)
virtual void SignalUpdated();
virtual void WaitForUpdated();
// Description:
// Set the Xdmf description file.
vtkGetStringMacro(HostsDescription);
vtkSetStringMacro(HostsDescription);
vtkSetMacro(ClientSideMode,int);
vtkGetMacro(ClientSideMode,int);
vtkBooleanMacro(ClientSideMode,int);
void SetSelectionCallback(zeq_callback cb);
void SetCameraCallback(zeq_callback cb);
void SetSpikeCallback(zeq_callback cb);
protected:
vtkZeqManager();
~vtkZeqManager();
void onHBPCamera( const zeq::Event& event );
void onSelectedIds( const zeq::Event& event );
void onSpike( const zeq::Event& event );
int Create();
void Discover();
int CreateNotificationSocket();
uint16_t _port;
std::string _servicename;
servus::Servus _service;
servus::Strings _hosts;
zeq::Subscriber *_subscriber_hbp;
zeq::Subscriber *_subscriber_monsteer;
//
// Zeq manager variables
//
static vtkZeqManager *ZeqManagerSingleton;
// Description:
// Wait for a notification - notifications are used to trigger user
// defined tasks and are sent when the file has been unlocked
virtual int WaitForUnlock(const void *flag);
//
// Internal Variables
//
int UpdatePiece;
int UpdateNumPieces;
int abort_poll;
int thread_done;
int ClientSideMode;
zeq_callback SelectionCallback;
zeq_callback CameraCallback;
zeq_callback SpikeCallback;
vtkMultiProcessController *Controller;
char *HostsDescription;
private:
vtkZeqManager(const vtkZeqManager&); // Not implemented.
void operator=(const vtkZeqManager&); // Not implemented.
};
#endif