Now that we have seen what the Command pattern is, let's look at how it is used in the Mach5 Engine. You will be surprised that there isn't much code here. That is because using the Command pattern is easy once you understand the code behind it. In this section, we will look at both the component responsible for the mouse click and the commands that are used within the engine.
Let's have a look at the M5Command class:
class M5Command
{
public:
virtual ~M5Command(void) {}//Empty Virtual Destructor
virtual void Execute(void) = 0;
virtual M5Command* Clone(void) const = 0;
};
Here is the M5Command class used in the Mach5 Engine. As you can see, it looks almost identical to the Command class we used in the example. The only difference is that since we plan on using this within a component, it needs to have a virtual constructor. That way we can make a copy of it without...