Skip to content

Commit

Permalink
database: Use new KeyedConfigGroup mechanism.
Browse files Browse the repository at this point in the history
  • Loading branch information
CFSworks committed Jul 9, 2015
1 parent b47a8b1 commit 8f8fd56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 61 deletions.
29 changes: 2 additions & 27 deletions src/database/DatabaseBackend.cpp
Expand Up @@ -4,30 +4,5 @@
#include <string>
using namespace std;


#if NEW_BACKEND_CONFIG

// Unbundled backend config

static KeyedConfigGroup db_backend_config("backend", "type", dbserver_config);

BackendConfigGroup::BackendConfigGroup(const string& type) :
ConfigGroup(type, db_backend_config), m_type("type", type, this)
{
}

#else

// Bundled backend config

ConfigGroup db_backend_config("backend", dbserver_config);
ConfigVariable<string> db_backend_type("type", "yaml", db_backend_config);

bool have_backend(const string& backend)
{
return DBBackendFactory::singleton().has_backend(backend);
}
ConfigConstraint<string> db_backend_exists(have_backend, db_backend_type,
"No database backend exists for the given backend type.");

#endif
KeyedConfigGroup db_backend_config("backend", "type", dbserver_config);
ConfigVariable<string> db_backend_type("type", "yaml", db_backend_config);
26 changes: 2 additions & 24 deletions src/database/DatabaseBackend.h
Expand Up @@ -2,30 +2,8 @@
#include "DBOperation.h"
#include "config/ConfigVariable.h"


#if NEW_BACKEND_CONFIG

// Unbundled backend config

typedef ConfigNode BackendConfig;
class BackendConfigGroup : public ConfigGroup
{
public:
BackendConfigGroup(const std::string& type);

private:
// NOTE(Kevin): These are shared config variables for all BackendConfigGroups
BackendConfigVariable<std::string> m_type;
};

#else

// Bundled backend config

extern ConfigGroup db_backend_config;
extern ConfigVariable<std::string> db_backend_type;

#endif
extern KeyedConfigGroup db_backend_config;
extern ConfigVariable<std::string> db_backend_type;

class DatabaseBackend
{
Expand Down
13 changes: 3 additions & 10 deletions src/database/YAMLDatabase.cpp
Expand Up @@ -15,16 +15,9 @@ using dclass::Class;
using dclass::Field;
using namespace std;

#if NEW_BACKEND_CONFIG

static ConfigGroup yaml_backend_config("yaml", db_backend_config);
static ConfigVariable<string> foldername("foldername", "yaml_db", yaml_backend_config);

#else

static ConfigVariable<string> foldername("foldername", "yaml_db", db_backend_config);

#endif
static ConfigGroup yaml_backend_config("yaml", db_backend_config);
static ConfigVariable<string> foldername("foldername", "yaml_db", yaml_backend_config);
static ConfigVariable<string> type_yaml("type", "yaml", yaml_backend_config);

class YAMLDatabase : public OldDatabaseBackend
{
Expand Down

0 comments on commit 8f8fd56

Please sign in to comment.