mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- add support for a future timeout callback mechanism
svn path=/trunk/; revision=33712
This commit is contained in:
parent
b0bbb622d9
commit
2dab0a3d0f
4 changed files with 155 additions and 0 deletions
|
@ -21,4 +21,5 @@
|
|||
<file>sysreg.cpp</file>
|
||||
<file>file_reader.cpp</file>
|
||||
<file>os_support.cpp</file>
|
||||
<file>timer_command_callback.cpp</file>
|
||||
</module>
|
||||
|
|
56
reactos/tools/sysreg/timer_callback.h
Normal file
56
reactos/tools/sysreg/timer_callback.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
#ifndef TIMER_CALLBACK_H__
|
||||
#define TIMER_CALLBACK_H__
|
||||
|
||||
|
||||
namespace System_
|
||||
{
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// TimerCallback
|
||||
///
|
||||
/// Description: base class for all timer callback functions
|
||||
|
||||
class TimerCallback
|
||||
{
|
||||
public:
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// TimerCallback
|
||||
///
|
||||
/// Description: constructor of class TimerCallback
|
||||
|
||||
TimerCallback() {}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// TimerCallback
|
||||
///
|
||||
/// Description: destructor of class TimerCallback
|
||||
|
||||
virtual ~TimerCallback() {}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// initialize
|
||||
///
|
||||
/// Description: this function is called when the timercallback object is initialized in
|
||||
/// in the callback mechanism
|
||||
|
||||
virtual bool initialize(){ return true;}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// hasExpired
|
||||
///
|
||||
/// Description: this function is called everytime timer event has started. The callback object
|
||||
/// should return true if the expiration function has expired.
|
||||
/// Note: the function should then also cleanup all consumed resourced
|
||||
|
||||
virtual bool hasExpired() = 0;
|
||||
}; //end of class TimerCallback
|
||||
|
||||
}// end of namespace System_
|
||||
|
||||
#endif
|
41
reactos/tools/sysreg/timer_command_callback.cpp
Normal file
41
reactos/tools/sysreg/timer_command_callback.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "timer_command_callback.h"
|
||||
|
||||
|
||||
namespace System_
|
||||
{
|
||||
using Sysreg_::ConfigParser;
|
||||
|
||||
string TimerCommandCallback::ROS_TIMER_COMMAND="ROS_TIMER_COMMAND";
|
||||
string TimerCommandCallback::ROS_TIMER_TIMEOUT="ROS_TIMER_TIMEOUT";
|
||||
|
||||
//---------------------------------------------------------------
|
||||
TimerCommandCallback::TimerCommandCallback(ConfigParser &conf_parser) : TimerCallback(), m_parser(conf_parser), m_Cmd(""), m_Timeout(0)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
TimerCommandCallback::~TimerCommandCallback()
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
bool TimerCommandCallback::initialize()
|
||||
{
|
||||
m_parser.getStringValue(ROS_TIMER_COMMAND, m_Cmd);
|
||||
m_parser.getIntValue(ROS_TIMER_TIMEOUT, m_Timeout);
|
||||
//FIXME
|
||||
// calculate current time
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
bool TimerCommandCallback::hasExpired()
|
||||
{
|
||||
|
||||
// FIXME
|
||||
// calculate current time
|
||||
// calculate difference
|
||||
// and invoke m_Cmd when it has expired
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end of namespace System_
|
57
reactos/tools/sysreg/timer_command_callback.h
Normal file
57
reactos/tools/sysreg/timer_command_callback.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
#ifndef TIMER_COMMAND_CALLBACK_H__ //timer_command_callback.h
|
||||
#define TIMER_COMMAND_CALLBACK_H__
|
||||
|
||||
#include "conf_parser.h"
|
||||
#include "timer_callback.h"
|
||||
|
||||
namespace System_
|
||||
{
|
||||
|
||||
class TimerCommandCallback : public TimerCallback
|
||||
{
|
||||
public:
|
||||
//---------------------------------------------------------------
|
||||
///
|
||||
/// TimerCommandCallback
|
||||
///
|
||||
/// Description: constructor of class TimerCommandCallback
|
||||
///
|
||||
/// @param conf_parser contains configuration data
|
||||
|
||||
TimerCommandCallback(Sysreg_::ConfigParser &conf_parser);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
///
|
||||
/// ~TimerCommandCallback
|
||||
///
|
||||
/// Description: destructor of class TimerCommandCallback
|
||||
|
||||
virtual ~TimerCommandCallback();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
///
|
||||
/// initialize
|
||||
///
|
||||
/// Description: initializes the callback object
|
||||
|
||||
virtual bool initialize();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
///
|
||||
/// hasExpired
|
||||
///
|
||||
/// Description: returns true when the callback object has expired
|
||||
|
||||
virtual bool hasExpired();
|
||||
protected:
|
||||
Sysreg_::ConfigParser & m_parser;
|
||||
string m_Cmd;
|
||||
long int m_Timeout;
|
||||
static string ROS_TIMER_TIMEOUT;
|
||||
static string ROS_TIMER_COMMAND;
|
||||
};
|
||||
|
||||
} /* EOF namspace System_ */
|
||||
|
||||
|
||||
#endif /* EOF TIMER_COMMAND_CALLBACK_H__ */
|
Loading…
Reference in a new issue