Public Member Functions | Private Attributes | List of all members
ecl::lite::Signal< Data, Capacity > Class Template Reference

A simple signal class. More...

#include <managers.hpp>

Public Member Functions

unsigned int capacity () const
 The reserved capacity for this signaller. More...
 
sigslots::Error connect (sigslots::SlotBase< Data > &slot)
 Connect the signal to the specified slot. More...
 
void emit (Data data) const
 Signal slots with the specified data. More...
 
 Signal ()
 Initialise the storage. More...
 
unsigned int stored () const
 The current number of connections stored. More...
 

Private Attributes

sigslots::SlotBase< Data > * slots [Capacity]
 

Detailed Description

template<typename Data = void, unsigned int Capacity = 1>
class ecl::lite::Signal< Data, Capacity >

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.

Definition at line 32 of file managers.hpp.

Constructor & Destructor Documentation

template<typename Data = void, unsigned int Capacity = 1>
ecl::lite::Signal< Data, Capacity >::Signal ( )
inline

Initialise the storage.

Definition at line 68 of file signal.hpp.

Member Function Documentation

template<typename Data = void, unsigned int Capacity = 1>
unsigned int ecl::lite::Signal< Data, Capacity >::capacity ( ) const
inline

The reserved capacity for this signaller.

Returns
unsigned int : the capacity.

Definition at line 103 of file signal.hpp.

template<typename Data = void, unsigned int Capacity = 1>
sigslots::Error ecl::lite::Signal< Data, Capacity >::connect ( sigslots::SlotBase< Data > &  slot)
inline

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

Definition at line 88 of file signal.hpp.

template<typename Data = void, unsigned int Capacity = 1>
void ecl::lite::Signal< Data, Capacity >::emit ( Data  data) const
inline

Signal slots with the specified data.

Parameters
data: the data to send to the slots.

Definition at line 125 of file signal.hpp.

template<typename Data = void, unsigned int Capacity = 1>
unsigned int ecl::lite::Signal< Data, Capacity >::stored ( ) const
inline

The current number of connections stored.

Returns
unsigned int : no. of connections.

Definition at line 109 of file signal.hpp.

Member Data Documentation

template<typename Data = void, unsigned int Capacity = 1>
sigslots::SlotBase<Data>* ecl::lite::Signal< Data, Capacity >::slots[Capacity]
private

Definition at line 136 of file signal.hpp.


The documentation for this class was generated from the following files:


ecl_sigslots_lite
Author(s): Daniel Stonier
autogenerated on Fri Jun 7 2019 21:52:46