#ifndef __UT_SERVICE_BASE_HPP__ #define __UT_SERVICE_BASE_HPP__ #include namespace unitree { namespace common { class ServiceBase { public: ServiceBase(); virtual ~ServiceBase(); virtual void Parse(const std::string& configFileName); virtual void Init(); virtual void Register(); virtual void Start(); virtual void Wait(); virtual void Stop(); protected: /* * Get field: ServiceName */ const std::string& GetServiceName() const; const std::string& GetCpuIds() const; /* * Get top-level field/value */ const Any& GetGlobalParameter(const std::string& name) const; /* * Get top-level field: Parameter */ bool HasParameter(const std::string& name) const; /* * Get top-level field: Parameter */ const JsonMap& GetParameter() const; /* * Get field from top-level field: Parameter */ const Any& GetParameter(const std::string& name) const; /* * Get field from top-level field: Parameter */ template const T& GetParameter(const std::string& name) const { return mConfig.GetParameter(name); } /* * Get field from top-level field: Parameter */ template T GetNumberParameter(const std::string& name) const { return mConfig.GetNumberParameter(name); } /* * Get field from top-level field: Parameter */ template T GetParameter(const std::string& name, const T& defValue) const { return mConfig.GetParameter(name, defValue); } template T GetNumberParameter(const std::string& name, const T& defValue) const { return mConfig.GetNumberParameter(name, defValue); } private: ServiceConfig mConfig; }; typedef std::shared_ptr ServicePtr; } } #endif//__UT_SERVICE_BASE_HPP__