xapian-core  1.4.27
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
BackendManager Class Reference

#include <backendmanager.h>

+ Inheritance diagram for BackendManager:
+ Collaboration diagram for BackendManager:

Public Member Functions

 BackendManager (const std::string &datadir_, const std::string &dbtype_)
 Constructor. More...
 
virtual ~BackendManager ()
 We have virtual methods and want to be able to delete derived classes using a pointer to the base class, so we need a virtual destructor. More...
 
const std::string & get_dbtype () const
 Get the database type currently in use. More...
 
const std::string & get_datadir () const
 Get the directory to store data in. More...
 
Xapian::Database get_database (const std::vector< std::string > &files)
 Get a database instance of the current type. More...
 
Xapian::Database get_database (const std::string &file)
 Get a database instance of the current type, single file case. More...
 
Xapian::Database get_database (const std::string &dbname, void(*gen)(Xapian::WritableDatabase &, const std::string &), const std::string &arg)
 Get a database instance of the current type, generated case. More...
 
virtual Xapian::Database get_database_by_path (const std::string &path)
 Get a database instance by path. More...
 
std::string get_database_path (const std::vector< std::string > &files)
 Get the path of a database instance, if such a thing exists. More...
 
std::string get_database_path (const std::string &file)
 Get the path of a database instance, if such a thing exists (single file case). More...
 
std::string get_database_path (const std::string &dbname, void(*gen)(Xapian::WritableDatabase &, const std::string &), const std::string &arg)
 Get the path of a generated database instance. More...
 
virtual Xapian::WritableDatabase get_writable_database (const std::string &name, const std::string &file)
 Get a writable database instance. More...
 
virtual Xapian::WritableDatabase get_remote_writable_database (std::string args)
 Get a remote Xapian::WritableDatabase instance with specified args. More...
 
virtual std::string get_writable_database_path (const std::string &name)
 Get the path of a writable database instance, if such a thing exists. More...
 
virtual Xapian::WritableDatabase get_generated_database (const std::string &name)
 Get a generated writable database instance. More...
 
virtual std::string get_generated_database_path (const std::string &name)
 Get the path to use for generating a database, if supported. More...
 
virtual void finalise_generated_database (const std::string &name)
 Finalise the generated database. More...
 
virtual Xapian::Database get_remote_database (const std::vector< std::string > &files, unsigned int timeout)
 Get a remote database instance with the specified timeout. More...
 
virtual std::string get_writable_database_args (const std::string &path, unsigned int timeout)
 Get the args for opening a writable remote database with the specified timeout. More...
 
virtual Xapian::Database get_writable_database_as_database ()
 Create a Database object for the last opened WritableDatabase. More...
 
virtual Xapian::WritableDatabase get_writable_database_again ()
 Create a WritableDatabase object for the last opened WritableDatabase. More...
 
virtual std::string get_writable_database_path_again ()
 Get the path of the last opened WritableDatabase. More...
 
virtual std::string get_compaction_output_path (const std::string &name)
 Get a path to compact a database to. More...
 
virtual void clean_up ()
 Called after each test, to perform any necessary cleanup. More...
 

Static Public Member Functions

static const char * get_xapian_progsrv_command ()
 Get the command line required to run xapian-progsrv. More...
 

Protected Member Functions

void index_files_to_database (Xapian::WritableDatabase &database, const std::vector< std::string > &files)
 Index data from zero or more text files into a database. More...
 
bool create_dir_if_needed (const std::string &dirname)
 Create the directory dirname if needed. More...
 
virtual Xapian::Database do_get_database (const std::vector< std::string > &files)
 Virtual method implementing get_database(). More...
 
virtual std::string do_get_database_path (const std::vector< std::string > &files)
 Virtual method implementing get_database_path(). More...
 

Private Attributes

std::string datadir
 The current data directory. More...
 
std::string dbtype
 The backend database type (set by subclass ctor). More...
 

Detailed Description

Definition at line 42 of file backendmanager.h.

Constructor & Destructor Documentation

◆ BackendManager()

BackendManager::BackendManager ( const std::string &  datadir_,
const std::string &  dbtype_ 
)
inline

Constructor.

Definition at line 74 of file backendmanager.h.

References ~BackendManager().

◆ ~BackendManager()

BackendManager::~BackendManager ( )
virtual

We have virtual methods and want to be able to delete derived classes using a pointer to the base class, so we need a virtual destructor.

Definition at line 78 of file backendmanager.cc.

Referenced by BackendManager().

Member Function Documentation

◆ clean_up()

void BackendManager::clean_up ( )
virtual

Called after each test, to perform any necessary cleanup.

May be called more than once for a given test in some cases.

Reimplemented in BackendManagerRemoteTcp.

Definition at line 290 of file backendmanager.cc.

Referenced by test_driver::do_run_tests(), get_datadir(), and test_driver::runtest().

◆ create_dir_if_needed()

bool BackendManager::create_dir_if_needed ( const std::string &  dirname)
protected

Create the directory dirname if needed.

Returns true if the directory was created and false if it was already there. Throws an exception if there was an error (eg not a directory).

Definition at line 60 of file backendmanager.cc.

References dir_exists().

Referenced by BackendManagerChert::BackendManagerChert(), BackendManagerGlass::BackendManagerGlass(), BackendManagerMulti::BackendManagerMulti(), BackendManagerSingleFile::BackendManagerSingleFile(), and BackendManagerSingleFile::finalise_generated_database().

◆ do_get_database()

Xapian::Database BackendManager::do_get_database ( const std::vector< std::string > &  files)
protectedvirtual

Virtual method implementing get_database().

If we just called this get_database() then each subclass which defined it would also need to un-hide the non-virtual overloaded method with "using get_database(const std::string&);" or similar.

Reimplemented in BackendManagerRemoteProg, BackendManagerRemoteTcp, and BackendManagerInMemory.

Definition at line 87 of file backendmanager.cc.

◆ do_get_database_path()

string BackendManager::do_get_database_path ( const std::vector< std::string > &  files)
protectedvirtual

Virtual method implementing get_database_path().

If we just called this get_database_path() then each subclass which defined it would also need to un-hide the non-virtual overloaded method with "using get_database_path(const std::string&);" or similar.

Reimplemented in BackendManagerMulti, BackendManagerSingleFile, BackendManagerChert, and BackendManagerGlass.

Definition at line 81 of file backendmanager.cc.

◆ finalise_generated_database()

void BackendManager::finalise_generated_database ( const std::string &  name)
virtual

Finalise the generated database.

Reimplemented in BackendManagerSingleFile.

Definition at line 242 of file backendmanager.cc.

Referenced by get_datadir().

◆ get_compaction_output_path()

string BackendManager::get_compaction_output_path ( const std::string &  name)
virtual

Get a path to compact a database to.

Reimplemented in BackendManagerMulti, BackendManagerSingleFile, BackendManagerChert, and BackendManagerGlass.

Definition at line 230 of file backendmanager.cc.

Referenced by get_compaction_output_path(), and get_datadir().

◆ get_database() [1/3]

Xapian::Database BackendManager::get_database ( const std::vector< std::string > &  files)

Get a database instance of the current type.

Definition at line 93 of file backendmanager.cc.

Referenced by DEFINE_TESTCASE(), BackendManagerSingleFile::do_get_database_path(), get_database(), and get_datadir().

◆ get_database() [2/3]

Xapian::Database BackendManager::get_database ( const std::string &  file)

Get a database instance of the current type, single file case.

Definition at line 99 of file backendmanager.cc.

◆ get_database() [3/3]

Xapian::Database BackendManager::get_database ( const std::string &  dbname,
void(*)(Xapian::WritableDatabase &, const std::string &)  gen,
const std::string &  arg 
)

Get a database instance of the current type, generated case.

Parameters
dbnameThe name of the database (base on your testcase name).
genGenerator function - should index data to the empty WritableDatabase provided.
argString argument to pass to gen - it's up to you how to make use of this (or just ignore it if you don't need it).

Definition at line 105 of file backendmanager.cc.

References gen, get_writable_database(), path_exists(), and rm_rf().

◆ get_database_by_path()

Xapian::Database BackendManager::get_database_by_path ( const std::string &  path)
virtual

Get a database instance by path.

Reimplemented in BackendManagerRemoteProg, and BackendManagerRemoteTcp.

Definition at line 184 of file backendmanager.cc.

Referenced by get_datadir().

◆ get_database_path() [1/3]

string BackendManager::get_database_path ( const std::vector< std::string > &  files)

Get the path of a database instance, if such a thing exists.

Definition at line 190 of file backendmanager.cc.

Referenced by get_database_path(), get_datadir(), and BackendManagerRemote::get_remote_database_args().

◆ get_database_path() [2/3]

string BackendManager::get_database_path ( const std::string &  file)

Get the path of a database instance, if such a thing exists (single file case).

Definition at line 196 of file backendmanager.cc.

◆ get_database_path() [3/3]

std::string BackendManager::get_database_path ( const std::string &  dbname,
void(*)(Xapian::WritableDatabase &, const std::string &)  gen,
const std::string &  arg 
)

Get the path of a generated database instance.

Definition at line 151 of file backendmanager.cc.

References gen, path_exists(), and rm_rf().

◆ get_datadir()

const std::string& BackendManager::get_datadir ( ) const
inline

◆ get_dbtype()

const std::string& BackendManager::get_dbtype ( ) const
inline

Get the database type currently in use.

Definition at line 84 of file backendmanager.h.

References dbtype.

Referenced by TestRunner::do_tests_for_backend_(), get_dbtype(), ApiTestRunner::run(), and PerfTestLogger::testcase_begin().

◆ get_generated_database()

Xapian::WritableDatabase BackendManager::get_generated_database ( const std::string &  name)
virtual

Get a generated writable database instance.

Reimplemented in BackendManagerRemote, and BackendManagerSingleFile.

Definition at line 224 of file backendmanager.cc.

References get_writable_database().

Referenced by get_datadir(), and BackendManagerSingleFile::get_generated_database().

◆ get_generated_database_path()

string BackendManager::get_generated_database_path ( const std::string &  name)
virtual

Get the path to use for generating a database, if supported.

Reimplemented in BackendManagerRemote, BackendManagerMulti, BackendManagerSingleFile, BackendManagerChert, BackendManagerGlass, and BackendManagerInMemory.

Definition at line 236 of file backendmanager.cc.

Referenced by BackendManagerSingleFile::finalise_generated_database(), and get_datadir().

◆ get_remote_database()

Xapian::Database BackendManager::get_remote_database ( const std::vector< std::string > &  files,
unsigned int  timeout 
)
virtual

Get a remote database instance with the specified timeout.

Reimplemented in BackendManagerRemoteProg, BackendManagerMulti, and BackendManagerRemoteTcp.

Definition at line 246 of file backendmanager.cc.

References get_dbtype().

Referenced by get_datadir(), and get_remote_database().

◆ get_remote_writable_database()

Xapian::WritableDatabase BackendManager::get_remote_writable_database ( std::string  args)
virtual

Get a remote Xapian::WritableDatabase instance with specified args.

Reimplemented in BackendManagerRemoteProg.

Definition at line 208 of file backendmanager.cc.

References get_dbtype().

Referenced by BackendManagerMulti::createdb_multi(), and get_datadir().

◆ get_writable_database()

Xapian::WritableDatabase BackendManager::get_writable_database ( const std::string &  name,
const std::string &  file 
)
virtual

◆ get_writable_database_again()

Xapian::WritableDatabase BackendManager::get_writable_database_again ( )
virtual

Create a WritableDatabase object for the last opened WritableDatabase.

Reimplemented in BackendManagerMulti, BackendManagerRemoteProg, BackendManagerRemoteTcp, BackendManagerChert, and BackendManagerGlass.

Definition at line 272 of file backendmanager.cc.

References get_dbtype().

Referenced by get_datadir(), and get_writable_database_again().

◆ get_writable_database_args()

string BackendManager::get_writable_database_args ( const std::string &  path,
unsigned int  timeout 
)
virtual

Get the args for opening a writable remote database with the specified timeout.

Reimplemented in BackendManagerRemote.

Definition at line 255 of file backendmanager.cc.

References get_dbtype().

Referenced by get_datadir().

◆ get_writable_database_as_database()

Xapian::Database BackendManager::get_writable_database_as_database ( )
virtual

Create a Database object for the last opened WritableDatabase.

Reimplemented in BackendManagerRemoteProg, and BackendManagerRemoteTcp.

Definition at line 266 of file backendmanager.cc.

Referenced by get_datadir(), and get_writable_database_as_database().

◆ get_writable_database_path()

string BackendManager::get_writable_database_path ( const std::string &  name)
virtual

Get the path of a writable database instance, if such a thing exists.

Reimplemented in BackendManagerMulti, BackendManagerChert, and BackendManagerGlass.

Definition at line 218 of file backendmanager.cc.

Referenced by get_datadir(), BackendManagerRemote::get_generated_database_path(), get_named_writable_database_path(), and BackendManagerRemote::get_writable_database_args().

◆ get_writable_database_path_again()

string BackendManager::get_writable_database_path_again ( )
virtual

◆ get_xapian_progsrv_command()

const char * BackendManager::get_xapian_progsrv_command ( )
static

Get the command line required to run xapian-progsrv.

Definition at line 295 of file backendmanager.cc.

References XAPIAN_PROGSRV.

Referenced by BackendManagerMulti::createdb_multi(), DEFINE_TESTCASE(), and get_datadir().

◆ index_files_to_database()

void BackendManager::index_files_to_database ( Xapian::WritableDatabase database,
const std::vector< std::string > &  files 
)
protected

Member Data Documentation

◆ datadir

std::string BackendManager::datadir
private

The current data directory.

Definition at line 44 of file backendmanager.h.

Referenced by get_datadir().

◆ dbtype

std::string BackendManager::dbtype
private

The backend database type (set by subclass ctor).

Definition at line 47 of file backendmanager.h.

Referenced by get_dbtype().


The documentation for this class was generated from the following files: