doc ru, printf() before assert in containers
This commit is contained in:
@@ -42,7 +42,6 @@ public:
|
||||
double interval() const {return interval_;}
|
||||
void setInterval(double i);
|
||||
|
||||
//! \brief Return \c true if thread is running
|
||||
bool isRunning() const {return running_;}
|
||||
|
||||
bool isStopped() const {return !running_;}
|
||||
@@ -79,45 +78,64 @@ class PIP_EXPORT PITimer: public PIObject {
|
||||
public:
|
||||
NO_COPY_CLASS(PITimer)
|
||||
|
||||
//! \brief Constructs timer with PITimer::Thread implementation
|
||||
//! \~english Constructs timer with PITimer::Thread implementation
|
||||
//! \~russian Создает таймер с реализацией PITimer::Thread
|
||||
explicit PITimer();
|
||||
|
||||
//! \brief Timer implementations
|
||||
//! \~english Timer implementations
|
||||
//! \~russian Реализация таймера
|
||||
enum TimerImplementation {
|
||||
Thread /*! Timer works in his own thread. Intervals are measured by the system time */ = 0x01,
|
||||
ThreadRT /*! Using POSIX timer with SIGEV_THREAD notification. \attention Doesn`t support on Windows and Mac OS! */ = 0x02,
|
||||
Pool /*! Using single TimerPool for all timers with this implementation. TimerPool works as Thread implementation and
|
||||
* sequentially executes all timers. \attention Use this implementation with care! */ = 0x04
|
||||
Thread /*!
|
||||
\~english Timer works in his own thread. Intervals are measured by the system time
|
||||
\~russian Таймер работает в собственном потоке. Интервалы измеряются с помощью системного времени
|
||||
*/ = 0x01,
|
||||
ThreadRT /*!
|
||||
\~english Using POSIX timer with SIGEV_THREAD notification. \attention Doesn`t support on Windows and Mac OS!
|
||||
\~russian Использовать таймер POSIX с SIGEV_THREAD уведомлением. \attention Не поддерживается на Windows и Mac OS!
|
||||
*/ = 0x02,
|
||||
Pool /*!
|
||||
\~english Using single TimerPool for all timers with this implementation. TimerPool works as Thread implementation and
|
||||
sequentially executes all timers. \attention Use this implementation with care!
|
||||
\~russian Использовать единый TimerPool для всех таймеров с этой реализацией. TimerPool реализован через Thread и
|
||||
последовательно исполняет все таймеры. \attention Осторожнее с этой реализацией!
|
||||
*/ = 0x04
|
||||
};
|
||||
|
||||
//! \brief Constructs timer with "ti" implementation
|
||||
//! \~english Constructs timer with "ti" implementation
|
||||
//! \~russian Создает таймер с реализацией "ti"
|
||||
explicit PITimer(TimerImplementation ti);
|
||||
|
||||
//! \brief Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation
|
||||
//! \~english Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation
|
||||
//! \~russian Создает таймер со слотом "slot", данными "data" и реализацией "ti"
|
||||
explicit PITimer(TimerEvent slot, void * data = 0, TimerImplementation ti = Thread);
|
||||
|
||||
//! \brief Constructs timer with "slot" slot void(), and "ti" implementation
|
||||
//! \~english Constructs timer with "slot" slot void(), and "ti" implementation
|
||||
//! \~russian Создает таймер со слотом "slot" и реализацией "ti"
|
||||
explicit PITimer(std::function<void ()> slot, TimerImplementation ti = Thread);
|
||||
|
||||
//! \brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
|
||||
//! \~english Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
|
||||
//! \~russian Создает таймер со слотом "slot", данными "data" и реализацией "ti"
|
||||
explicit PITimer(std::function<void (void *)> slot, void * data, TimerImplementation ti = Thread);
|
||||
|
||||
virtual ~PITimer();
|
||||
|
||||
|
||||
//! \brief Returns timer implementation
|
||||
//! \~english Returns timer implementation
|
||||
//! \~russian Возвращает реализацию таймера
|
||||
PITimer::TimerImplementation implementation() const {return imp_mode;}
|
||||
|
||||
//! \brief Returns timer loop delay in milliseconds
|
||||
//! \~english Returns timer loop delay in milliseconds
|
||||
//! \~russian Возвращает задержку цикла таймера в миллисекундах
|
||||
double interval() const;
|
||||
|
||||
//! \brief Set timer loop delay in milliseconds
|
||||
EVENT_HANDLER1(void, setInterval, double, ms);
|
||||
|
||||
//! \brief Returns if timer is started
|
||||
//! \~english Returns if timer is started
|
||||
//! \~russian Возвращает работает ли таймер
|
||||
bool isRunning() const;
|
||||
|
||||
//! \brief Returns if timer is not started
|
||||
//! \~english Returns if timer is not started
|
||||
//! \~russian Возвращает остановлен ли таймер
|
||||
bool isStopped() const;
|
||||
|
||||
EVENT_HANDLER0(bool, start);
|
||||
@@ -126,24 +144,20 @@ public:
|
||||
EVENT_HANDLER0(bool, restart);
|
||||
|
||||
|
||||
/** \brief Start timer with \b interval() loop delay after \b delay_msecs delay.
|
||||
* \details Timer wait \b delay_msecs milliseconds and then normally starts with
|
||||
* \b interval() loop delay. */
|
||||
//! \~english Start timer with \a interval() loop delay after "delay_msecs" delay
|
||||
//! \~russian Запускает таймер с интервалом \a interval() после ожидания "delay_msecs"
|
||||
void startDeferred(double delay_ms);
|
||||
|
||||
/** \brief Start timer with \b interval_msecs loop delay after \b delay_msecs delay.
|
||||
* \details Timer wait \b delay_msecs milliseconds and then normally starts with
|
||||
* \b interval_msecs loop delay. */
|
||||
//! \~english Start timer with "interval_msecs" loop delay after "delay_msecs" delay
|
||||
//! \~russian Запускает таймер с интервалом "interval_msecs" после ожидания "delay_msecs"
|
||||
void startDeferred(double interval_ms, double delay_ms);
|
||||
|
||||
/** \brief Start timer with \b interval() loop delay after \b start_datetime date and time.
|
||||
* \details Timer wait until \b start_datetime and then normally starts with
|
||||
* \b interval() loop delay. */
|
||||
//! \~english Start timer with \a interval() loop delay after "start_datetime" date and time
|
||||
//! \~russian Запускает таймер с интервалом \a interval() после наступления "start_datetime"
|
||||
void startDeferred(PIDateTime start_datetime);
|
||||
|
||||
/** \brief Start timer with \b interval_msecs loop delay after \b start_datetime date and time.
|
||||
* \details Timer wait until \b start_datetime and then normally starts with
|
||||
* \b interval_msecs loop delay. */
|
||||
//! \~english Start timer with "interval_msecs" loop delay after "start_datetime" date and time
|
||||
//! \~russian Запускает таймер с интервалом "interval_msecs" после наступления "start_datetime"
|
||||
void startDeferred(double interval_ms, PIDateTime start_datetime);
|
||||
|
||||
EVENT_HANDLER0(bool, stop);
|
||||
@@ -151,43 +165,52 @@ public:
|
||||
bool waitForFinish() {return waitForFinish(-1);}
|
||||
bool waitForFinish(int timeout_msecs);
|
||||
|
||||
//! \brief Set custom data
|
||||
//! \~english Set custom data
|
||||
//! \~russian Установить данные, передаваемые в метод таймера
|
||||
void setData(void * data_) {data_t = data_;}
|
||||
|
||||
//! \brief Set timer tick function
|
||||
|
||||
//! \~english Returns common data passed to tick functions
|
||||
//! \~russian Возвращает данные, передаваемые в метод таймера
|
||||
void * data() const {return data_t;}
|
||||
|
||||
//! \~english Set timer tick function
|
||||
//! \~russian Установить вызываемый метод
|
||||
void setSlot(TimerEvent slot) {ret_func = slot;}
|
||||
|
||||
//! \brief Set timer tick function
|
||||
//! \~english Set timer tick function
|
||||
//! \~russian Установить вызываемый метод
|
||||
void setSlot(std::function<void ()> slot) {ret_func = [slot](void *, int){slot();};}
|
||||
|
||||
//! \brief Set timer tick function
|
||||
//! \~english Set timer tick function
|
||||
//! \~russian Установить вызываемый метод
|
||||
void setSlot(std::function<void (void *)> slot) {ret_func = [slot](void *d, int){slot(d);};}
|
||||
|
||||
//! \brief Returns common data passed to tick functions
|
||||
void * data() const {return data_t;}
|
||||
|
||||
void needLockRun(bool need) {lockRun = need;}
|
||||
EVENT_HANDLER0(void, lock) {mutex_.lock();}
|
||||
EVENT_HANDLER0(void, unlock) {mutex_.unlock();}
|
||||
|
||||
//! \brief Returns if timer should exec \a maybeCallQueuedEvents() at every tick.
|
||||
//! By default \b true
|
||||
//! \~english Returns if timer should exec \a maybeCallQueuedEvents() at every tick. By default \b true
|
||||
//! \~russian Возвращает должен ли таймер вызывать \a maybeCallQueuedEvents() каждый тик. По умолчанию \b true
|
||||
bool isCallQueuedEvents() const {return callEvents;}
|
||||
|
||||
//! \brief If set timer exec \a maybeCallQueuedEvents() at every tick.
|
||||
//! By default \b true
|
||||
//! \~english Set timer exec \a maybeCallQueuedEvents() at every tick
|
||||
//! \~russian Установает должен ли таймер вызывать \a maybeCallQueuedEvents() каждый тик
|
||||
void setCallQueuedEvents(bool yes) {callEvents = yes;}
|
||||
|
||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
//! \~english Add frequency delimiter "delim" with optional delimiter slot "slot"
|
||||
//! \~russian Добавляет делитель частоты "delim" с необязательным методом "slot"
|
||||
void addDelimiter(int delim, TimerEvent slot = 0) {delims << Delimiter(slot, delim);}
|
||||
|
||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
//! \~english Add frequency delimiter "delim" with optional delimiter slot "slot"
|
||||
//! \~russian Добавляет делитель частоты "delim" с необязательным методом "slot"
|
||||
void addDelimiter(int delim, std::function<void ()> slot) {delims << Delimiter([slot](void *, int){slot();}, delim);}
|
||||
|
||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
//! \~english Add frequency delimiter "delim" with optional delimiter slot "slot"
|
||||
//! \~russian Добавляет делитель частоты "delim" с необязательным методом "slot"
|
||||
void addDelimiter(int delim, std::function<void (void *)> slot) {delims << Delimiter([slot](void *d, int){slot(d);}, delim);}
|
||||
|
||||
//! \brief Remove all frequency delimiters \b delim.
|
||||
//! \~english Remove all frequency delimiters "delim"
|
||||
//! \~russian Удаляет все делители частоты "delim"
|
||||
void removeDelimiter(int delim) {for (int i = 0; i < delims.size_s(); ++i) if (delims[i].delim == delim) {delims.remove(i); i--;}}
|
||||
|
||||
EVENT_HANDLER0(void, clearDelimiters) {delims.clear();}
|
||||
@@ -197,33 +220,58 @@ public:
|
||||
//! \handlers
|
||||
//! \{
|
||||
|
||||
/** \fn bool start()
|
||||
* \brief Start timer with \a interval() loop delay
|
||||
* \details Start execution of timer functions with frequency = 1 / msecs Hz. */
|
||||
|
||||
/** \fn bool start(double msecs)
|
||||
* \brief Start timer with \b msecs loop delay
|
||||
* \details Start execution of timer functions with frequency = 1. / msecs Hz.
|
||||
* Instead of \a start(int msecs) function this variant allow start timer
|
||||
* with frequencies more than 1 kHz */
|
||||
|
||||
//! \fn void setInterval(double ms)
|
||||
//! \~english Set timer loop delay in milliseconds
|
||||
//! \~russian Установить интервал таймера "ms" миллисекунд
|
||||
|
||||
//! \fn bool start()
|
||||
//! \~english Start timer with \a interval() loop delay
|
||||
//! \~russian Запустить таймер с интервалом \a interval()
|
||||
//! \~\details
|
||||
//! \~english
|
||||
//! Start execution of timer functions with frequency = 1 / msecs Hz
|
||||
//! \~russian
|
||||
//! Запускает таймер с частотой = 1 / msecs Гц
|
||||
|
||||
//! \fn bool start(double msecs)
|
||||
//! \~english Start timer with "msecs" loop delay
|
||||
//! \~russian Запустить таймер с интервалом "msecs"
|
||||
//! \~\details
|
||||
//! \~english
|
||||
//! Start execution of timer functions with frequency = 1. / msecs Hz.
|
||||
//! Instead of \a start(int msecs) this function allow start timer
|
||||
//! with frequencies more than 1 kHz
|
||||
//! \~russian
|
||||
//! Запускает таймер с частотой = 1 / msecs Гц. В отличии от
|
||||
//! \a start(int msecs) этот метод позволяет запустить таймер с частотой
|
||||
//! более 1 кГц
|
||||
|
||||
//! \fn bool restart()
|
||||
//! \brief Stop and start timer with \a interval() loop delay
|
||||
//! \~english Stop and start timer with \a interval() loop delay
|
||||
//! \~russian Остановить и запустить таймер с интервалом \a interval()
|
||||
|
||||
//! \fn bool stop(bool wait = true)
|
||||
//! \brief Stop timer and wait for it finish if "wait"
|
||||
//! \~english Stop timer and wait for it finish if "wait"
|
||||
//! \~russian Остановить таймер и если "wait" то дождаться остановки
|
||||
|
||||
//! \fn void clearDelimiters()
|
||||
//! \brief Remove all frequency delimiters
|
||||
//! \~english Remove all frequency delimiters
|
||||
//! \~russian Удаляет все делители частоты
|
||||
|
||||
//! \}
|
||||
//! \events
|
||||
//! \{
|
||||
|
||||
/** \fn void tickEvent(void * data, int delimiter)
|
||||
* \brief Raise on timer tick
|
||||
* \details \b Data can be set with function \a setData(void * data) or from constructor.
|
||||
* \b Delimiter is frequency delimiter, 1 for main loop. */
|
||||
//! \fn void tickEvent(void * data, int delimiter)
|
||||
//! \~english Raise on timer tick
|
||||
//! \~russian Вызывается каждый тик таймера
|
||||
//! \~\details
|
||||
//! \~english
|
||||
//! "data" can be set with function \a setData() or from constructor.
|
||||
//! "delimiter" is frequency delimiter, 1 for main loop.
|
||||
//! \~russian
|
||||
//! "data" устанавливается методом \a setData() или в конструкторе.
|
||||
//! "delimiter" - делитель частоты, 1 для основного цикла
|
||||
|
||||
|
||||
//! \}
|
||||
@@ -243,8 +291,7 @@ protected:
|
||||
static void tickImpS(PITimer * t) {t->tickImp();}
|
||||
void tickImp();
|
||||
|
||||
//! Virtual timer execution function, similar to "slot" or event \a void timeout(void * data, int delimiter).
|
||||
//! By default is empty.
|
||||
//! Timer execution function, similar to "slot" or event \a timeout(). By default does nothing
|
||||
virtual void tick(void * data_, int delimiter) {}
|
||||
|
||||
void * data_t;
|
||||
|
||||
Reference in New Issue
Block a user