GnuCash  5.6-150-g038405b370+
gnc-backend-prov.hpp
1 /********************************************************************\
2  * qofbackend-prov.hpp -- Manage creation of a QofBackend subclass. *
3  * *
4  * Copyright 2016 John Ralls <jralls@ceridwen.us> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA gnu@gnu.org *
22  * *
23 \********************************************************************/
24 
25 #ifndef __GNC_BACKEND_PROV_HPP__
26 #define __GNC_BACKEND_PROV_HPP__
27 
28 #include <memory>
29 
31 {
32  QofBackendProvider(const char* name, const char* type) :
33  provider_name {name}, access_method {type} {}
36  virtual ~QofBackendProvider() {}
37 
43  virtual QofBackend * create_backend(void) = 0;
44 
59  /*@ null @*/
60  virtual bool type_check(const char*) = 0;
62  const char * provider_name;
63 
67  const char * access_method;
68 };
69 
70 using QofBackendProvider_ptr = std::unique_ptr<QofBackendProvider>;
71 
79 void qof_backend_register_provider (QofBackendProvider_ptr&&);
80 
81 void qof_backend_unregister_all_providers ();
82 
83 #endif // __GNC_BACKEND_PROV_HPP__
void qof_backend_register_provider(QofBackendProvider_ptr &&prov)
Let the system know about a new provider of backends.
Definition: qofsession.cpp:90
virtual QofBackend * create_backend(void)=0
Return a new, fully initialized backend.
virtual bool type_check(const char *)=0
Distinguish two providers with same access method.
const char * provider_name
Some arbitrary name given for this particular backend provider.
const char * access_method
The access method that this provider provides, for example, file:// http:// postgres:// or sqlite://...