mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-02 14:04:22 +00:00
Create intermediate backend lib to help loading backend plugins.
This commit is contained in:
parent
1fd51f75ba
commit
064fc0cf1a
11 changed files with 429 additions and 4 deletions
59
include/backends/backend_loader.hpp
Normal file
59
include/backends/backend_loader.hpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* Copyright 2015, 2016, Michele Santullo
|
||||
* This file is part of "dindexer".
|
||||
*
|
||||
* "dindexer" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "dindexer" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef id756A258A98B24B0DB2529BCEEC5137E2
|
||||
#define id756A258A98B24B0DB2529BCEEC5137E2
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <boost/utility/string_ref.hpp>
|
||||
|
||||
namespace YAML {
|
||||
class Node;
|
||||
} //namespace YAML
|
||||
|
||||
namespace dindb {
|
||||
class Backend;
|
||||
|
||||
using BackendPtr = std::unique_ptr<dindb::Backend, void(*)(dindb::Backend*)>;
|
||||
|
||||
class BackendPlugin {
|
||||
public:
|
||||
BackendPlugin ( void );
|
||||
BackendPlugin ( BackendPlugin&& ) = default;
|
||||
BackendPlugin ( const std::string& parSOPath, const YAML::Node* parConfig );
|
||||
~BackendPlugin ( void ) noexcept;
|
||||
|
||||
const boost::string_ref& name ( void ) const;
|
||||
Backend& backend ( void );
|
||||
const Backend& backend ( void ) const;
|
||||
bool is_loaded ( void ) const;
|
||||
|
||||
BackendPlugin& operator= ( BackendPlugin&& ) = default;
|
||||
|
||||
private:
|
||||
using SoHandle = std::unique_ptr<void, int(*)(void*)>;
|
||||
|
||||
SoHandle m_lib;
|
||||
BackendPtr m_backend;
|
||||
boost::string_ref m_name;
|
||||
};
|
||||
|
||||
std::string backend_name ( const std::string& parSOPath );
|
||||
} //namespace dindb
|
||||
|
||||
#endif
|
49
include/backends/db_backend.hpp
Normal file
49
include/backends/db_backend.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* Copyright 2015, 2016, Michele Santullo
|
||||
* This file is part of "dindexer".
|
||||
*
|
||||
* "dindexer" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "dindexer" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef id7506CA9825454B80856154ACFE8A9DE2
|
||||
#define id7506CA9825454B80856154ACFE8A9DE2
|
||||
|
||||
#include "backends/backend_loader.hpp"
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/utility/string_ref.hpp>
|
||||
|
||||
namespace dindb {
|
||||
using GroupIDType = uint32_t;
|
||||
using FileIDType = uint64_t;
|
||||
|
||||
constexpr const GroupIDType InvalidGroupID = 0;
|
||||
constexpr const FileIDType InvalidFileID = 0;
|
||||
|
||||
class Backend {
|
||||
public:
|
||||
Backend ( void ) = default;
|
||||
virtual ~Backend ( void ) noexcept = default;
|
||||
|
||||
virtual void tag_files ( const std::vector<FileIDType>& parFiles, const std::vector<boost::string_ref>& parTags, GroupIDType parSet ) const = 0;
|
||||
virtual void tag_files ( const std::vector<std::string>& parRegexes, const std::vector<boost::string_ref>& parTags, GroupIDType parSet ) const = 0;
|
||||
virtual void delete_tags ( const std::vector<FileIDType>& parFiles, const std::vector<boost::string_ref>& parTags, GroupIDType parSet ) const = 0;
|
||||
virtual void delete_tags ( const std::vector<std::string>& parRegexes, const std::vector<boost::string_ref>& parTags, GroupIDType parSet ) const = 0;
|
||||
virtual void delete_all_tags ( const std::vector<FileIDType>& parFiles, GroupIDType parSet ) const = 0;
|
||||
virtual void delete_all_tags ( const std::vector<std::string>& parRegexes, GroupIDType parSet ) const = 0;
|
||||
|
||||
};
|
||||
} //namespace dindb
|
||||
|
||||
#endif
|
33
include/backends/exposed_functions.hpp
Normal file
33
include/backends/exposed_functions.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* Copyright 2015, 2016, Michele Santullo
|
||||
* This file is part of "dindexer".
|
||||
*
|
||||
* "dindexer" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "dindexer" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef idA9E47E37E2FA49EE84C2E93FB701C368
|
||||
#define idA9E47E37E2FA49EE84C2E93FB701C368
|
||||
|
||||
namespace YAML {
|
||||
class Node;
|
||||
} //namespace YAML
|
||||
|
||||
namespace dindb {
|
||||
class Backend;
|
||||
} //namespace dindb
|
||||
|
||||
extern "C" dindb::Backend* dindexer_create_backend ( const YAML::Node* parConfig );
|
||||
extern "C" void dindexer_destroy_backend ( dindb::Backend* parDele );
|
||||
extern "C" const char* dindexer_backend_name ( void );
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue