include
bota_worker
WorkerOptions.hpp
Go to the documentation of this file.
1
/**********************************************************************
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2016, Philipp Leemann
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
*
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* * Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials provided
16
* with the distribution.
17
* * Neither the name of Robotic Systems Lab nor ETH Zurich
18
* nor the names of its contributors may be used to endorse or
19
* promote products derived from this software without specific
20
* prior written permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*/
35
42
#pragma once
43
44
#include <atomic>
45
#include <string>
46
47
#include "
bota_worker/RateOptions.hpp
"
48
#include "
bota_worker/WorkerEvent.hpp
"
49
50
namespace
bota_worker
51
{
52
using
WorkerCallback
= std::function<bool(
const
WorkerEvent
&)>;
53
using
WorkerCallbackFailureReaction
= std::function<void(
void
)>;
54
55
struct
WorkerOptions
:
public
RateOptions
56
{
57
WorkerOptions
()
58
:
RateOptions
(),
callback_
(),
callbackFailureReaction_
([]() {}),
defaultPriority_
(0),
destructWhenDone_
(
false
)
59
{
60
}
61
62
WorkerOptions
(
const
std::string& name,
const
double
timestep,
WorkerCallback
callback,
const
int
priority = 0)
63
:
RateOptions
(name, timestep)
64
,
callback_
(
std
::move(callback))
65
,
callbackFailureReaction_
([]() {})
66
,
defaultPriority_
(priority)
67
,
destructWhenDone_
(
false
)
68
{
69
}
70
71
WorkerOptions
(
const
std::string& name,
const
double
timestep,
WorkerCallback
callback,
72
WorkerCallbackFailureReaction
callbackFailureReaction,
const
int
priority = 0)
73
:
RateOptions
(name, timestep)
74
,
callback_
(
std
::move(callback))
75
,
callbackFailureReaction_
(
std
::move(callbackFailureReaction))
76
,
defaultPriority_
(priority)
77
,
destructWhenDone_
(false)
78
{
79
}
80
81
WorkerOptions
(
const
WorkerOptions
& other) =
default
;
82
83
WorkerOptions
(
WorkerOptions
&& other) noexcept
84
:
RateOptions
(std::move(other))
85
,
callback_
(std::move(other.callback_))
86
,
callbackFailureReaction_
(std::move(other.callbackFailureReaction_))
87
,
defaultPriority_
(other.defaultPriority_)
88
,
destructWhenDone_
(other.destructWhenDone_)
89
{
90
}
91
95
WorkerCallback
callback_
;
96
100
WorkerCallbackFailureReaction
callbackFailureReaction_
;
101
105
int
defaultPriority_
;
106
110
bool
destructWhenDone_
;
111
};
112
113
}
// namespace bota_worker
bota_worker::WorkerOptions::WorkerOptions
WorkerOptions(const std::string &name, const double timestep, WorkerCallback callback, const int priority=0)
Definition:
WorkerOptions.hpp:62
bota_worker::WorkerOptions::callbackFailureReaction_
WorkerCallbackFailureReaction callbackFailureReaction_
Definition:
WorkerOptions.hpp:100
RateOptions.hpp
bota_worker::WorkerCallbackFailureReaction
std::function< void(void)> WorkerCallbackFailureReaction
Definition:
WorkerOptions.hpp:53
bota_worker
Definition:
Rate.hpp:50
bota_worker::WorkerOptions::defaultPriority_
int defaultPriority_
Definition:
WorkerOptions.hpp:105
bota_worker::WorkerOptions::WorkerOptions
WorkerOptions(WorkerOptions &&other) noexcept
Definition:
WorkerOptions.hpp:83
bota_worker::WorkerOptions::callback_
WorkerCallback callback_
Definition:
WorkerOptions.hpp:95
bota_worker::WorkerOptions
Definition:
WorkerOptions.hpp:55
bota_worker::RateOptions::RateOptions
RateOptions(std::string name="", const double timeStep=0.0, const double maxTimeStepFactorWarning=1.0, const double maxTimeStepFactorError=10.0, const bool enforceRate=true, const clockid_t clockId=CLOCK_MONOTONIC)
Definition:
RateOptions.hpp:79
bota_worker::RateOptions
Definition:
RateOptions.hpp:54
bota_worker::WorkerEvent
Definition:
WorkerEvent.hpp:51
bota_worker::WorkerOptions::WorkerOptions
WorkerOptions()
Definition:
WorkerOptions.hpp:57
std
bota_worker::WorkerCallback
std::function< bool(const WorkerEvent &)> WorkerCallback
Definition:
WorkerOptions.hpp:52
WorkerEvent.hpp
bota_worker::WorkerOptions::destructWhenDone_
bool destructWhenDone_
Definition:
WorkerOptions.hpp:110
bota_worker::WorkerOptions::WorkerOptions
WorkerOptions(const std::string &name, const double timestep, WorkerCallback callback, WorkerCallbackFailureReaction callbackFailureReaction, const int priority=0)
Definition:
WorkerOptions.hpp:71
bota_worker
Author(s):
autogenerated on Sat Apr 15 2023 02:53:50