Skip to content

Commit

Permalink
Move classes to registry namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 11, 2017
1 parent 8ee895d commit 2f8a573
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
6 changes: 5 additions & 1 deletion plugins/xmlregistry/RegistryTree.cpp
Expand Up @@ -7,7 +7,9 @@

#include "wxutil/IConv.h"

// Constructor
namespace registry
{

RegistryTree::RegistryTree() :
_topLevelNode(TOPLEVEL_NODE_NAME),
_defaultImportNode(std::string("/") + _topLevelNode),
Expand Down Expand Up @@ -307,3 +309,5 @@ void RegistryTree::dump() const
{
_tree.saveToFile("-");
}

}
5 changes: 5 additions & 0 deletions plugins/xmlregistry/RegistryTree.h
Expand Up @@ -2,6 +2,9 @@

#include "xmlutil/Document.h"

namespace registry
{

const char* const TOPLEVEL_NODE_NAME = "darkradiant";

class RegistryTree
Expand Down Expand Up @@ -74,3 +77,5 @@ class RegistryTree
*/
std::string prepareKey(const std::string& key);
};

}
9 changes: 7 additions & 2 deletions plugins/xmlregistry/XMLRegistry.cpp
@@ -1,4 +1,4 @@
#include "XMLRegistry.h" // The Abstract Base Class
#include "XMLRegistry.h"

#include <iostream>
#include <stdexcept>
Expand All @@ -11,6 +11,9 @@
#include "string/string.h"
#include "wxutil/IConv.h"

namespace registry
{

XMLRegistry::XMLRegistry() :
_queryCounter(0),
_changesSinceLastSave(0),
Expand Down Expand Up @@ -314,8 +317,10 @@ void XMLRegistry::initialiseModule(const ApplicationContext& ctx)
module::GlobalModuleRegistry().signal_allModulesUninitialised().connect(
sigc::mem_fun(this, &XMLRegistry::shutdown));

_autosaver.reset(new registry::Autosaver([this]()
_autosaver.reset(new Autosaver([this]()
{
return _changesSinceLastSave > 0;
}));
}

}
35 changes: 20 additions & 15 deletions plugins/xmlregistry/XMLRegistry.h
Expand Up @@ -28,14 +28,17 @@
#include "RegistryTree.h"
#include "Autosaver.h"

namespace registry
{

class XMLRegistry :
public Registry
{
private:
// The map of registry key signals. There is one signal per key, but a
// signal can of course be connected to multiple slots.
typedef std::map<const std::string, sigc::signal<void> > KeySignals;
mutable KeySignals _keySignals;
// The map of registry key signals. There is one signal per key, but a
// signal can of course be connected to multiple slots.
typedef std::map<const std::string, sigc::signal<void> > KeySignals;
mutable KeySignals _keySignals;

// The "install" tree, is basically treated as read-only
RegistryTree _standardTree;
Expand All @@ -50,13 +53,13 @@ class XMLRegistry :
// Change tracking counter, is reset when saveToDisk() is called
unsigned int _changesSinceLastSave;

// TRUE if the registry has already been saved to disk
// At this point no more write operations should be made
// to the registry
bool _shutdown;
// TRUE if the registry has already been saved to disk
// At this point no more write operations should be made
// to the registry
bool _shutdown;

// The autosaver
std::unique_ptr<registry::Autosaver> _autosaver;
// Auto-save helper
std::unique_ptr<Autosaver> _autosaver;

public:
/* Constructor:
Expand Down Expand Up @@ -84,8 +87,8 @@ class XMLRegistry :

// Set the value of the given attribute at the specified <path>.
void setAttribute(const std::string& path,
const std::string& attrName,
const std::string& attrValue) override;
const std::string& attrName,
const std::string& attrValue) override;

// Loads the string value of the given attribute of the node at <path>.
std::string getAttribute(const std::string& path, const std::string& attrName) override;
Expand Down Expand Up @@ -114,7 +117,7 @@ class XMLRegistry :
*/
void exportToFile(const std::string& key, const std::string& filename) override;

sigc::signal<void> signalForKey(const std::string& key) const override;
sigc::signal<void> signalForKey(const std::string& key) const override;

// RegisterableModule implementation
const std::string& getName() const override;
Expand All @@ -127,7 +130,9 @@ class XMLRegistry :

void emitSignalForKey(const std::string& changedKey);

// Invoked after all modules have been uninitialised
void shutdown();
// Invoked after all modules have been uninitialised
void shutdown();
};
typedef std::shared_ptr<XMLRegistry> XMLRegistryPtr;

}
2 changes: 1 addition & 1 deletion plugins/xmlregistry/XMLRegistryModule.cpp
Expand Up @@ -9,5 +9,5 @@ extern "C" void DARKRADIANT_DLLEXPORT RegisterModule(IModuleRegistry& registry)
{
module::performDefaultInitialisation(registry);

registry.registerModule(XMLRegistryPtr(new XMLRegistry));
registry.registerModule(std::make_shared<registry::XMLRegistry>());
}

0 comments on commit 2f8a573

Please sign in to comment.