整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
115
Application.h
Normal file
115
Application.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
#ifndef C7F1A9D3_4E28_4B60_9C15_8A3E6D2F0B94
|
||||
#define C7F1A9D3_4E28_4B60_9C15_8A3E6D2F0B94
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include <Poco/BasicEvent.h>
|
||||
#include <Poco/Dynamic/Var.h>
|
||||
#include <Poco/JSON/Array.h>
|
||||
#include <Poco/JSON/Object.h>
|
||||
#include <Poco/JSON/Parser.h>
|
||||
#include <Poco/Net/IPAddress.h>
|
||||
#include <Poco/Net/NetworkInterface.h>
|
||||
#include <Poco/Util/Application.h>
|
||||
#include <atomic>
|
||||
#include "util/JsonUtil.h"
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CONSTANTS
|
||||
*******************************************************************************
|
||||
*/
|
||||
#define APPLICATION_VERSION application().version()
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* MACROS
|
||||
*******************************************************************************
|
||||
*/
|
||||
#define application() (*(Application::getInstance()))
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* TYPEDEFS
|
||||
*******************************************************************************
|
||||
*/
|
||||
using ConfigurationPtr = Poco::Util::AbstractConfiguration::Ptr;
|
||||
using Configuration = Poco::Util::AbstractConfiguration;
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class Application: public Poco::Util::Application
|
||||
{
|
||||
public:
|
||||
struct SystemStatus
|
||||
{
|
||||
};
|
||||
|
||||
public:
|
||||
static const std::string ROOT_CONFIG;
|
||||
|
||||
Poco::BasicEvent<std::string> ConfigChanged;
|
||||
Poco::BasicEvent<void> ApplicationExitNotify;
|
||||
|
||||
protected:
|
||||
void initialize(Poco::Util::Application& self) override;
|
||||
void uninitialize() override;
|
||||
int main(const std::vector<std::string>& args) override;
|
||||
|
||||
std::string getConfigFilePath(const std::string& label);
|
||||
|
||||
template <class T> T& findConfig(const std::string& label) const
|
||||
{
|
||||
return *static_cast<T*>(config().find(label).get());
|
||||
}
|
||||
|
||||
void initConfigAll();
|
||||
void initConfig(const std::string& label);
|
||||
|
||||
public:
|
||||
std::string version() const;
|
||||
Poco::Util::AbstractConfiguration& getConfig() const;
|
||||
Poco::Util::AbstractConfiguration& getConfig(const std::string& label) const;
|
||||
|
||||
void saveConfig(const std::string& label);
|
||||
|
||||
void loadConfig(const std::string& label, std::istream& istr);
|
||||
|
||||
void loadConfig(const std::string& label, const std::string& istr);
|
||||
|
||||
void dumpConfig(const std::string& label, std::ostream& ostr);
|
||||
|
||||
void configNotifyAsync(const std::string& label);
|
||||
|
||||
void restoreFactorySettings();
|
||||
|
||||
void reboot(uint32_t delay = 2000);
|
||||
|
||||
void setSystemTime(uint32_t timestamp, int timezone = 8);
|
||||
|
||||
void exit();
|
||||
|
||||
void upgrade(const std::string& file);
|
||||
|
||||
static Application* getInstance()
|
||||
{
|
||||
Poco::Util::Application& app = instance();
|
||||
return static_cast<Application*>(&app);
|
||||
}
|
||||
|
||||
private:
|
||||
Poco::Thread _delayRebootThread;
|
||||
std::atomic<bool> _exitRequst;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue