Refactor NodeStore:

Manager is changed to be a Meyer's singleton, with factories automatically
registering upon construction.
This commit is contained in:
Vinnie Falco
2014-12-28 08:24:48 -08:00
parent 6283801981
commit 96fbcc9a5a
46 changed files with 471 additions and 780 deletions

View File

@@ -17,6 +17,10 @@
*/
//==============================================================================
#include <ripple/nodestore/Factory.h>
#include <ripple/nodestore/Manager.h>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple {
namespace NodeStore {
@@ -75,6 +79,16 @@ private:
class NullFactory : public Factory
{
public:
NullFactory()
{
Manager::instance().insert(*this);
}
~NullFactory()
{
Manager::instance().erase(*this);
}
std::string
getName () const
{
@@ -91,12 +105,7 @@ public:
}
};
//------------------------------------------------------------------------------
std::unique_ptr <Factory> make_NullFactory ()
{
return std::make_unique <NullFactory> ();
}
static NullFactory nullFactory;
}
}