Go to the documentation of this file.
12 #ifndef ECL_SIGSLOTS_LITE_MANAGERS_HPP_
13 #define ECL_SIGSLOTS_LITE_MANAGERS_HPP_
32 template <
typename Data,
unsigned int Capacity>
class Signal;
42 template <
typename Data,
typename FunctionClass>
43 class MemberSlotsBase {
45 virtual unsigned int stored()
const {
return 0; }
46 virtual unsigned int capacity()
const {
return 0; }
47 virtual sigslots::MemberSlot<Data,FunctionClass>*
addSlot(
void (FunctionClass::*func)(Data), FunctionClass &instance) = 0;
53 template <
typename FunctionClass>
54 class MemberSlotsBase<void,FunctionClass> {
56 virtual unsigned int stored()
const {
return 0; }
57 virtual unsigned int capacity()
const {
return 0; }
90 template <
typename Data,
typename FunctionClass,
unsigned int Capacity = 1>
97 template <
typename Data_,
unsigned int Capacity_,
typename FunctionClass_>
101 template <
typename Data_,
typename FunctionClass_>
105 template <
typename Data_,
typename FunctionClass_>
136 for (
unsigned int i = 0; i <
size; ++i ) {
137 if ( func ==
slots[i].member_function ) {
141 if (
size < Capacity ) {
142 slots[
size] = sigslots::MemberSlot<Data,FunctionClass>(func,instance);
190 template <
typename Data,
typename Dummy =
int>
199 template <
typename Data_,
unsigned int Capacity_>
203 template <
typename Data_>
218 static unsigned int stored(
const bool increment =
false) {
219 static unsigned int stored_slots = 0;
220 if ( increment ) { ++stored_slots; }
231 static sigslots::GlobalSlot<Data>*
addSlot(
void (*func)(Data)) {
234 for (
unsigned int i = 0; i < size; ++i ) {
235 if ( func == slots[i].global_function ) {
240 slots[size] = sigslots::GlobalSlot<Data>(func);
243 return &(slots[size]);
256 template <
typename FunctionClass,
unsigned int Capacity>
257 class MemberSlots<void, FunctionClass, Capacity> :
public sigslots::MemberSlotsBase<void,FunctionClass> {
263 template <
unsigned int Capacity_,
typename FunctionClass_>
264 friend sigslots::Error
connect(Signal<void,Capacity_> &signal,
void(FunctionClass_::*f)(
void), FunctionClass_ &o);
266 template <
typename Data_,
typename FunctionClass_>
270 template <
typename Data_,
typename FunctionClass_>
289 unsigned int capacity()
const {
return Capacity; }
300 sigslots::MemberSlot<void,FunctionClass>*
addSlot(
void (FunctionClass::*func)(
void), FunctionClass &instance) {
301 for (
unsigned int i = 0; i <
size; ++i ) {
302 if ( func ==
slots[i].member_function ) {
306 if (
size < Capacity ) {
307 slots[
size] = sigslots::MemberSlot<void,FunctionClass>(func,instance);
324 template <
typename Dummy>
334 template <
unsigned int Capacity_>
352 static unsigned int stored(
const bool increment =
false) {
353 static unsigned int stored_slots = 0;
354 if ( increment ) { ++stored_slots; }
367 unsigned int size =
stored();
369 for (
unsigned int i = 0; i < size; ++i ) {
370 if ( func == slots[i].global_function ) {
375 slots[size] = sigslots::GlobalSlot<void>(func);
378 return &(slots[size]);
static unsigned int stored(const bool increment=false)
Number of slots currently stored.
virtual unsigned int stored() const
unsigned int capacity() const
The number of slots that can be attached to member functions.
A slot with global/static callback function.
friend sigslots::Error connect(Signal< Data_, Capacity_ > &signal, void(*function)(Data_))
friend sigslots::Error connect(Signal< Data_, Capacity_ > &signal, void(FunctionClass_::*f)(Data_), FunctionClass_ &o)
static const unsigned int capacity
Number of global functions of this type that can be slotted.
sigslots::MemberSlot< Data, FunctionClass > * addSlot(void(FunctionClass::*func)(Data), FunctionClass &instance)
Add a slot.
virtual unsigned int capacity() const
Simple slots - these are actually all hidden from the user.
This is the global slot interface.
virtual sigslots::MemberSlot< Data, FunctionClass > * addSlot(void(FunctionClass::*func)(Data), FunctionClass &instance)=0
unsigned int stored() const
The number of slots stored.
Extends the generic ecl error handler with some time specific error strings.
friend unsigned int global_slots_stored()
static sigslots::GlobalSlot< Data > * addSlot(void(*func)(Data))
Add a slot.
sigslots::MemberSlot< Data, FunctionClass > slots[Capacity]
friend unsigned int member_slots_capacity(const FunctionClass_ &object)
A slot with member callback function.
Used internally to retrieve info about members lots.
friend unsigned int member_slots_stored(const FunctionClass_ &object)
This is the member slot interface, inheritable by classes.
A slot with global/static callback function.
A slot with member callback function.