Allolib  1.0
C++ Components For Interactive Multimedia
al_NodeConfiguration.hpp
1 #ifndef INCLUDE_AL_NODECONFIGURATION
2 #define INCLUDE_AL_NODECONFIGURATION
3 
4 #include <cinttypes>
5 #include <iostream>
6 
7 namespace al {
8 
9 // TODO flow parameters
10 typedef enum {
11  CAP_NONE = 0,
12  CAP_SIMULATOR = 1 << 1,
13  CAP_RENDERING = 1 << 2,
14  CAP_OMNIRENDERING = 1 << 3,
15  CAP_AUDIO_IO = 1 << 4,
16  CAP_OSC = 1 << 5,
17  CAP_CONSOLE_IO = 1 << 6,
18  CAP_2DGUI = 1 << 7,
19  CAP_STATE_SEND = 1 << 8,
20  CAP_USER = 1 << 10
21  // User defined capabilities can add from here through bitshifting
22 } Capability;
23 
29  uint16_t rank{0};
30  uint16_t group{0};
31 
32  std::string dataRoot;
33 
34  Capability mCapabilites{CAP_NONE};
35 
36  bool hasCapability(Capability cap) { return cap & mCapabilites; }
37  bool isPrimary() { return rank == 0; }
38 
39  void setRole(std::string role) {
40  if (role == "desktop") {
41  mCapabilites =
42  (Capability)(CAP_SIMULATOR | CAP_STATE_SEND | CAP_RENDERING |
43  CAP_AUDIO_IO | CAP_OSC | CAP_2DGUI);
44  } else if (role == "renderer") {
45  mCapabilites = (Capability)(CAP_SIMULATOR | CAP_OMNIRENDERING | CAP_OSC);
46  } else if (role == "audio") {
47  mCapabilites =
48  (Capability)(CAP_SIMULATOR | CAP_AUDIO_IO | CAP_CONSOLE_IO | CAP_OSC);
49  } else if (role == "simulator") {
50  mCapabilites = (Capability)(CAP_SIMULATOR | CAP_STATE_SEND |
51  CAP_CONSOLE_IO | CAP_OSC);
52  } else if (role == "replica") {
53  mCapabilites = (Capability)(CAP_SIMULATOR | CAP_OMNIRENDERING |
54  CAP_AUDIO_IO | CAP_OSC);
55  } else if (role == "control") {
56  mCapabilites = (Capability)(CAP_RENDERING | CAP_OSC | CAP_2DGUI);
57  } else {
58  std::cerr << "WARNING: Setting no capabilities for this app from "
59  "config file"
60  << std::endl;
61  }
62  }
63 };
64 
65 } // namespace al
66 
67 #endif // INCLUDE_AL_NODECONFIGURATION
Definition: al_App.hpp:23
The NodeConfiguration struct describes a distributed node and its capabilities.