单例模式:
#pragma once
#include <iostream>
class IncrementalDBLoader {
public:
static IncrementalDBLoader& instance(){
static IncrementalDBLoader s_g_loader ;
return s_g_loader;
}
private:
IncrementalDBLoader(){} // Constructor
IncrementalDBLoader(IncrementalDBLoader const&); // Don't Implement
void operator=(IncrementalDBLoader const&); // Don't implement
private:
};
状态机部分代码片:
int stateMgr::catchPic() {
switch (m_state) {
case STATE_INITED:
if (this->doCatchPic() == 0) {
this->setState(STATE_PIC_CAPTURED);
} else {
this->setState(STATE_NOT_INITED);
}
break;
default:
LOG << "Not Required init STATE" << std::endl;
break;
}
}