Ethereum  PoC-8
The C++ Implementation of Ethereum
DBFactory.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #pragma once
19 
20 #include "Common.h"
21 #include "db.h"
22 
23 #include <boost/filesystem.hpp>
24 #include <boost/program_options/options_description.hpp>
25 
26 namespace dev
27 {
28 namespace db
29 {
30 enum class DatabaseKind
31 {
32  LevelDB,
33  RocksDB,
34  MemoryDB
35 };
36 
41 boost::program_options::options_description databaseProgramOptions(
42  unsigned _lineLength = boost::program_options::options_description::m_default_line_length);
43 
44 bool isDiskDatabase();
46 void setDatabaseKindByName(std::string const& _name);
47 void setDatabaseKind(DatabaseKind _kind);
48 boost::filesystem::path databasePath();
49 
50 class DBFactory
51 {
52 public:
53  DBFactory() = delete;
54  ~DBFactory() = delete;
55 
56  static std::unique_ptr<DatabaseFace> create();
57  static std::unique_ptr<DatabaseFace> create(boost::filesystem::path const& _path);
58  static std::unique_ptr<DatabaseFace> create(DatabaseKind _kind);
59  static std::unique_ptr<DatabaseFace> create(
60  DatabaseKind _kind, boost::filesystem::path const& _path);
61 
62 private:
63 };
64 } // namespace db
65 } // namespace dev
dev::db::DatabaseKind
DatabaseKind
Definition: DBFactory.h:31
dev::db::databasePath
fs::path databasePath()
Definition: DBFactory.cpp:97
dev::db::isDiskDatabase
bool isDiskDatabase()
Definition: DBFactory.cpp:80
dev::db::databaseKind
DatabaseKind databaseKind()
Definition: DBFactory.cpp:92
dev::db::databaseProgramOptions
po::options_description databaseProgramOptions(unsigned _lineLength)
Definition: DBFactory.cpp:102
dev::db::DBFactory::create
static std::unique_ptr< DatabaseFace > create(DatabaseKind _kind, boost::filesystem::path const &_path)
dev::db::MemoryDB
Definition: MemoryDB.h:42
dev::db::DatabaseKind::RocksDB
@ RocksDB
dev::db::DatabaseKind::LevelDB
@ LevelDB
db.h
Common.h
dev::db::DBFactory::DBFactory
DBFactory()=delete
dev::db::DBFactory
Definition: DBFactory.h:51
dev::db::DBFactory::create
static std::unique_ptr< DatabaseFace > create()
Definition: DBFactory.cpp:135
dev::db::setDatabaseKind
void setDatabaseKind(DatabaseKind _kind)
Definition: DBFactory.cpp:70
dev
Definition: Address.cpp:21
dev::db::setDatabaseKindByName
void setDatabaseKindByName(std::string const &_name)
Definition: DBFactory.cpp:55
dev::db::DBFactory::~DBFactory
~DBFactory()=delete
dev::db::DBFactory::create
static std::unique_ptr< DatabaseFace > create(boost::filesystem::path const &_path)