DNA Calib 1.1
Project brief
ConditionalCommand.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "dnacalib/Command.h"
6
7namespace dnac {
8
9class DNACalibDNAReader;
10
14template<class TCommand, class TCondition>
16 private:
17 using CommandType = TCommand;
18 using ConditionType = TCondition;
19
20 public:
22 command{nullptr},
23 condition{} {
24 }
25
27 command{command_},
28 condition{condition_} {
29 }
30
32
35
38
44 void setCommand(Command* command_) {
45 command = command_;
46 }
47
53 void setCondition(ConditionType condition_) {
54 condition = condition_;
55 }
56
57 void run(DNACalibDNAReader* output) override {
58 if (command && condition(command, output)) {
59 command->run(output);
60 }
61 }
62
63 private:
66
67};
68
69template<class TCommand, class TCondition>
70ConditionalCommand<TCommand, TCondition> makeConditional(TCommand* command, TCondition condition) {
71 return ConditionalCommand<TCommand, TCondition>{command, condition};
72}
73
74} // namespace dnac
Command is an abstract class whose implementations are expected to modify the DNA provided in the run...
Definition: Command.h:15
ConditionalCommand is used to run a command if the specified condition is met.
Definition: ConditionalCommand.h:15
TCommand CommandType
Definition: ConditionalCommand.h:17
TCondition ConditionType
Definition: ConditionalCommand.h:18
ConditionalCommand(CommandType *command_, ConditionType condition_)
Definition: ConditionalCommand.h:26
ConditionalCommand(const ConditionalCommand &)=delete
void setCondition(ConditionType condition_)
Method for setting the condition under which the command should run.
Definition: ConditionalCommand.h:53
ConditionalCommand & operator=(const ConditionalCommand &)=delete
ConditionType condition
Definition: ConditionalCommand.h:65
ConditionalCommand & operator=(ConditionalCommand &&)=default
CommandType * command
Definition: ConditionalCommand.h:64
void setCommand(Command *command_)
Method for setting the command to run.
Definition: ConditionalCommand.h:44
ConditionalCommand()
Definition: ConditionalCommand.h:21
ConditionalCommand(ConditionalCommand &&)=default
void run(DNACalibDNAReader *output) override
Definition: ConditionalCommand.h:57
Definition: DNACalibDNAReader.h:12
Definition: Command.h:8
ConditionalCommand< TCommand, TCondition > makeConditional(TCommand *command, TCondition condition)
Definition: ConditionalCommand.h:70