#include <driver.h>
Public Types | |
typedef char | state_t |
Public Member Functions | |
void | clearRecoveryComplete () |
bool | close () |
Driver () | |
virtual std::string | getID ()=0 |
bool | getRecoveryComplete () |
state_t | getState () |
const std::string | getStateName () |
const std::string | getStatusMessage () |
bool | getStatusOk () |
bool | goClosed () |
bool | goOpened () |
bool | goRunning () |
bool | goState (state_t target) |
bool | isClosed () |
bool | isOpened () |
bool | isRunning () |
bool | isStopped () |
bool | lowerState (state_t target) |
bool | open () |
bool | raiseState (state_t target) |
void | setPostOpenHook (hookFunction f) |
void | setStatusMessage (const std::string &msg, bool ok=false, bool recovery_complete=false) |
void | setStatusMessagef (const char *format,...) |
bool | start () |
bool | stop () |
virtual | ~Driver () |
Static Public Member Functions | |
static const std::string & | getStateName (state_t s) |
Public Attributes | |
boost::recursive_mutex | mutex_ |
Static Public Attributes | |
static const state_t | CLOSED = 0 |
static const state_t | OPENED = 1 |
static const state_t | RUNNING = 2 |
Protected Types | |
typedef boost::function< void() > | hookFunction |
Protected Member Functions | |
virtual void | doClose ()=0 |
virtual void | doOpen ()=0 |
virtual void | doStart ()=0 |
virtual void | doStop ()=0 |
Protected Attributes | |
hookFunction | postOpenHook |
state_t | state_ |
Private Member Functions | |
const std::string & | getTransitionName (void(Driver::*transition)()) |
bool | tryTransition (state_t target, void(Driver::*transition)()) |
Private Attributes | |
std::string | status_message_ |
boost::mutex | status_message_mutex_ |
bool | status_ok_ |
bool | status_recovery_complete_ |
State transition functions assume that they are called from the correct state. It is the caller's responsibility to check that the state is correct. The Driver mutex_ should always be locked by the caller before checking the current state and throughout the call to the transition function.
State should not change between calls to the transition function except for transitions from RUNNING to STOPPED. The device must hold its lock while doing this transition to allow the caller to enforce that stop is only called from the RUNNING state.
Transitions may fail. It is the caller's responsibility to check success by looking at the device's state_. After a failure, the device can set itself into any state. For example, if a call to start() fails, the device may end up in the CLOSED state.
|
protected |
typedef char driver_base::Driver::state_t |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
pure virtual |
|
inline |
|
inlinestatic |
|
inline |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
static |
|
protected |
|
private |
|
private |