xapian-core  1.4.19
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_)
 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...
 
virtual 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...
 

Detailed Description

Definition at line 42 of file backendmanager.h.

Constructor & Destructor Documentation

◆ BackendManager()

BackendManager::BackendManager ( const std::string &  datadir_)
inlineexplicit

Constructor.

Definition at line 72 of file backendmanager.h.

References get_dbtype(), and ~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 292 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(), and BackendManagerSingleFile::BackendManagerSingleFile().

◆ 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 93 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 87 of file backendmanager.cc.

◆ finalise_generated_database()

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

Finalise the generated database.

Definition at line 244 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, BackendManagerChert, BackendManagerGlass, and BackendManagerSingleFile.

Definition at line 232 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 99 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 105 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 111 of file backendmanager.cc.

References 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 186 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 192 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 198 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 153 of file backendmanager.cc.

References path_exists(), and rm_rf().

◆ get_datadir()

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

◆ get_dbtype()

std::string BackendManager::get_dbtype ( ) const
virtual

◆ get_generated_database()

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

Get a generated writable database instance.

Reimplemented in BackendManagerRemote.

Definition at line 226 of file backendmanager.cc.

References get_writable_database().

Referenced by get_datadir().

◆ 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 BackendManagerMulti, BackendManagerRemote, BackendManagerChert, BackendManagerGlass, and BackendManagerInMemory.

Definition at line 238 of file backendmanager.cc.

Referenced by 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 248 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 210 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 274 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 257 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 268 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 220 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 297 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().


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