Skip to content

Commit 6667770

Browse files
committed
Replace MAX_ARRAY_SIZE with DMX_MAX_PORTS guards
Replace the intermediate MAX_ARRAY_SIZE macro with direct use of DMX_MAX_PORTS and DMXNODE_OUTPUT_DMX guards across artnet, e131, dmxnode, displayudf, remoteconfig, and showfile libraries. Also removes debug logging from parameter setters, renames store_dmxnode_ to store_dmxnode, uses MakeSimpleKey() helpers, and applies consistent code formatting (brace style, constexpr qualifiers).
1 parent 312e51e commit 6667770

29 files changed

Lines changed: 509 additions & 659 deletions

lib-artnet/include/json/artnetparams.h

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
#include "json/artnetparamsconst.h"
1111
#include "json/json_key.h"
1212
#include "json/json_params_base.h"
13-
14-
#if !defined (MAX_ARRAY_SIZE)
15-
#error
13+
#include "dmxnode_outputtype.h"
14+
#if defined(DMXNODE_OUTPUT_DMX)
15+
#include "dmx.h"
1616
#endif
1717

18-
namespace json
19-
{
20-
class ArtNetParams : public JsonParamsBase<ArtNetParams>
21-
{
18+
namespace json {
19+
class ArtNetParams : public JsonParamsBase<ArtNetParams> {
2220
public:
2321
ArtNetParams();
2422

@@ -43,32 +41,44 @@ class ArtNetParams : public JsonParamsBase<ArtNetParams>
4341
static void SetRdmEnablePort(const char* key, uint32_t key_len, const char* val, uint32_t val_len);
4442

4543
static constexpr json::Key kArtNetKeys[] = {
46-
MakeKey(SetEnableRdm, ArtNetParamsConst::kEnableRdm),
4744
MakeKey(SetMapUniverse0, ArtNetParamsConst::kMapUniverse0),
45+
#if defined(RDM_CONTROLLER) || defined(RDM_RESPONDER)
46+
MakeKey(SetEnableRdm, ArtNetParamsConst::kEnableRdm),
47+
#if defined(DMX_MAX_PORTS)
48+
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[0]),
49+
#if (DMX_MAX_PORTS > 1)
50+
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[1]),
51+
#endif
52+
#if (DMX_MAX_PORTS > 2)
53+
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[2]),
54+
#endif
55+
#if (DMX_MAX_PORTS == 4)
56+
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[3]),
57+
#endif
58+
#endif
59+
#endif
60+
#if defined(DMX_MAX_PORTS)
4861
MakeKey(SetDestinationIpPort, ArtNetParamsConst::kDestinationIpPort[0]),
4962
MakeKey(SetProtocolPort, ArtNetParamsConst::kProtocolPort[0]),
50-
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[0]),
51-
#if (MAX_ARRAY_SIZE > 1)
63+
#if (DMX_MAX_PORTS > 1)
5264
MakeKey(SetDestinationIpPort, ArtNetParamsConst::kDestinationIpPort[1]),
5365
MakeKey(SetProtocolPort, ArtNetParamsConst::kProtocolPort[1]),
54-
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[1]),
5566
#endif
56-
#if (MAX_ARRAY_SIZE > 2)
67+
#if (DMX_MAX_PORTS > 2)
5768
MakeKey(SetDestinationIpPort, ArtNetParamsConst::kDestinationIpPort[2]),
5869
MakeKey(SetProtocolPort, ArtNetParamsConst::kProtocolPort[2]),
59-
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[2]),
6070
#endif
61-
#if (MAX_ARRAY_SIZE == 4)
71+
#if (DMX_MAX_PORTS == 4)
6272
MakeKey(SetDestinationIpPort, ArtNetParamsConst::kDestinationIpPort[3]),
6373
MakeKey(SetProtocolPort, ArtNetParamsConst::kProtocolPort[3]),
64-
MakeKey(SetRdmEnablePort, ArtNetParamsConst::kRdmEnablePort[3]),
74+
#endif
6575
#endif
6676
};
6777

68-
inline static common::store::DmxNode store_dmxnode_;
78+
inline static common::store::DmxNode store_dmxnode;
6979

7080
friend class JsonParamsBase<ArtNetParams>;
7181
};
7282
} // namespace json
7383

74-
#endif // JSON_ARTNETPARAMS_H_
84+
#endif // JSON_ARTNETPARAMS_H_

lib-artnet/include/json/artnetparamsconst.h

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -26,125 +26,118 @@
2626
#define JSON_ARTNETPARAMSCONST_H_
2727

2828
#include "common/utils/utils_hash.h"
29-
#include "configurationstore.h"
3029
#include "json/json_key.h"
31-
#include "common/utils/utils_hash.h"
32-
33-
#undef MAX_ARRAY_SIZE
30+
#include "dmxnode_outputtype.h"
3431
#if defined(DMXNODE_OUTPUT_DMX)
3532
#include "dmx.h"
36-
#define MAX_ARRAY_SIZE DMX_MAX_PORTS
37-
#else
38-
#define MAX_ARRAY_SIZE 4
3933
#endif
4034

41-
static_assert(MAX_ARRAY_SIZE <= common::store::dmxnode::kParamPorts);
42-
43-
namespace json
44-
{
35+
namespace json {
4536
struct ArtNetParamsConst {
4637
static constexpr char kFileName[] = "artnet.json";
38+
static constexpr auto kMapUniverse0 = json::MakeSimpleKey("map_universe0");
39+
40+
#if defined(RDM_CONTROLLER) || defined(RDM_RESPONDER)
41+
static constexpr auto kEnableRdm = json::MakeSimpleKey("enable_rdm");
42+
43+
static constexpr json::PortKey kRdmEnablePortA{"rdm_enable_port_a", 17, Fnv1a32("rdm_enable_port_a", 17)};
44+
#if (DMX_MAX_PORTS > 1)
45+
static constexpr json::PortKey kRdmEnablePortB{"rdm_enable_port_b", 17, Fnv1a32("rdm_enable_port_b", 17)};
46+
#endif
47+
#if (DMX_MAX_PORTS > 2)
48+
static constexpr json::PortKey kRdmEnablePortC{"rdm_enable_port_c", 17, Fnv1a32("rdm_enable_port_c", 17)};
49+
#endif
50+
#if (DMX_MAX_PORTS == 4)
51+
static constexpr json::PortKey kRdmEnablePortD{"rdm_enable_port_d", 17, Fnv1a32("rdm_enable_port_d", 17)};
52+
#endif
53+
54+
static constexpr json::PortKey kRdmEnablePort[] = {
55+
kRdmEnablePortA,
56+
#if (DMX_MAX_PORTS > 1)
57+
kRdmEnablePortB,
58+
#endif
59+
#if (DMX_MAX_PORTS > 2)
60+
kRdmEnablePortC,
61+
#endif
62+
#if (DMX_MAX_PORTS == 4)
63+
kRdmEnablePortD,
64+
#endif
65+
};
66+
#endif
4767

68+
#if defined(DMX_MAX_PORTS)
4869
static constexpr json::PortKey kDestinationIpPortA{"destination_ip_port_a", 21, Fnv1a32("destination_ip_port_a", 21)};
49-
#if (MAX_ARRAY_SIZE > 1)
70+
#if (DMX_MAX_PORTS > 1)
5071
static constexpr json::PortKey kDestinationIpPortB{"destination_ip_port_b", 21, Fnv1a32("destination_ip_port_b", 21)};
5172
#endif
52-
#if (MAX_ARRAY_SIZE > 2)
73+
#if (DMX_MAX_PORTS > 2)
5374
static constexpr json::PortKey kDestinationIpPortC{"destination_ip_port_c", 21, Fnv1a32("destination_ip_port_c", 21)};
5475
#endif
55-
#if (MAX_ARRAY_SIZE == 4)
76+
#if (DMX_MAX_PORTS == 4)
5677
static constexpr json::PortKey kDestinationIpPortD{"destination_ip_port_d", 21, Fnv1a32("destination_ip_port_d", 21)};
5778
#endif
5879

5980
static constexpr json::PortKey kDestinationIpPort[] = {
6081
kDestinationIpPortA,
61-
#if (MAX_ARRAY_SIZE > 1)
82+
#if (DMX_MAX_PORTS > 1)
6283
kDestinationIpPortB,
6384
#endif
64-
#if (MAX_ARRAY_SIZE > 2)
85+
#if (DMX_MAX_PORTS > 2)
6586
kDestinationIpPortC,
6687
#endif
67-
#if (MAX_ARRAY_SIZE == 4)
88+
#if (DMX_MAX_PORTS == 4)
6889
kDestinationIpPortD,
6990
#endif
7091
};
7192

72-
// Art-Net 4
73-
static constexpr auto kEnableRdm = json::MakeSimpleKey("enable_rdm");
74-
75-
static constexpr auto kMapUniverse0 = json::MakeSimpleKey("map_universe0");
76-
7793
static constexpr json::PortKey kProtocolPortA{"protocol_port_a", 15, Fnv1a32("protocol_port_a", 15)};
78-
#if (MAX_ARRAY_SIZE > 1)
94+
#if (DMX_MAX_PORTS > 1)
7995
static constexpr json::PortKey kProtocolPortB{"protocol_port_b", 15, Fnv1a32("protocol_port_b", 15)};
8096
#endif
81-
#if (MAX_ARRAY_SIZE > 2)
97+
#if (DMX_MAX_PORTS > 2)
8298
static constexpr json::PortKey kProtocolPortC{"protocol_port_c", 15, Fnv1a32("protocol_port_c", 15)};
8399
#endif
84-
#if (MAX_ARRAY_SIZE == 4)
100+
#if (DMX_MAX_PORTS == 4)
85101
static constexpr json::PortKey kProtocolPortD{"protocol_port_d", 15, Fnv1a32("protocol_port_d", 15)};
86102
#endif
87103

88104
static constexpr json::PortKey kProtocolPort[] = {
89105
kProtocolPortA,
90-
#if (MAX_ARRAY_SIZE > 1)
106+
#if (DMX_MAX_PORTS > 1)
91107
kProtocolPortB,
92108
#endif
93-
#if (MAX_ARRAY_SIZE > 2)
109+
#if (DMX_MAX_PORTS > 2)
94110
kProtocolPortC,
95111
#endif
96-
#if (MAX_ARRAY_SIZE == 4)
112+
#if (DMX_MAX_PORTS == 4)
97113
kProtocolPortD,
98114
#endif
99115
};
100116

101-
static constexpr json::PortKey kRdmEnablePortA{"rdm_enable_port_a", 17, Fnv1a32("rdm_enable_port_a", 17)};
102-
#if (MAX_ARRAY_SIZE > 1)
103-
static constexpr json::PortKey kRdmEnablePortB{"rdm_enable_port_b", 17, Fnv1a32("rdm_enable_port_b", 17)};
104-
#endif
105-
#if (MAX_ARRAY_SIZE > 2)
106-
static constexpr json::PortKey kRdmEnablePortC{"rdm_enable_port_c", 17, Fnv1a32("rdm_enable_port_c", 17)};
107-
#endif
108-
#if (MAX_ARRAY_SIZE == 4)
109-
static constexpr json::PortKey kRdmEnablePortD{"rdm_enable_port_d", 17, Fnv1a32("rdm_enable_port_d", 17)};
110-
#endif
111-
112-
static constexpr json::PortKey kRdmEnablePort[] = {
113-
kRdmEnablePortA,
114-
#if (MAX_ARRAY_SIZE > 1)
115-
kRdmEnablePortB,
116-
#endif
117-
#if (MAX_ARRAY_SIZE > 2)
118-
kRdmEnablePortC,
119-
#endif
120-
#if (MAX_ARRAY_SIZE == 4)
121-
kRdmEnablePortD,
122-
#endif
123-
};
124-
125117
static constexpr json::PortKey kBgDiscoveryPortA{"bg_discovery_port_a", 19, Fnv1a32("bg_discovery_port_a", 19)};
126-
#if (MAX_ARRAY_SIZE > 1)
118+
#if (DMX_MAX_PORTS > 1)
127119
static constexpr json::PortKey kBgDiscoveryPortB{"bg_discovery_port_b", 19, Fnv1a32("bg_discovery_port_b", 19)};
128120
#endif
129-
#if (MAX_ARRAY_SIZE > 2)
121+
#if (DMX_MAX_PORTS > 2)
130122
static constexpr json::PortKey kBgDiscoveryPortC{"bg_discovery_port_c", 19, Fnv1a32("bg_discovery_port_c", 19)};
131123
#endif
132-
#if (MAX_ARRAY_SIZE == 4)
124+
#if (DMX_MAX_PORTS == 4)
133125
static constexpr json::PortKey kBgDiscoveryPortD{"bg_discovery_port_d", 19, Fnv1a32("bg_discovery_port_d", 19)};
134126
#endif
135127

136128
static constexpr json::PortKey kBgDiscoveryPort[] = {
137129
kBgDiscoveryPortA,
138-
#if (MAX_ARRAY_SIZE > 1)
130+
#if (DMX_MAX_PORTS > 1)
139131
kBgDiscoveryPortB,
140132
#endif
141-
#if (MAX_ARRAY_SIZE > 2)
133+
#if (DMX_MAX_PORTS > 2)
142134
kBgDiscoveryPortC,
143135
#endif
144-
#if (MAX_ARRAY_SIZE == 4)
136+
#if (DMX_MAX_PORTS == 4)
145137
kBgDiscoveryPortD,
146138
#endif
147139
};
140+
#endif
148141
};
149142
} // namespace json
150143

0 commit comments

Comments
 (0)