OTest2
A C++ testing framework
cmdnextobject.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include <cmdnextobject.h>
20 
21 #include <assert.h>
22 #include <utility>
23 
24 #include <cmdrepeatobject.h>
25 #include <commandstack.h>
26 #include <context.h>
27 #include <objectrepeater.h>
28 #include <scenario.h>
29 #include <scenarioiter.h>
30 
31 namespace OTest2 {
32 
34  ScenarioIterPtr scenario_iter_,
35  ObjectPtr parent_) :
36  scenario_iter(scenario_iter_),
37  parent(parent_) {
38  assert(scenario_iter != nullptr);
39 
40 }
41 
43 
44 }
45 
47  const Context& context_) {
48  /* -- if the iterator still points a valid object, run it */
49  if(scenario_iter->isValid()) {
50  /* -- get the pointed scenario object */
51  ScenarioPtr object_scenario_(scenario_iter->getScenario());
52 
53  /* -- schedule run of next testing object */
54  scenario_iter->next();
55  context_.command_stack->pushCommand(
56  std::make_shared<CmdNextObject>(scenario_iter, parent));
57 
58  /* -- create the repeater object */
59  auto repeater_(object_scenario_->createRepeater(context_));
60 
61  /* -- schedule the repeater for run */
62  context_.command_stack->pushCommand(
63  std::make_shared<CmdRepeatObject>(
64  object_scenario_, repeater_.second, repeater_.first, parent));
65  }
66 }
67 
68 } /* -- namespace OTest2 */
objectrepeater.h
OTest2::CommandStack::pushCommand
void pushCommand(CommandPtr command_)
Push a command into the stack.
Definition: commandstack.cpp:67
commandstack.h
OTest2::CmdNextObject::~CmdNextObject
virtual ~CmdNextObject()
Dtor.
Definition: cmdnextobject.cpp:42
cmdrepeatobject.h
OTest2::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Shared pointer to a testing object.
Definition: objectptr.h:27
OTest2::CmdNextObject::CmdNextObject
CmdNextObject(ScenarioIterPtr scenario_iter_, ObjectPtr parent_)
Ctor.
Definition: cmdnextobject.cpp:33
OTest2::Context::command_stack
CommandStack *const command_stack
Definition: context.h:40
OTest2
Definition: assertbean.h:25
OTest2::ScenarioIterPtr
std::shared_ptr< ScenarioIter > ScenarioIterPtr
Shared pointer of the scenario iter interface.
Definition: scenarioiterptr.h:27
OTest2::ScenarioPtr
std::shared_ptr< Scenario > ScenarioPtr
Shared pointer of the scenario object.
Definition: scenarioptr.h:27
scenarioiter.h
scenario.h
context.h
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
OTest2::CmdNextObject::run
virtual void run(const Context &context_) override
Run the command.
Definition: cmdnextobject.cpp:46
cmdnextobject.h