Template Class Signal
Defined in File signal.hpp
Class Documentation
-
template<typename Data = void, unsigned int Capacity = 1>
class Signal A simple signal class.
This class, once instantiated and connected is a fixed entity. Memory reserved for slots is fixed and disconnects are not possible This allows us to avoid the use of new and in most low level control programs, such disconnects are rarely used anyway.
To reserve the capacity (i.e. no. of slots that can be attached) configure the second template parameter upon instantiation. Note that the default is 1.
void f(int i) { std::cout << i << std::endl; } int main() { Signal<int,1> signal; // Signal<int> provides a default of 1 connect(signal,f) signal.emit(3); // ...
- Template Parameters:
Data – : the data type to emit.
Capacity – : the number of slot connections to reserve.
Public Functions
-
inline Signal()
Initialise the storage.
-
inline sigslots::Error connect(sigslots::SlotBase<Data> &slot)
Connect the signal to the specified slot.
This will attach the slot (note that it is a permanent attachment) so long as the reserved capacity isn’t already fully utilised.
Valid return values:
NoError
OutOfResourcesError
- Parameters:
slot – : the slot to connect.
- Returns:
Error : the sigslots error
-
inline unsigned int capacity() const
The reserved capacity for this signaller.
- Returns:
unsigned int : the capacity.
-
inline unsigned int stored() const
The current number of connections stored.
- Returns:
unsigned int : no. of connections.