AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
sqlSharedLibraries.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-sql-export.hpp"
23
24#include <string>
25#include <map>
26#include <memory>
27
28#include "connection.hpp"
29#include "singleton.hpp"
30
31
32namespace anch::sql {
33
41 struct ANCH_SQL_EXPORT SQLSharedLibrary {
43 std::string layer;
44
46 void* _layer = NULL;
47
49 std::shared_ptr<Connection> (*make_shared_connection)(const SqlConnectionConfiguration&) = NULL;
50
52 Connection* (*create)(const SqlConnectionConfiguration&) = NULL;
53 };
54
62 class ANCH_SQL_EXPORT SQLSharedLibraries: public anch::Singleton<SQLSharedLibraries> {
63 friend class anch::Singleton<SQLSharedLibraries>;
64
65 // Attributes +
66 private:
68 std::map<std::string,anch::sql::SQLSharedLibrary> _libraries;
69 // Attributes -
70
71 // Constructors +
72 private:
76 SQLSharedLibraries() noexcept;
77
83 SQLSharedLibraries(const SQLSharedLibraries& other) = delete;
84 // Constructors -
85
86 // Destructor +
87 private:
91 virtual ~SQLSharedLibraries();
92 // Destructor -
93
94 // Methods +
95 public:
103 void registerSQLLibrary(const std::string& db, const std::string& library);
104
114 std::shared_ptr<Connection> makeSharedConnection(const SqlConnectionConfiguration& config);
115
126
130 static void registerMySQL();
131
135 static void registerPostgreSQL();
136
140 static void registerSQLite();
141 // Methods -
142
143 };
144
145}
146
147#include "sql/impl/sqlSharedLibraries.hpp"
Meyers' singleton implementation.
Definition singleton.hpp:50
SQL connection virtual class.
Definition connection.hpp:109
Connection * makeConnection(const SqlConnectionConfiguration &config)
std::shared_ptr< Connection > makeSharedConnection(const SqlConnectionConfiguration &config)
void registerSQLLibrary(const std::string &db, const std::string &library)
SQL namespace.
Definition clauses.hpp:28
SQL shared library data.
Definition sqlSharedLibraries.hpp:41
std::shared_ptr< Connection >(*) make_shared_connection(const SqlConnectionConfiguration &)
Definition sqlSharedLibraries.hpp:49
void * _layer
Definition sqlSharedLibraries.hpp:46
std::string layer
Definition sqlSharedLibraries.hpp:43
SQL database connection configuration.
Definition connection.hpp:55