OTest2
A C++ testing framework
include
otest2
testmarkfactory.h
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
20
#ifndef OTest2__INCLUDE_OTEST2_TESTMARKFACTORY_H_
21
#define OTest2__INCLUDE_OTEST2_TESTMARKFACTORY_H_
22
23
#include <functional>
24
#include <memory>
25
#include <string>
26
27
#include <
otest2/testmarkptr.h
>
28
29
namespace
OTest2
{
30
40
struct
CtorMark;
41
45
class
TestMarkFactory
{
46
private
:
47
struct
Impl;
48
Impl* pimpl;
49
50
void
doRegisterRecord(
51
const
std::string& typemark_,
52
std::function<
TestMarkPtr
()> ctor_);
53
54
public
:
55
/* -- avoid copying */
56
TestMarkFactory
(
57
const
TestMarkFactory
&) =
delete
;
58
TestMarkFactory
&
operator =
(
59
const
TestMarkFactory
&) =
delete
;
60
66
TestMarkFactory
();
67
71
~TestMarkFactory
();
72
80
TestMarkPtr
createMark
(
81
const
std::string& typemark_);
82
88
template
<
typename
Mark_>
89
void
registerMark
() {
90
doRegisterRecord(
91
Mark_::typeMark(),
92
[]() {
93
return
std::make_shared<Mark_>(
static_cast<
const
CtorMark*
>
(
nullptr
));
94
});
95
}
96
};
97
98
}
/* -- namespace OTest2 */
99
100
#endif
/* -- OTest2__INCLUDE_OTEST2_TESTMARKFACTORY_H_ */
testmarkptr.h
OTest2::TestMarkFactory::operator=
TestMarkFactory & operator=(const TestMarkFactory &)=delete
OTest2::TestMarkPtr
std::shared_ptr< TestMark > TestMarkPtr
Definition:
testmarkptr.h:26
OTest2
Definition:
assertbean.h:25
OTest2::TestMarkFactory::registerMark
void registerMark()
Register a testmark type.
Definition:
testmarkfactory.h:89
OTest2::TestMarkFactory::createMark
TestMarkPtr createMark(const std::string &typemark_)
Create new empty testmark.
Definition:
testmarkfactory.cpp:82
OTest2::TestMarkFactory::TestMarkFactory
TestMarkFactory()
Ctor.
Definition:
testmarkfactory.cpp:65
OTest2::TestMarkFactory
A factory of testmark objects used for deserialization.
Definition:
testmarkfactory.h:45
OTest2::TestMarkFactory::~TestMarkFactory
~TestMarkFactory()
Dtor.
Definition:
testmarkfactory.cpp:78
Generated by
1.8.17