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

@@ -43,6 +43,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\node\ripple_NullBackendFactory.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\node\ripple_SqliteBackendFactory.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1345,6 +1351,7 @@
<ClInclude Include="..\..\modules\ripple_app\node\ripple_NodeObject.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_NodeStore.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_LevelDBBackendFactory.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_NullBackendFactory.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_SqliteBackendFactory.h" />
<ClInclude Include="..\..\modules\ripple_app\ripple_app.h" />
<ClInclude Include="..\..\modules\ripple_basics\containers\ripple_KeyCache.h" />

View File

@@ -861,6 +861,9 @@
<ClCompile Include="..\..\modules\ripple_app\node\ripple_LevelDBBackendFactory.cpp">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\node\ripple_NullBackendFactory.cpp">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3.h">
@@ -1608,6 +1611,9 @@
<ClInclude Include="..\..\modules\ripple_app\node\ripple_LevelDBBackendFactory.h">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_app\node\ripple_NullBackendFactory.h">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\cpp\ripple\ripple.proto" />

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

View File

@@ -96,8 +96,9 @@ namespace ripple
#include "node/ripple_NodeObject.h"
#include "node/ripple_NodeStore.h"
#include "node/ripple_SqliteBackendFactory.h"
#include "node/ripple_LevelDBBackendFactory.h"
#include "node/ripple_NullBackendFactory.h"
#include "node/ripple_SqliteBackendFactory.h"
#include "src/cpp/ripple/ripple_SHAMapItem.h"
#include "src/cpp/ripple/ripple_SHAMapNode.h"
@@ -237,6 +238,7 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
#include "node/ripple_NodeObject.cpp"
#include "node/ripple_NodeStore.cpp"
#include "node/ripple_LevelDBBackendFactory.cpp"
#include "node/ripple_NullBackendFactory.cpp"
#include "node/ripple_SqliteBackendFactory.cpp"
#include "src/cpp/ripple/Ledger.cpp"