Skip to main content

ICommand

Namespace: UTILSLIB  ·  Library: Utilities Library

#include <utils/commandpattern.h>

class UTILSLIB::ICommand

Declare interface command.

The ICommand interface provides the base class of every command of the command design pattern.

src/examples/ex_utils/main.cpp
// A command wraps an action so it can be queued or replayed later
class AppendCommand : public ICommand
{
public:
AppendCommand(QStringList& target, QString text)
: m_target(target)
, m_text(std::move(text))
{
}
void execute() override
{
m_target.append(m_text);
}

private:
QStringList& m_target;
QString m_text;
};

Inheritance​


Public Methods​

~ICommand()​

Destroys the ICommand.


execute()​

Executes the ICommand.


Example​

Used in examples​

ex_utils​

Utilities library: buffers, observers, logging, file formats, montages, layouts and reports.

src/examples/ex_utils/main.cpp, line 115
// A command wraps an action so it can be queued or replayed later
class AppendCommand : public ICommand
{
public:
AppendCommand(QStringList& target, QString text)
: m_target(target)
, m_text(std::move(text))
{
}
void execute() override
{
m_target.append(m_text);
}

Authors of this file​