Slot.h
1/*
2 Copyright (C) 2008 Marc Boris Duerner
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 As a special exception, you may use this file as part of a free
10 software library without restriction. Specifically, if other files
11 instantiate templates or use macros or inline functions from this
12 file, or you compile this file and link it with other files to
13 produce an executable, this file does not by itself cause the
14 resulting executable to be covered by the GNU General Public
15 License. This exception does not however invalidate any other
16 reasons why the executable file might be covered by the GNU Library
17 General Public License.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, write to the:
26 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301 USA
28*/
29
30#ifndef Pt_Slot_h
31#define Pt_Slot_h
32
33#include <Pt/Api.h>
34#include <Pt/Void.h>
35#include <Pt/Callable.h>
36#include <tuple>
37#include <type_traits>
38#include <utility>
39
40namespace Pt {
41
42class Connection;
43
54class Slot
55{
56 public:
59 virtual ~Slot() {}
60
63 virtual Slot* clone() const = 0;
64
71 virtual const Callback* callable() const = 0;
72
75 virtual void onConnect(const Connection& c) = 0;
76
79 virtual void onDisconnect(const Connection& c) = 0;
80
83 virtual bool equals(const Slot& slot) const = 0;
84};
85
90template <typename R, typename... As>
91class BasicSlot : public Slot
92{
93 public:
94 virtual Slot* clone() const = 0;
95};
96
97} // namespace Pt
98
99#include "SlotBind.h"
100
101#endif
Base type for various "slot" types.
Definition Slot.h:92
virtual Slot * clone() const =0
Clone this object with new.
Represents a connection between a Signal/Delegate and a slot.
Definition Connection.h:96
Endpoint of a signal/slot connection.
Definition Slot.h:55
virtual ~Slot()
Destructor.
Definition Slot.h:59
virtual bool equals(const Slot &slot) const =0
Returns true if two slots are equal in value.
virtual void onConnect(const Connection &c)=0
Notifies of connects.
virtual void onDisconnect(const Connection &c)=0
Notifies of disconnects.
ConstMethodSlot< R, ClassT, As... > slot(ClassT &object, R(BaseT::*method)(As...) const)
Returns a slot object for the given object/member pair.
Definition ConstMethod.h:172
virtual Slot * clone() const =0
Clone this object with new.
virtual const Callback * callable() const =0
Returns the callable converted to the type-erased Callback interface.
Core module.
Definition Allocator.h:33