OTest2
A C++ testing framework
stategenerated.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 
20 #ifndef OTest2INCLUDE_STATEGENERATED_H_
21 #define OTest2INCLUDE_STATEGENERATED_H_
22 
23 #include <string>
24 
25 #include <otest2/contextobject.h>
26 #include <otest2/stateordinary.h>
27 
28 namespace OTest2 {
29 
30 class Context;
31 
35 class StateGenerated : public StateOrdinary, public ContextObject {
36  private:
37  struct Impl;
38  Impl* pimpl;
39 
40  public:
41  /* -- avoid copying */
43  const StateGenerated&) = delete;
45  const StateGenerated&) = delete;
46 
55  explicit StateGenerated(
56  const Context& context_,
57  const std::string& name_,
58  const std::string& section_path_);
59 
63  virtual ~StateGenerated();
64 
65  /* -- object's interface */
66  virtual std::string getName() const;
67 
68  /* -- ordinary state interface */
69  virtual void executeState(
70  const Context& context_,
71  CaseOrdinaryPtr parent_);
72 
73  /* -- context object */
74  virtual const Context& otest2Context() const;
75 
76  private:
82  virtual void runState(
83  const Context& context_) = 0;
84 
85  protected:
96  void switchState(
97  const Context& context_,
98  const std::string& name_,
99  int delay_);
100 
108  bool isTestSectionActive(
109  const Context& context_,
110  const std::string& section_path_);
111 };
112 
113 } /* -- namespace OTest2 */
114 
115 #endif /* -- OTest2INCLUDE_STATEGENERATED_H_ */
OTest2::StateGenerated::StateGenerated
StateGenerated(const StateGenerated &)=delete
OTest2::StateGenerated
Common implementation of generated states.
Definition: stategenerated.h:35
OTest2::StateGenerated::~StateGenerated
virtual ~StateGenerated()
Dtor.
Definition: stategenerated.cpp:85
OTest2::StateGenerated::isTestSectionActive
bool isTestSectionActive(const Context &context_, const std::string &section_path_)
Check whether a test section is active.
Definition: stategenerated.cpp:120
OTest2::CaseOrdinaryPtr
std::shared_ptr< CaseOrdinary > CaseOrdinaryPtr
Shared pointer of the ordinary cases.
Definition: caseordinaryptr.h:27
OTest2
Definition: assertbean.h:25
stateordinary.h
OTest2::StateGenerated::switchState
void switchState(const Context &context_, const std::string &name_, int delay_)
Switch test states.
Definition: stategenerated.cpp:109
OTest2::ContextObject
A generic interface of objects which offers OTest2 context.
Definition: contextobject.h:33
OTest2::StateOrdinary
Ordinary state class.
Definition: stateordinary.h:33
OTest2::StateGenerated::getName
virtual std::string getName() const
Get object's name.
Definition: stategenerated.cpp:89
OTest2::StateGenerated::otest2Context
virtual const Context & otest2Context() const
Get the OTest2 context.
Definition: stategenerated.cpp:105
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
contextobject.h
OTest2::StateGenerated::operator=
StateGenerated & operator=(const StateGenerated &)=delete
OTest2::StateGenerated::executeState
virtual void executeState(const Context &context_, CaseOrdinaryPtr parent_)
Run the state.
Definition: stategenerated.cpp:93