Skip to content

Commit 56293ae

Browse files
committed
Avoid some extraneous structs
1 parent 7532541 commit 56293ae

12 files changed

Lines changed: 83 additions & 118 deletions

File tree

al/eax/effect.h

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct EaxReverbCommitter {
116116
static void translate(const EAX20LISTENERPROPERTIES& src, EAXREVERBPROPERTIES& dst) noexcept;
117117
};
118118

119-
template<typename T>
119+
template<typename P>
120120
struct EaxCommitter {
121121
struct Exception;
122122

@@ -131,46 +131,35 @@ struct EaxCommitter {
131131
property = value;
132132
}
133133

134-
[[noreturn]] static void fail(const std::string_view message);
134+
[[noreturn]] static void fail(std::string_view message);
135135
[[noreturn]] static void fail_unknown_property_id()
136136
{ fail(EaxEffectErrorMessages::unknown_property_id()); }
137137

138-
private:
139138
EaxCommitter(EaxEffectProps &eaxprops, EffectProps &alprops)
140139
: mEaxProps{eaxprops}, mAlProps{alprops}
141140
{ }
142141

143-
friend T;
144-
};
142+
[[nodiscard]] auto commit(const P &props) const -> bool;
145143

146-
#define DECL_COMMITTER(T, P) struct T : EaxCommitter<T> { \
147-
T(EaxEffectProps &eaxprops, EffectProps &alprops) \
148-
: EaxCommitter{eaxprops, alprops} \
149-
{ } \
150-
\
151-
[[nodiscard]] auto commit(const P &props) const -> bool; \
152-
\
153-
static void SetDefaults(EaxEffectProps &props); \
154-
static void Get(const EaxCall &call, const P &props); \
155-
static void Set(const EaxCall &call, P &props); \
144+
static void SetDefaults(EaxEffectProps &props);
145+
static void Get(const EaxCall &call, const P &props);
146+
static void Set(const EaxCall &call, P &props);
156147
};
157-
DECL_COMMITTER(EaxAutowahCommitter, EAXAUTOWAHPROPERTIES)
158-
DECL_COMMITTER(EaxChorusCommitter, EAXCHORUSPROPERTIES)
159-
DECL_COMMITTER(EaxCompressorCommitter, EAXAGCCOMPRESSORPROPERTIES)
160-
DECL_COMMITTER(EaxDistortionCommitter, EAXDISTORTIONPROPERTIES)
161-
DECL_COMMITTER(EaxEchoCommitter, EAXECHOPROPERTIES)
162-
DECL_COMMITTER(EaxEqualizerCommitter, EAXEQUALIZERPROPERTIES)
163-
DECL_COMMITTER(EaxFlangerCommitter, EAXFLANGERPROPERTIES)
164-
DECL_COMMITTER(EaxFrequencyShifterCommitter, EAXFREQUENCYSHIFTERPROPERTIES)
165-
DECL_COMMITTER(EaxModulatorCommitter, EAXRINGMODULATORPROPERTIES)
166-
DECL_COMMITTER(EaxPitchShifterCommitter, EAXPITCHSHIFTERPROPERTIES)
167-
DECL_COMMITTER(EaxVocalMorpherCommitter, EAXVOCALMORPHERPROPERTIES)
168-
DECL_COMMITTER(EaxNullCommitter, std::monostate)
169-
#undef DECL_COMMITTER
170-
171-
template<typename T>
172-
struct CommitterFromProps { };
173148

149+
using EaxAutowahCommitter = EaxCommitter<EAXAUTOWAHPROPERTIES>;
150+
using EaxChorusCommitter = EaxCommitter<EAXCHORUSPROPERTIES>;
151+
using EaxCompressorCommitter = EaxCommitter<EAXAGCCOMPRESSORPROPERTIES>;
152+
using EaxDistortionCommitter = EaxCommitter<EAXDISTORTIONPROPERTIES>;
153+
using EaxEchoCommitter = EaxCommitter<EAXECHOPROPERTIES>;
154+
using EaxEqualizerCommitter = EaxCommitter<EAXEQUALIZERPROPERTIES>;
155+
using EaxFlangerCommitter = EaxCommitter<EAXFLANGERPROPERTIES>;
156+
using EaxFrequencyShifterCommitter = EaxCommitter<EAXFREQUENCYSHIFTERPROPERTIES>;
157+
using EaxModulatorCommitter = EaxCommitter<EAXRINGMODULATORPROPERTIES>;
158+
using EaxPitchShifterCommitter = EaxCommitter<EAXPITCHSHIFTERPROPERTIES>;
159+
using EaxVocalMorpherCommitter = EaxCommitter<EAXVOCALMORPHERPROPERTIES>;
160+
using EaxNullCommitter = EaxCommitter<std::monostate>;
161+
162+
template<typename> struct CommitterFromProps { };
174163
template<> struct CommitterFromProps<std::monostate> { using type = EaxNullCommitter; };
175164
template<> struct CommitterFromProps<EAXREVERBPROPERTIES> { using type = EaxReverbCommitter; };
176165
template<> struct CommitterFromProps<EAXCHORUSPROPERTIES> { using type = EaxChorusCommitter; };

al/effects/autowah.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,10 @@ void AutowahEffectHandler::GetParamfv(al::Context *context, const AutowahProps &
103103
#if ALSOFT_EAX
104104
namespace {
105105

106-
using AutowahCommitter = EaxCommitter<EaxAutowahCommitter>;
107-
108106
struct AttackTimeValidator {
109107
void operator()(float flAttackTime) const
110108
{
111-
eax_validate_range<AutowahCommitter::Exception>(
109+
eax_validate_range<EaxAutowahCommitter::Exception>(
112110
"Attack Time",
113111
flAttackTime,
114112
EAXAUTOWAH_MINATTACKTIME,
@@ -119,7 +117,7 @@ struct AttackTimeValidator {
119117
struct ReleaseTimeValidator {
120118
void operator()(float flReleaseTime) const
121119
{
122-
eax_validate_range<AutowahCommitter::Exception>(
120+
eax_validate_range<EaxAutowahCommitter::Exception>(
123121
"Release Time",
124122
flReleaseTime,
125123
EAXAUTOWAH_MINRELEASETIME,
@@ -130,7 +128,7 @@ struct ReleaseTimeValidator {
130128
struct ResonanceValidator {
131129
void operator()(eax_long const lResonance) const
132130
{
133-
eax_validate_range<AutowahCommitter::Exception>(
131+
eax_validate_range<EaxAutowahCommitter::Exception>(
134132
"Resonance",
135133
lResonance,
136134
EAXAUTOWAH_MINRESONANCE,
@@ -141,7 +139,7 @@ struct ResonanceValidator {
141139
struct PeakLevelValidator {
142140
void operator()(eax_long const lPeakLevel) const
143141
{
144-
eax_validate_range<AutowahCommitter::Exception>(
142+
eax_validate_range<EaxAutowahCommitter::Exception>(
145143
"Peak Level",
146144
lPeakLevel,
147145
EAXAUTOWAH_MINPEAKLEVEL,
@@ -162,13 +160,13 @@ struct AllValidator {
162160
} // namespace
163161

164162
template<> /* NOLINTNEXTLINE(clazy-copyable-polymorphic) Exceptions must be copyable. */
165-
struct AutowahCommitter::Exception final : EaxException {
163+
struct EaxAutowahCommitter::Exception final : EaxException {
166164
explicit Exception(const std::string_view message) : EaxException{"EAX_AUTOWAH_EFFECT", message}
167165
{ }
168166
};
169167

170168
template<> [[noreturn]]
171-
void AutowahCommitter::fail(const std::string_view message) { throw Exception{message}; }
169+
void EaxAutowahCommitter::fail(const std::string_view message) { throw Exception{message}; }
172170

173171
auto EaxAutowahCommitter::commit(const EAXAUTOWAHPROPERTIES &props) const -> bool
174172
{

al/effects/chorus.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,20 +525,16 @@ struct ChorusFlangerEffect {
525525
}
526526
}; // EaxChorusFlangerEffect
527527

528-
529-
using ChorusCommitter = EaxCommitter<EaxChorusCommitter>;
530-
using FlangerCommitter = EaxCommitter<EaxFlangerCommitter>;
531-
532528
} // namespace
533529

534530
template<> /* NOLINTNEXTLINE(clazy-copyable-polymorphic) Exceptions must be copyable. */
535-
struct ChorusCommitter::Exception final : EaxException {
531+
struct EaxChorusCommitter::Exception final : EaxException {
536532
explicit Exception(const std::string_view message) : EaxException{"EAX_CHORUS_EFFECT", message}
537533
{ }
538534
};
539535

540536
template<> [[noreturn]]
541-
void ChorusCommitter::fail(const std::string_view message)
537+
void EaxChorusCommitter::fail(const std::string_view message)
542538
{ throw Exception{message}; }
543539

544540
auto EaxChorusCommitter::commit(const EAXCHORUSPROPERTIES &props) const -> bool
@@ -566,13 +562,13 @@ void EaxChorusCommitter::Set(const EaxCall &call, EAXCHORUSPROPERTIES &props)
566562
}
567563

568564
template<> /* NOLINTNEXTLINE(clazy-copyable-polymorphic) Exceptions must be copyable. */
569-
struct FlangerCommitter::Exception final : EaxException {
565+
struct EaxFlangerCommitter::Exception final : EaxException {
570566
explicit Exception(const std::string_view message) : EaxException{"EAX_FLANGER_EFFECT",message}
571567
{ }
572568
};
573569

574570
template<> [[noreturn]]
575-
void FlangerCommitter::fail(const std::string_view message)
571+
void EaxFlangerCommitter::fail(const std::string_view message)
576572
{ throw Exception{message}; }
577573

578574
auto EaxFlangerCommitter::commit(const EAXFLANGERPROPERTIES &props) const -> bool

al/effects/compressor.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ void CompressorEffectHandler::GetParamfv(al::Context *context, const CompressorP
7373
#if ALSOFT_EAX
7474
namespace {
7575

76-
using CompressorCommitter = EaxCommitter<EaxCompressorCommitter>;
77-
7876
struct OnOffValidator {
7977
void operator()(eax_ulong const ulOnOff) const
8078
{
81-
eax_validate_range<CompressorCommitter::Exception>(
79+
eax_validate_range<EaxCompressorCommitter::Exception>(
8280
"On-Off",
8381
ulOnOff,
8482
EAXAGCCOMPRESSOR_MINONOFF,
@@ -96,13 +94,13 @@ struct AllValidator {
9694
} // namespace
9795

9896
template<> /* NOLINTNEXTLINE(clazy-copyable-polymorphic) Exceptions must be copyable. */
99-
struct CompressorCommitter::Exception final : EaxException {
97+
struct EaxCompressorCommitter::Exception final : EaxException {
10098
explicit Exception(const std::string_view message) : EaxException{"EAX_CHORUS_EFFECT", message}
10199
{ }
102100
};
103101

104102
template<> [[noreturn]]
105-
void CompressorCommitter::fail(const std::string_view message)
103+
void EaxCompressorCommitter::fail(const std::string_view message)
106104
{ throw Exception{message}; }
107105

108106
auto EaxCompressorCommitter::commit(const EAXAGCCOMPRESSORPROPERTIES &props) const -> bool

al/effects/distortion.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,10 @@ void DistortionEffectHandler::GetParamfv(al::Context *context, const DistortionP
109109
#if ALSOFT_EAX
110110
namespace {
111111

112-
using DistortionCommitter = EaxCommitter<EaxDistortionCommitter>;
113-
114112
struct EdgeValidator {
115113
void operator()(float const flEdge) const
116114
{
117-
eax_validate_range<DistortionCommitter::Exception>(
115+
eax_validate_range<EaxDistortionCommitter::Exception>(
118116
"Edge",
119117
flEdge,
120118
EAXDISTORTION_MINEDGE,
@@ -125,7 +123,7 @@ struct EdgeValidator {
125123
struct GainValidator {
126124
void operator()(eax_long const lGain) const
127125
{
128-
eax_validate_range<DistortionCommitter::Exception>(
126+
eax_validate_range<EaxDistortionCommitter::Exception>(
129127
"Gain",
130128
lGain,
131129
EAXDISTORTION_MINGAIN,
@@ -136,7 +134,7 @@ struct GainValidator {
136134
struct LowPassCutOffValidator {
137135
void operator()(float const flLowPassCutOff) const
138136
{
139-
eax_validate_range<DistortionCommitter::Exception>(
137+
eax_validate_range<EaxDistortionCommitter::Exception>(
140138
"Low-pass Cut-off",
141139
flLowPassCutOff,
142140
EAXDISTORTION_MINLOWPASSCUTOFF,
@@ -147,7 +145,7 @@ struct LowPassCutOffValidator {
147145
struct EqCenterValidator {
148146
void operator()(float const flEQCenter) const
149147
{
150-
eax_validate_range<DistortionCommitter::Exception>(
148+
eax_validate_range<EaxDistortionCommitter::Exception>(
151149
"EQ Center",
152150
flEQCenter,
153151
EAXDISTORTION_MINEQCENTER,
@@ -158,7 +156,7 @@ struct EqCenterValidator {
158156
struct EqBandwidthValidator {
159157
void operator()(float const flEQBandwidth) const
160158
{
161-
eax_validate_range<DistortionCommitter::Exception>(
159+
eax_validate_range<EaxDistortionCommitter::Exception>(
162160
"EQ Bandwidth",
163161
flEQBandwidth,
164162
EAXDISTORTION_MINEQBANDWIDTH,
@@ -180,14 +178,14 @@ struct AllValidator {
180178
} // namespace
181179

182180
template<> /* NOLINTNEXTLINE(clazy-copyable-polymorphic) Exceptions must be copyable. */
183-
struct DistortionCommitter::Exception final : EaxException {
181+
struct EaxDistortionCommitter::Exception final : EaxException {
184182
explicit Exception(const std::string_view message)
185183
: EaxException{"EAX_DISTORTION_EFFECT", message}
186184
{ }
187185
};
188186

189187
template<> [[noreturn]]
190-
void DistortionCommitter::fail(const std::string_view message)
188+
void EaxDistortionCommitter::fail(const std::string_view message)
191189
{ throw Exception{message}; }
192190

193191
auto EaxDistortionCommitter::commit(const EAXDISTORTIONPROPERTIES &props) const -> bool

al/effects/echo.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,10 @@ void EchoEffectHandler::GetParamfv(al::Context *context, const EchoProps &props,
109109
#if ALSOFT_EAX
110110
namespace {
111111

112-
using EchoCommitter = EaxCommitter<EaxEchoCommitter>;
113-
114112
struct DelayValidator {
115113
void operator()(float const flDelay) const
116114
{
117-
eax_validate_range<EchoCommitter::Exception>(
115+
eax_validate_range<EaxEchoCommitter::Exception>(
118116
"Delay",
119117
flDelay,
120118
EAXECHO_MINDELAY,
@@ -125,7 +123,7 @@ struct DelayValidator {
125123
struct LrDelayValidator {
126124
void operator()(float const flLRDelay) const
127125
{
128-
eax_validate_range<EchoCommitter::Exception>(
126+
eax_validate_range<EaxEchoCommitter::Exception>(
129127
"LR Delay",
130128
flLRDelay,
131129
EAXECHO_MINLRDELAY,
@@ -136,7 +134,7 @@ struct LrDelayValidator {
136134
struct DampingValidator {
137135
void operator()(float const flDamping) const
138136
{
139-
eax_validate_range<EchoCommitter::Exception>(
137+
eax_validate_range<EaxEchoCommitter::Exception>(
140138
"Damping",
141139
flDamping,
142140
EAXECHO_MINDAMPING,
@@ -147,7 +145,7 @@ struct DampingValidator {
147145
struct FeedbackValidator {
148146
void operator()(float const flFeedback) const
149147
{
150-
eax_validate_range<EchoCommitter::Exception>(
148+
eax_validate_range<EaxEchoCommitter::Exception>(
151149
"Feedback",
152150
flFeedback,
153151
EAXECHO_MINFEEDBACK,
@@ -158,7 +156,7 @@ struct FeedbackValidator {
158156
struct SpreadValidator {
159157
void operator()(float const flSpread) const
160158
{
161-
eax_validate_range<EchoCommitter::Exception>(
159+
eax_validate_range<EaxEchoCommitter::Exception>(
162160
"Spread",
163161
flSpread,
164162
EAXECHO_MINSPREAD,
@@ -180,13 +178,13 @@ struct AllValidator {
180178
} // namespace
181179

182180
template<> /* NOLINTNEXTLINE(clazy-copyable-polymorphic) Exceptions must be copyable. */
183-
struct EchoCommitter::Exception final : EaxException {
181+
struct EaxEchoCommitter::Exception final : EaxException {
184182
explicit Exception(const std::string_view message) : EaxException{"EAX_ECHO_EFFECT", message}
185183
{ }
186184
};
187185

188186
template<> [[noreturn]]
189-
void EchoCommitter::fail(const std::string_view message)
187+
void EaxEchoCommitter::fail(const std::string_view message)
190188
{ throw Exception{message}; }
191189

192190
auto EaxEchoCommitter::commit(const EAXECHOPROPERTIES &props) const -> bool

0 commit comments

Comments
 (0)