ISAAC
Overview :: Library Doc :: Server Doc :: JSON Commands

In Situ Animation of Accelerated Computations

Broker.hpp
Go to the documentation of this file.
1 /* This file is part of ISAAC.
2  *
3  * ISAAC is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * ISAAC is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with ISAAC. If not, see <www.gnu.org/licenses/>. */
15 
16 #ifndef __BROKER
17 #define __BROKER
18 
19 #include <string>
20 #include <vector>
21 #include "Common.hpp"
22 #include "MetaDataConnector.hpp"
23 class MetaDataConnector;
24 
25 #include "ImageConnector.hpp"
26 class ImageConnector;
27 
28 #include <signal.h>
29 #include "MetaDataClient.hpp"
31 #include <memory>
32 #include <map>
33 
35 {
37  pthread_t thread;
39 
41 {
43  pthread_t thread;
45 
46 #define MAX_NODES 999999
47 
49 {
50  friend class Broker;
51  public:
52  InsituConnectorGroup(std::string name) :
53  master( NULL ),
54  initData( NULL ),
55  id( 0 ),
56  name( name),
57  nodes( MAX_NODES ),
58  video_buffer_size( 0 )
59  {
60  pthread_mutex_init (&streams_mutex, NULL);
61  }
62  int getID()
63  {
64  return id;
65  }
67  {
68  return video_buffer_size;
69  }
71  {
72  return framebuffer_width;
73  }
75  {
76  return framebuffer_height;
77  }
78  std::string getName()
79  {
80  return name;
81  }
83  {
84  pthread_mutex_destroy(&streams_mutex);
85  }
86  private:
88  int nodes;
89  std::string name;
90  json_t* initData;
91  int id;
92  int framebuffer_width;
93  int framebuffer_height;
94  size_t video_buffer_size;
95  std::map< std::string, std::map< void* , std::string > > streams;
96  pthread_mutex_t streams_mutex;
97 };
98 
99 class Broker
100 {
101  public:
102  Broker(std::string name,int inner_port,std::string interface);
103  ~Broker();
104  errorCode addDataConnector(MetaDataConnector *dataConnector);
105  errorCode addImageConnector(ImageConnector *imageConnector);
106  MetaDataClient* addDataClient();
107  void receiveVideo(InsituConnectorGroup* group,uint8_t* video_buffer,char* payload);
108  errorCode run();
109  std::string getStream(std::string connector,std::string name,std::string ref);
110  static volatile sig_atomic_t force_exit;
111  private:
112  InsituConnectorMaster insituMaster;
113  json_t* masterHello;
114  json_t* masterHelloConnectorList;
115  std::string name;
116  std::vector< MetaDataConnectorContainer > dataConnectorList;
117  std::vector< ImageConnectorContainer > imageConnectorList;
118  ThreadList< InsituConnectorGroup* > insituConnectorGroupList;
119  ThreadList< MetaDataClient* > dataClientList;
120  int inner_port;
121  std::string inner_interface;
122  pthread_t insituThread;
123 };
124 
125 #endif
#define MAX_NODES
Definition: Broker.hpp:46
std::string getName()
Definition: Broker.hpp:78
int getVideoBufferSize()
Definition: Broker.hpp:66
struct ImageConnectorContainer_struct ImageConnectorContainer
static volatile sig_atomic_t force_exit
Definition: Broker.hpp:110
InsituConnectorGroup(std::string name)
Definition: Broker.hpp:52
int errorCode
Definition: Common.hpp:24
struct MetaDataConnectorContainer_struct MetaDataConnectorContainer
int getFramebufferHeight()
Definition: Broker.hpp:74
MetaDataConnector * connector
Definition: Broker.hpp:36
ImageConnector * connector
Definition: Broker.hpp:42
int getFramebufferWidth()
Definition: Broker.hpp:70