Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
ipc
libmultiprocess
test
mp
test
foo.h
Go to the documentation of this file.
1
// Copyright (c) The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef MP_TEST_FOO_H
6
#define MP_TEST_FOO_H
7
8
#include <cassert>
9
#include <functional>
10
#include <map>
11
#include <memory>
12
#include <optional>
13
#include <string>
14
#include <set>
15
#include <unordered_set>
16
#include <vector>
17
18
namespace
mp
{
19
namespace
test
{
20
21
struct
FooStruct
22
{
23
std::string
name
;
24
std::set<int>
set_int
;
25
std::vector<bool>
vector_bool
;
26
std::optional<int>
optional_int
;
27
std::unordered_set<int>
unordered_set_int
;
28
std::map<std::string, int>
map_string_int
;
29
};
30
31
enum class
FooEnum
: uint8_t { ONE = 1,
TWO
= 2, };
32
33
struct
FooCustom
34
{
35
std::string
v1
;
36
int
v2
;
37
};
38
39
struct
FooEmpty
40
{
41
};
42
43
struct
FooMessage
44
{
45
std::string
message
;
46
};
47
48
struct
FooMutable
49
{
50
std::string
message
;
51
};
52
53
using
FooData
= std::vector<char>;
54
using
FooDataRef
= std::shared_ptr<const FooData>;
55
56
class
FooCallback
57
{
58
public
:
59
virtual
~FooCallback
() =
default
;
60
virtual
int
call
(
int
arg) = 0;
61
};
62
63
class
ExtendedCallback
:
public
FooCallback
64
{
65
public
:
66
virtual
int
callExtended
(
int
arg) = 0;
67
};
68
69
class
FooImplementation
70
{
71
public
:
72
int
add
(
int
a,
int
b) {
return
a + b; }
73
void
addOut
(
int
a,
int
b,
int
& out) { out = a + b; }
74
void
addInOut
(
int
x,
int
&
sum
) {
sum
+= x; }
75
int
mapSize
(
const
std::map<std::string, std::string>& map) {
return
map.size(); }
76
FooStruct
pass
(
FooStruct
foo) {
return
foo; }
77
void
raise
(
FooStruct
foo) {
throw
foo; }
78
void
initThreadMap
() {}
79
int
callback
(
FooCallback
&
callback
,
int
arg) {
return
callback
.
call
(arg); }
80
int
callbackUnique
(std::unique_ptr<FooCallback>
callback
,
int
arg) {
return
callback
->call(arg); }
81
int
callbackShared
(std::shared_ptr<FooCallback>
callback
,
int
arg) {
return
callback
->call(arg); }
// NOLINT(performance-unnecessary-value-param)
82
void
saveCallback
(std::shared_ptr<FooCallback>
callback
) {
m_callback
= std::move(
callback
); }
83
int
callbackSaved
(
int
arg) {
return
m_callback
->call(arg); }
84
int
callbackExtended
(
ExtendedCallback
&
callback
,
int
arg) {
return
callback
.
callExtended
(arg); }
85
FooCustom
passCustom
(
FooCustom
foo) {
return
foo; }
86
FooEmpty
passEmpty
(
FooEmpty
foo) {
return
foo; }
87
FooData
passData
(
FooData
foo) {
return
foo; }
88
FooMessage
passMessage
(
FooMessage
foo) { foo.
message
+=
" call"
;
return
foo; }
89
void
passMutable
(
FooMutable
& foo) { foo.
message
+=
" call"
; }
90
FooEnum
passEnum
(
FooEnum
foo) {
return
foo; }
91
double
passDouble
(
double
value) {
return
value; }
92
int
passFn
(std::function<
int
()> fn) {
return
fn(); }
93
std::vector<FooDataRef>
passDataPointers
(std::vector<FooDataRef> values) {
return
values; }
94
std::shared_ptr<FooCallback>
m_callback
;
95
void
callFn
() {
assert
(
m_fn
);
m_fn
(); }
96
void
callFnAsync
() {
assert
(
m_fn
);
m_fn
(); }
97
int
callIntFnAsync
(
int
arg) {
assert
(
m_int_fn
);
return
m_int_fn
(arg); }
98
std::function<void()>
m_fn
;
99
std::function<int(
int
)>
m_int_fn
;
100
};
101
102
}
// namespace test
103
}
// namespace mp
104
105
#endif
// MP_TEST_FOO_H
mp::test::ExtendedCallback
Definition
foo.h:64
mp::test::ExtendedCallback::callExtended
virtual int callExtended(int arg)=0
mp::test::FooCallback
Definition
foo.h:57
mp::test::FooCallback::call
virtual int call(int arg)=0
mp::test::FooCallback::~FooCallback
virtual ~FooCallback()=default
mp::test::FooImplementation
Definition
foo.h:70
mp::test::FooImplementation::addOut
void addOut(int a, int b, int &out)
Definition
foo.h:73
mp::test::FooImplementation::m_int_fn
std::function< int(int)> m_int_fn
Definition
foo.h:99
mp::test::FooImplementation::callFn
void callFn()
Definition
foo.h:95
mp::test::FooImplementation::callbackSaved
int callbackSaved(int arg)
Definition
foo.h:83
mp::test::FooImplementation::passMutable
void passMutable(FooMutable &foo)
Definition
foo.h:89
mp::test::FooImplementation::initThreadMap
void initThreadMap()
Definition
foo.h:78
mp::test::FooImplementation::passEmpty
FooEmpty passEmpty(FooEmpty foo)
Definition
foo.h:86
mp::test::FooImplementation::callFnAsync
void callFnAsync()
Definition
foo.h:96
mp::test::FooImplementation::passFn
int passFn(std::function< int()> fn)
Definition
foo.h:92
mp::test::FooImplementation::m_callback
std::shared_ptr< FooCallback > m_callback
Definition
foo.h:94
mp::test::FooImplementation::m_fn
std::function< void()> m_fn
Definition
foo.h:98
mp::test::FooImplementation::callbackShared
int callbackShared(std::shared_ptr< FooCallback > callback, int arg)
Definition
foo.h:81
mp::test::FooImplementation::addInOut
void addInOut(int x, int &sum)
Definition
foo.h:74
mp::test::FooImplementation::raise
void raise(FooStruct foo)
Definition
foo.h:77
mp::test::FooImplementation::callbackUnique
int callbackUnique(std::unique_ptr< FooCallback > callback, int arg)
Definition
foo.h:80
mp::test::FooImplementation::passEnum
FooEnum passEnum(FooEnum foo)
Definition
foo.h:90
mp::test::FooImplementation::add
int add(int a, int b)
Definition
foo.h:72
mp::test::FooImplementation::passDouble
double passDouble(double value)
Definition
foo.h:91
mp::test::FooImplementation::callIntFnAsync
int callIntFnAsync(int arg)
Definition
foo.h:97
mp::test::FooImplementation::passMessage
FooMessage passMessage(FooMessage foo)
Definition
foo.h:88
mp::test::FooImplementation::callback
int callback(FooCallback &callback, int arg)
Definition
foo.h:79
mp::test::FooImplementation::pass
FooStruct pass(FooStruct foo)
Definition
foo.h:76
mp::test::FooImplementation::passDataPointers
std::vector< FooDataRef > passDataPointers(std::vector< FooDataRef > values)
Definition
foo.h:93
mp::test::FooImplementation::passCustom
FooCustom passCustom(FooCustom foo)
Definition
foo.h:85
mp::test::FooImplementation::saveCallback
void saveCallback(std::shared_ptr< FooCallback > callback)
Definition
foo.h:82
mp::test::FooImplementation::passData
FooData passData(FooData foo)
Definition
foo.h:87
mp::test::FooImplementation::callbackExtended
int callbackExtended(ExtendedCallback &callback, int arg)
Definition
foo.h:84
mp::test::FooImplementation::mapSize
int mapSize(const std::map< std::string, std::string > &map)
Definition
foo.h:75
sum
volatile double sum
Definition
examples.cpp:10
mp::test
Definition
foo-types.h:36
mp::test::FooEnum
FooEnum
Definition
foo.h:31
mp::test::FooEnum::TWO
@ TWO
Definition
foo.h:31
mp::test::FooData
std::vector< char > FooData
Definition
foo.h:53
mp::test::FooDataRef
std::shared_ptr< const FooData > FooDataRef
Definition
foo.h:54
mp
Functions to serialize / deserialize common bitcoin types.
Definition
common-types.h:58
mp::test::FooCustom
Definition
foo.h:34
mp::test::FooCustom::v2
int v2
Definition
foo.h:36
mp::test::FooCustom::v1
std::string v1
Definition
foo.h:35
mp::test::FooEmpty
Definition
foo.h:40
mp::test::FooMessage
Definition
foo.h:44
mp::test::FooMessage::message
std::string message
Definition
foo.h:45
mp::test::FooMutable
Definition
foo.h:49
mp::test::FooMutable::message
std::string message
Definition
foo.h:50
mp::test::FooStruct
Definition
foo.h:22
mp::test::FooStruct::name
std::string name
Definition
foo.h:23
mp::test::FooStruct::map_string_int
std::map< std::string, int > map_string_int
Definition
foo.h:28
mp::test::FooStruct::unordered_set_int
std::unordered_set< int > unordered_set_int
Definition
foo.h:27
mp::test::FooStruct::optional_int
std::optional< int > optional_int
Definition
foo.h:26
mp::test::FooStruct::vector_bool
std::vector< bool > vector_bool
Definition
foo.h:25
mp::test::FooStruct::set_int
std::set< int > set_int
Definition
foo.h:24
assert
assert(!tx.IsCoinBase())
Generated on
for Bitcoin Core by
1.18.0