Baseclass for applications rt_appl
The baseclass rt_appl contains many of the initializations and supervision of events
described above. By subclassing rt_appl you don't have to supply any code for this, it
is done by rt_appl. rt_appl contains three virtual functions that are to be implemented
by the subclass, open(), close() and scan(). open() is used at initialization to direct
link to attributes anad object, scan() is called cyclic with supplied cycletime, and in
close() you remove the direct links.
rt_appl handles this:
- Initialization of gdh, errh and qcom
- Setting of application status at startup and restart
- Handling events for soft restart and termination
- Timestamps to avoid timeout
This example shows the application ra_appl subclassing rt_appl.
class ra_appl : public rt_appl {
public:
ra_appl() : rt_appl( "ra_appl", errh_eAnix_appl1) {}
void open();
void close();
void scan();
};
void ra_appl::open()
{
// Link to database objects
}
void ra_appl::close()
{
// Unlink to database objects
}
void ra_appl::scan()
{
// Do something
}
int main()
{
ra_appl appl;
appl.init();
appl.register_appl( "Nodes-MyNode-MyAppl");
appl.mainloop();
}