rename some class
This commit is contained in:
@@ -14,7 +14,7 @@ file(
|
||||
source_files
|
||||
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-call.cpp
|
||||
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-object.cpp
|
||||
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-timer.cpp
|
||||
${workspaceRoot}/src/lib/libubus-cpp/src/uloop-timer.cpp
|
||||
)
|
||||
|
||||
add_library(
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _UBUS_TIMER_H
|
||||
#define _UBUS_TIMER_H
|
||||
#ifndef _ULOOP_TIMER_H
|
||||
#define _ULOOP_TIMER_H
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
@@ -39,23 +39,25 @@ extern "C" {
|
||||
|
||||
/*--------------------------------- CLASS ----------------------------------*/
|
||||
|
||||
class UBusTimer : public uloop_timeout {
|
||||
class ULoopTimer : public uloop_timeout {
|
||||
|
||||
// Disable copy construction and copy assignement
|
||||
UBusTimer (const UBusTimer&);
|
||||
UBusTimer &operator=(const UBusTimer&);
|
||||
ULoopTimer (const ULoopTimer&);
|
||||
ULoopTimer &operator=(const ULoopTimer&);
|
||||
|
||||
public:
|
||||
UBusTimer (void);
|
||||
virtual ~UBusTimer (void);
|
||||
ULoopTimer (void);
|
||||
virtual ~ULoopTimer (void);
|
||||
|
||||
virtual int Expire (void);
|
||||
int Start (unsigned int aTimerValue, bool aRepeat = false);
|
||||
int Tick (void);
|
||||
virtual int expire (void);
|
||||
int start (unsigned int a_timer_value, bool a_is_repeated = false);
|
||||
int stop (void);
|
||||
|
||||
int tick (void);
|
||||
|
||||
private:
|
||||
bool mRepeat;
|
||||
uint16_t mTimerValue;
|
||||
bool m_is_repeated;
|
||||
uint16_t m_timer_value;
|
||||
};
|
||||
|
||||
#endif /* _UBUS_TIMER_H */
|
||||
#endif /* _ULOOP_TIMER_H */
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "ubus-cpp/ubus-timer.h"
|
||||
#include "ubus-cpp/uloop-timer.h"
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
@@ -35,60 +35,73 @@
|
||||
*
|
||||
* @brief Callback used when a Timer has expired.
|
||||
*/
|
||||
static void timer_callback (struct uloop_timeout *aTimeout)
|
||||
static void timer_callback (struct uloop_timeout *a_timeout)
|
||||
{
|
||||
UBusTimer *aTmp = static_cast<UBusTimer *>(aTimeout);
|
||||
aTmp->Tick();
|
||||
ULoopTimer *the_timer = static_cast<ULoopTimer *>(a_timeout);
|
||||
|
||||
the_timer->tick();
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn UBusTimer
|
||||
* @fn ULoopTimer
|
||||
*
|
||||
* @brief Constructor of the Timer UBUS Object.
|
||||
* @brief Constructor of the Uloop Timer Object.
|
||||
*/
|
||||
UBusTimer::UBusTimer (void)
|
||||
ULoopTimer::ULoopTimer (void)
|
||||
{
|
||||
// Uloop Timer Init.
|
||||
cb = timer_callback;
|
||||
pending = 0;
|
||||
|
||||
// UBus Timer.
|
||||
mRepeat = false;
|
||||
mTimerValue = 0;
|
||||
m_is_repeated = false;
|
||||
m_timer_value = 0;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn ~UBusTimer
|
||||
* @fn ~ULoopTimer
|
||||
*
|
||||
* @brief Destructor of the Timer UBUS Object.
|
||||
* @brief Destructor of the Ullop Timer Object.
|
||||
*/
|
||||
UBusTimer::~UBusTimer (void)
|
||||
ULoopTimer::~ULoopTimer (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Start the Timer
|
||||
*
|
||||
* @fn start
|
||||
* @param aTimerValue is the amount of time (in milliseconds) before the timer
|
||||
* expires.
|
||||
* @brief Start the Timer object.
|
||||
*/
|
||||
int UBusTimer::Start (unsigned int aTimerValue, bool aRepeat)
|
||||
int ULoopTimer::start (unsigned int a_timer_value, bool a_is_repeated)
|
||||
{
|
||||
mTimerValue = aTimerValue;
|
||||
mRepeat = aRepeat;
|
||||
m_timer_value = a_timer_value;
|
||||
m_is_repeated = a_is_repeated;
|
||||
|
||||
return uloop_timeout_set (this, mTimerValue);
|
||||
return uloop_timeout_set (this, m_timer_value);
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Expire
|
||||
* @fn stop
|
||||
*
|
||||
* @brief Stop the Timer object.
|
||||
*/
|
||||
int ULoopTimer::stop (void)
|
||||
{
|
||||
return uloop_timeout_cancel (this);
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn expire
|
||||
*
|
||||
* @brief Method Should be overrided.
|
||||
*/
|
||||
int UBusTimer::Expire (void)
|
||||
int ULoopTimer::expire (void)
|
||||
{
|
||||
//fprintf (stderr, "UBusTimer::Expire\n");
|
||||
return 0;
|
||||
@@ -96,18 +109,16 @@ int UBusTimer::Expire (void)
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Tick
|
||||
* @fn tick
|
||||
*
|
||||
* @brief Method called when the Timer has expired.
|
||||
*/
|
||||
int UBusTimer::Tick (void)
|
||||
int ULoopTimer::tick (void)
|
||||
{
|
||||
//fprintf (stderr, "UBusTimer::Tick\n");
|
||||
// fprintf (stderr, "UBusTimer::Tick\n");
|
||||
|
||||
if (m_is_repeated == true)
|
||||
uloop_timeout_set (this, m_timer_value);
|
||||
|
||||
Expire ();
|
||||
|
||||
if (mRepeat == true)
|
||||
uloop_timeout_set (this, mTimerValue);
|
||||
|
||||
return 0;
|
||||
return expire ();
|
||||
}
|
||||
Reference in New Issue
Block a user