#ifndef __UT_SERVICE_APPLICATION_HPP__ #define __UT_SERVICE_APPLICATION_HPP__ #include #define SERVICE_REGISTER(SERVICE) \ class SERVICE##Register \ { \ public: \ SERVICE##Register() \ { \ unitree::common::ServiceApplication::Instance()->RegistService(); \ } \ static SERVICE##Register mRegister; \ }; \ SERVICE##Register SERVICE##Register::mRegister = SERVICE##Register(); namespace unitree { namespace common { class ServiceApplication { public: static ServiceApplication* Instance() { static ServiceApplication inst; return &inst; } template void RegistService() { mServicePtr = ServicePtr(new SERVICE()); } void Init(const std::string& configFileName); void Start(); void Stop(); private: ServiceApplication(); protected: ServicePtr mServicePtr; }; } } #endif//__UT_SERVICE_APPLICATION_HPP__