#include #include #include #include #define FAIL -1 class MyDriver : public Driver { private: MyDriver(); // not implemented public: MyDriver(ConfigFile * cf, int section); public: virtual ~MyDriver(); public: virtual int Setup(); public: virtual int Shutdown(); private: virtual void Main(); }; // factory function Driver * MyDriver_Init(ConfigFile * cf, int section) { return new MyDriver(cf, section); } // registration function void MyDriver_Register(DriverTable * table) { table->AddDriver("mydriver", MyDriver_Init); } extern "C" { int player_driver_init(DriverTable * table) { MyDriver_Register(table); return 0; } } // just for example: #define SOMETHING_WRONG 0 // Single interface example: MyDriver::MyDriver(ConfigFile * cf, int section) : Driver(cf, section, PLAYER_CAMERA_CODE, PLAYER_READ_MODE, sizeof(player_camera_data_t), 0, 10, 10) { if (SOMETHING_WRONG) { this->SetError(FAIL); return; } } MyDriver::~MyDriver() { } int MyDriver::Setup() { if (SOMETHING_WRONG) return FAIL; this->StartThread(); return 0; } int MyDriver::Shutdown() { this->StopThread(); return 0; } void MyDriver::Main() { for (;;) { pthread_testcancel(); } }