Add null backend factory

This commit is contained in:
Vinnie Falco
2013-07-10 13:06:28 -07:00
parent 01b57e984c
commit 7d2cc6887d
5 changed files with 116 additions and 1 deletions

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
class NullBackendFactory::Backend : public NodeStore::Backend
{
public:
Backend ()
{
}
~Backend ()
{
}
std::string getDataBaseName()
{
return std::string ();
}
bool store (NodeObject::ref obj)
{
return false;
}
bool bulkStore (const std::vector< NodeObject::pointer >& objs)
{
return false;
}
NodeObject::pointer retrieve (uint256 const& hash)
{
return NodeObject::pointer ();
}
void visitAll (FUNCTION_TYPE <void (NodeObject::pointer)> func)
{
}
};
//------------------------------------------------------------------------------
NullBackendFactory::NullBackendFactory ()
{
}
NullBackendFactory::~NullBackendFactory ()
{
}
NullBackendFactory& NullBackendFactory::getInstance ()
{
static NullBackendFactory instance;
return instance;
}
String NullBackendFactory::getName () const
{
return "none";
}
NodeStore::Backend* NullBackendFactory::createInstance (StringPairArray const& keyValues)
{
return new NullBackendFactory::Backend;
}
//------------------------------------------------------------------------------

View File

@@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
#ifndef RIPPLE_NULLBACKENDFACTORY_H_INCLUDED
#define RIPPLE_NULLBACKENDFACTORY_H_INCLUDED
/** Factory to produce a null backend.
This is for standalone / testing mode.
*/
class NullBackendFactory : public NodeStore::BackendFactory
{
private:
class Backend;
NullBackendFactory ();
~NullBackendFactory ();
public:
static NullBackendFactory& getInstance ();
String getName () const;
NodeStore::Backend* createInstance (StringPairArray const& keyValues);
};
#endif