I have a abstract base class called Command
that acts as an interface for commands that can be put in a queue:
class Command
{
public:
Command(Dependency1& d1, Dependency2& d2);
//...Irrelevant code removed for simplicity...
private:
//Implementations do their work in their override of operator()
virtual void operator()() = 0;
};
Then I have the declarations for the implementations in a header file:
class FooCommand : public Command
{
public:
using Command::Command;
private:
void operator()() override;
};
class BarCommand : public Command
{
public:
using Command::Command;
private:
void operator()() override;
};
class BazCommand : public Command
{
public:
using Command::Command;
private:
void operator()() override;
};
//...And many more...
So now I have a long list of near identical class declarations, only the name differs a bit. What would be the preferred ways to clean this up besides C style macro's?