DART 6.7.3
Loading...
Searching...
No Matches
ConnectionBody.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2019, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_COMMON_DETAIL_CONNECTIONBODY_HPP_
34#define DART_COMMON_DETAIL_CONNECTIONBODY_HPP_
35
36#include <memory>
37
38namespace dart {
39namespace common {
40
41namespace signal {
42namespace detail {
43
46{
47public:
50
52 virtual ~ConnectionBodyBase();
53
55 void disconnect();
56
58 bool isConnected() const;
59
60protected:
63};
64
66template <typename SlotType>
68{
69public:
71 ConnectionBody(const SlotType& _slot);
72
74 ConnectionBody(SlotType&& _slot);
75
77 virtual ~ConnectionBody();
78
80 const SlotType& getSlot();
81
82private:
84 SlotType mSlot;
85};
86
87//==============================================================================
88template <typename SlotType>
90 : ConnectionBodyBase(), mSlot(_slot)
91{
92 // Do nothing
93}
94
95//==============================================================================
96template <typename SlotType>
98 : ConnectionBodyBase(), mSlot(std::forward<SlotType>(_slot))
99{
100 // Do nothing
101}
102
103//==============================================================================
104template <typename SlotType>
106{
107 // Do nothing
108}
109
110//==============================================================================
111template <typename SlotType>
113{
114 return mSlot;
115}
116
118template <typename T>
120{
121 typedef T result_type;
122
123 template <typename InputIterator>
124 static T process(InputIterator first, InputIterator last)
125 {
126 // If there are no slots to call, just return the
127 // default-constructed value
128 if (first == last)
129 return T();
130
131 return *(--last);
132 }
133};
134
135} // namespace detail
136} // namespace signal
137
138} // namespace common
139} // namespace dart
140
141#endif // DART_COMMON_DETAIL_CONNECTIONBODY_HPP_
142
class ConnectionBodyBase
Definition ConnectionBody.hpp:46
virtual ~ConnectionBodyBase()
Destructor.
Definition ConnectionBody.cpp:49
ConnectionBodyBase()
Constructor.
Definition ConnectionBody.cpp:42
void disconnect()
Disconnect.
Definition ConnectionBody.cpp:55
bool isConnected() const
Get true if this connection body is connected to the signal.
Definition ConnectionBody.cpp:61
bool mIsConnected
Connection flag.
Definition ConnectionBody.hpp:62
class ConnectionBody
Definition ConnectionBody.hpp:68
SlotType mSlot
Slot.
Definition ConnectionBody.hpp:84
const SlotType & getSlot()
Get slot.
Definition ConnectionBody.hpp:112
virtual ~ConnectionBody()
Destructor.
Definition ConnectionBody.hpp:105
ConnectionBody(const SlotType &_slot)
Constructor given slot.
Definition ConnectionBody.hpp:89
Definition BulletCollisionDetector.cpp:63
Definition SharedLibraryManager.hpp:43
DefaultCombiner – return the last result.
Definition ConnectionBody.hpp:120
static T process(InputIterator first, InputIterator last)
Definition ConnectionBody.hpp:124
T result_type
Definition ConnectionBody.hpp:121