整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
55
util/Configurable.h
Normal file
55
util/Configurable.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#ifndef E6D074E1_FEDB_4EFB_902B_95FF6BD2EB09
|
||||
#define E6D074E1_FEDB_4EFB_902B_95FF6BD2EB09
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "Configuration.h"
|
||||
#include <unordered_set>
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* MACROS
|
||||
*******************************************************************************
|
||||
*/
|
||||
#define CONFIGURABLE_DECLARE_PARAMETER(name, type) \
|
||||
type get##name() \
|
||||
{ \
|
||||
return config().getParameter<type>(#name); \
|
||||
} \
|
||||
void set##name(const type value) \
|
||||
{ \
|
||||
config().setParameter(#name, value); \
|
||||
} \
|
||||
const std::string _##name = (#name);
|
||||
|
||||
namespace Util
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class Configurable
|
||||
{
|
||||
public:
|
||||
using ParameterNames = Configuration::ParameterNames;
|
||||
|
||||
public:
|
||||
void commit();
|
||||
Configuration& config();
|
||||
|
||||
protected:
|
||||
virtual void onConfigChanged(ParameterNames& names) = 0;
|
||||
|
||||
private:
|
||||
Configuration _config;
|
||||
};
|
||||
|
||||
inline Configuration& Configurable::config()
|
||||
{
|
||||
return _config;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue