first commit
This commit is contained in:
65
include/framework/data/registry.h
Normal file
65
include/framework/data/registry.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#ifndef __NREGISTRY__
|
||||
#define __NREGISTRY__
|
||||
|
||||
|
||||
#include "metafile/nml.h"
|
||||
#include "messaging/messaging.h"
|
||||
|
||||
|
||||
namespace GS {
|
||||
|
||||
enum RegistryMessage
|
||||
{
|
||||
RegistryMsg_None = 0, ///< No message.
|
||||
RegistryMsg_StartKeyChangeBatch,
|
||||
RegistryMsg_KeyChange,
|
||||
RegistryMsg_EndKeyChangeBatch
|
||||
};
|
||||
|
||||
enum RegistryRValue
|
||||
{
|
||||
RegistryReturn_Ok = 0
|
||||
};
|
||||
|
||||
//
|
||||
struct RegistryKeyChange
|
||||
{
|
||||
String key;
|
||||
RegistryKeyChange(const char *k) { key = String(k).TrimChar(';'); }
|
||||
};
|
||||
|
||||
struct Registry;
|
||||
|
||||
/// Registry listener.
|
||||
struct RegistryListener
|
||||
{
|
||||
virtual RegistryRValue ProcessMessage(RegistryMessage message, const Registry *from, const void *parm) = 0;
|
||||
virtual ~RegistryListener() {}
|
||||
};
|
||||
|
||||
/*
|
||||
@short Registry.
|
||||
@author Emmanuel Julien (ejulien@gsworks.fr)
|
||||
*/
|
||||
struct Registry : public Messaging::Broadcaster <RegistryMessage, RegistryListener, Registry *>, public NML::File
|
||||
{
|
||||
NML::Tag *CreateKey(const char *path, const Variant *value = 0, bool recursive = true);
|
||||
NML::Tag *CreateKey(const char *path, const Variant &value, bool recursive = true);
|
||||
bool DeleteKey(const char *path);
|
||||
|
||||
/// Get the float value of a given key.
|
||||
float GetReal(const char *path, float default_value = 0) const;
|
||||
/// Get the boolean value of a given key.
|
||||
bool GetBool(const char *path, bool default_value = false) const;
|
||||
};
|
||||
|
||||
} // GS
|
||||
|
||||
|
||||
#endif // __NREGISTRY__
|
||||
Reference in New Issue
Block a user