[DEV] add possibility to tag a signal periodic and remove log on it event

This commit is contained in:
Edouard DUPIN 2016-08-03 21:45:17 +02:00
parent a2209a6a0e
commit bf72807cef
3 changed files with 19 additions and 4 deletions

View File

@ -34,6 +34,9 @@ const std::string& esignal::Base::getDescription() const {
return noValue;
}
void esignal::Base::setPeriodic(bool _state) {
m_periodic = _state;
}
std::ostream& esignal::operator <<(std::ostream& _os, const esignal::Base& _obj) {
_os << _obj.getName();

View File

@ -28,6 +28,7 @@ namespace esignal {
public:
using ObserverConnection = std::function<void(size_t)>; //!< Define an Observer of the number of observer
protected:
bool m_periodic; //!< The signal is periodic ==> no log with this signal ... (no really needed)
esignal::LockSharedPtrRef<esignal::Base> m_shared; //!< Reference counter on itself.
static size_t s_uid; //!< global id of the signal (STATIC)
static int64_t s_uidSignalEmit; //!< global id to emit counting
@ -67,6 +68,11 @@ namespace esignal {
* @return requested decription.
*/
virtual const std::string& getDescription() const;
/**
* @brief Tag the signal as periodic...
* @param[in] _state state of the periodic element
*/
void setPeriodic(bool _state);
};
//! @not-in-doc
std::ostream& operator <<(std::ostream& _os, const esignal::Base& _obj);

View File

@ -23,11 +23,17 @@ void esignal::Signal<T_ARGS...>::emit(const T_ARGS&... _args) {
#endif
// TODO : Add protection ... but how ...
m_callInProgress++;
if (m_periodic == false) {
ESIGNAL_DEBUG(esignal::logIndent(m_callInProgress-1) << " signal{" << tmpID << "} : '" << getName() << "' ***/" << m_executors.size());
for (size_t iii=0; iii < m_executors.size(); ++iii) {
ESIGNAL_VERBOSE(esignal::logIndent(m_callInProgress-1) << " {" << tmpID << "} : " << iii);
m_executors[iii]->emit(_args...);
}
} else {
for (size_t iii=0; iii < m_executors.size(); ++iii) {
m_executors[iii]->emit(_args...);
}
}
if (m_callInProgress == 1) {
bool haveRemove = false;
auto it = m_executors.begin();