updated signal module
This commit is contained in:
@@ -46,21 +46,6 @@ public:
|
||||
/*! @brief Unsigned integer type. */
|
||||
using size_type = std::size_t;
|
||||
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit Bus() noexcept = default;
|
||||
/*! @brief Default destructor. */
|
||||
~Bus() noexcept = default;
|
||||
|
||||
/*! @brief Default copy constructor. */
|
||||
Bus(const Bus &) = default;
|
||||
/*! @brief Default move constructor. */
|
||||
Bus(Bus &&) = default;
|
||||
|
||||
/*! @brief Default copy assignment operator. @return This bus. */
|
||||
Bus & operator=(const Bus &) = default;
|
||||
/*! @brief Default move assignment operator. @return This bus. */
|
||||
Bus & operator=(Bus &&) = default;
|
||||
|
||||
/**
|
||||
* @brief Unregisters all the member functions of an instance.
|
||||
*
|
||||
@@ -117,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns false is at least a listener is connected to the bus.
|
||||
* @brief Returns false if at least a listener is connected to the bus.
|
||||
* @return True if the bus has no listeners connected, false otherwise.
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
@@ -203,21 +188,6 @@ public:
|
||||
/*! @brief Unsigned integer type. */
|
||||
using size_type = typename signal_type::size_type;
|
||||
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit Bus() noexcept = default;
|
||||
/*! @brief Default destructor. */
|
||||
virtual ~Bus() noexcept = default;
|
||||
|
||||
/*! @brief Default copy constructor. */
|
||||
Bus(const Bus &) = default;
|
||||
/*! @brief Default move constructor. */
|
||||
Bus(Bus &&) = default;
|
||||
|
||||
/*! @brief Default copy assignment operator. @return This bus. */
|
||||
Bus & operator=(const Bus &) = default;
|
||||
/*! @brief Default move assignment operator. @return This bus. */
|
||||
Bus & operator=(Bus &&) = default;
|
||||
|
||||
/**
|
||||
* @brief Unregisters member functions of instances.
|
||||
*
|
||||
@@ -259,7 +229,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns false is at least a listener is connected to the bus.
|
||||
* @brief Returns false if at least a listener is connected to the bus.
|
||||
* @return True if the bus has no listeners connected, false otherwise.
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
|
||||
@@ -19,7 +19,7 @@ class Delegate;
|
||||
|
||||
|
||||
/**
|
||||
* @brief A delegate class to send around functions and member functions.
|
||||
* @brief Utility class to send around functions and member functions.
|
||||
*
|
||||
* Unmanaged delegate for function pointers and member functions. Users of this
|
||||
* class are in charge of disconnecting instances before deleting them.
|
||||
@@ -49,8 +49,8 @@ class Delegate<Ret(Args...)> final {
|
||||
}
|
||||
|
||||
public:
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit Delegate() noexcept
|
||||
/*! @brief Default constructor. */
|
||||
Delegate() noexcept
|
||||
: stub{std::make_pair(nullptr, &fallback)}
|
||||
{}
|
||||
|
||||
|
||||
@@ -93,24 +93,11 @@ class Dispatcher final {
|
||||
}
|
||||
|
||||
public:
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit Dispatcher() noexcept
|
||||
/*! @brief Default constructor. */
|
||||
Dispatcher() noexcept
|
||||
: wrappers{}, mode{false}
|
||||
{}
|
||||
|
||||
/*! @brief Default destructor. */
|
||||
~Dispatcher() = default;
|
||||
|
||||
/*! @brief Default copy constructor. */
|
||||
Dispatcher(const Dispatcher &) = default;
|
||||
/*! @brief Default move constructor. */
|
||||
Dispatcher(Dispatcher &&) = default;
|
||||
|
||||
/*! @brief Default copy assignment operator. @return This dispatcher. */
|
||||
Dispatcher & operator=(const Dispatcher &) = default;
|
||||
/*! @brief Default move assignment operator. @return This dispatcher. */
|
||||
Dispatcher & operator=(Dispatcher &&) = default;
|
||||
|
||||
/**
|
||||
* @brief Registers a listener given in the form of a member function.
|
||||
*
|
||||
|
||||
@@ -156,16 +156,8 @@ public:
|
||||
/** @brief Event emitters are friend classes of connections. */
|
||||
friend class Emitter;
|
||||
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit Connection() = default;
|
||||
|
||||
/*! @brief Default copy constructor. */
|
||||
Connection(const Connection &) = default;
|
||||
/*! @brief Default move constructor. */
|
||||
Connection(Connection &&) = default;
|
||||
|
||||
/*! @brief Default destructor. */
|
||||
~Connection() = default;
|
||||
/*! @brief Default constructor. */
|
||||
Connection() noexcept = default;
|
||||
|
||||
/**
|
||||
* @brief Creates a connection that wraps its underlying instance.
|
||||
@@ -175,6 +167,11 @@ public:
|
||||
: Handler<Event>::connection_type{std::move(conn)}
|
||||
{}
|
||||
|
||||
/*! @brief Default copy constructor. */
|
||||
Connection(const Connection &) = default;
|
||||
/*! @brief Default move constructor. */
|
||||
Connection(Connection &&) = default;
|
||||
|
||||
/**
|
||||
* @brief Default copy assignament operator.
|
||||
* @return This connection.
|
||||
@@ -188,19 +185,19 @@ public:
|
||||
Connection & operator=(Connection &&) = default;
|
||||
};
|
||||
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit Emitter() noexcept = default;
|
||||
|
||||
/*! @brief Copying an emitter isn't allowed. */
|
||||
Emitter(const Emitter &) = delete;
|
||||
/*! @brief Default move constructor. */
|
||||
Emitter(Emitter &&) = default;
|
||||
/*! @brief Default constructor. */
|
||||
Emitter() noexcept = default;
|
||||
|
||||
/*! @brief Default destructor. */
|
||||
virtual ~Emitter() noexcept {
|
||||
static_assert(std::is_base_of<Emitter<Derived>, Derived>::value, "!");
|
||||
}
|
||||
|
||||
/*! @brief Copying an emitter isn't allowed. */
|
||||
Emitter(const Emitter &) = delete;
|
||||
/*! @brief Default move constructor. */
|
||||
Emitter(Emitter &&) = default;
|
||||
|
||||
/*! @brief Copying an emitter isn't allowed. @return This emitter. */
|
||||
Emitter & operator=(const Emitter &) = delete;
|
||||
/*! @brief Default move assignament operator. @return This emitter. */
|
||||
|
||||
@@ -91,11 +91,13 @@ class SigH;
|
||||
* of this class are in charge of disconnecting instances before deleting them.
|
||||
*
|
||||
* This class serves mainly two purposes:
|
||||
*
|
||||
* * Creating signals used later to notify a bunch of listeners.
|
||||
* * Collecting results from a set of functions like in a voting system.
|
||||
*
|
||||
* The default collector does nothing. To properly collect data, define and use
|
||||
* a class that has a call operator the signature of which is `bool(Param)` and:
|
||||
*
|
||||
* * `Param` is a type to which `Ret` can be converted.
|
||||
* * The return type is true if the handler must stop collecting data, false
|
||||
* otherwise.
|
||||
@@ -131,51 +133,6 @@ public:
|
||||
template<typename Class>
|
||||
using instance_type = Class *;
|
||||
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit SigH() noexcept = default;
|
||||
|
||||
/*! @brief Default destructor. */
|
||||
~SigH() noexcept = default;
|
||||
|
||||
/**
|
||||
* @brief Copy constructor, listeners are also connected to this signal.
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
*/
|
||||
SigH(const SigH &other)
|
||||
: calls{other.calls}
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Default move constructor.
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
*/
|
||||
SigH(SigH &&other): SigH{} {
|
||||
swap(*this, other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy assignment operator.
|
||||
*
|
||||
* Listeners are also connected to this signal.
|
||||
*
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
* @return This signal.
|
||||
*/
|
||||
SigH & operator=(const SigH &other) {
|
||||
calls = other.calls;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Move assignment operator.
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
* @return This signal.
|
||||
*/
|
||||
SigH & operator=(SigH &&other) {
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Number of listeners connected to the signal.
|
||||
* @return Number of listeners currently connected.
|
||||
@@ -185,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns false is at least a listener is connected to the signal.
|
||||
* @brief Returns false if at least a listener is connected to the signal.
|
||||
* @return True if the signal has no listeners connected, false otherwise.
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
|
||||
@@ -70,51 +70,6 @@ public:
|
||||
template<typename Class>
|
||||
using instance_type = std::shared_ptr<Class>;
|
||||
|
||||
/*! @brief Default constructor, explicit on purpose. */
|
||||
explicit Signal() noexcept = default;
|
||||
|
||||
/*! @brief Default destructor. */
|
||||
~Signal() noexcept = default;
|
||||
|
||||
/**
|
||||
* @brief Copy constructor, listeners are also connected to this signal.
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
*/
|
||||
Signal(const Signal &other)
|
||||
: calls{other.calls}
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Default move constructor.
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
*/
|
||||
Signal(Signal &&other): Signal{} {
|
||||
swap(*this, other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy assignment operator.
|
||||
*
|
||||
* Listeners are also connected to this signal.
|
||||
*
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
* @return This signal.
|
||||
*/
|
||||
Signal & operator=(const Signal &other) {
|
||||
calls = other.calls;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Move assignment operator.
|
||||
* @param other A signal to use as source to initialize this instance.
|
||||
* @return This signal.
|
||||
*/
|
||||
Signal & operator=(Signal &&other) {
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Number of listeners connected to the signal.
|
||||
* @return Number of listeners currently connected.
|
||||
@@ -124,7 +79,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns false is at least a listener is connected to the signal.
|
||||
* @brief Returns false if at least a listener is connected to the signal.
|
||||
* @return True if the signal has no listeners connected, false otherwise.
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
|
||||
Reference in New Issue
Block a user