SNode.C
Loading...
Searching...
No Matches
MariaDBConnection.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 * 2021, 2022 Daniel Flockert
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef DATABASE_MARIADB_MARIADBCONNECTION
22#define DATABASE_MARIADB_MARIADBCONNECTION
23
24#include "core/eventreceiver/ExceptionalConditionEventReceiver.h"
25#include "core/eventreceiver/ReadEventReceiver.h"
26#include "core/eventreceiver/WriteEventReceiver.h"
27#include "database/mariadb/MariaDBCommandSequence.h" // IWYU pragma: export
28
29namespace database::mariadb {
30 class MariaDBCommand;
31 class MariaDBClient;
34} // namespace database::mariadb
35
36#ifndef DOXYGEN_SHOULD_SKIP_THIS
37
38namespace utils {
39 class Timeval;
40}
41
42#include <deque>
43#include <mysql.h>
44#include <string>
45
46#endif /* DOXYGEN_SHOULD_SKIP_THIS */
47
48namespace database::mariadb {
49
51 public:
52 MariaDBCommandStartEvent(const std::string& name, MariaDBConnection* mariaDBConnection);
53
54 using core::EventReceiver::span;
55
56 private:
57 void onEvent(const utils::Timeval& currentTime) override;
58
59 void destruct() override;
60
62 };
63
65 : private core::eventreceiver::ReadEventReceiver
66 , private core::eventreceiver::WriteEventReceiver
68 public:
69 explicit MariaDBConnection(MariaDBClient* mariaDBClient, const MariaDBConnectionDetails& connectionDetails);
71
72 ~MariaDBConnection() override;
73
75
77 void execute_sync(MariaDBCommand* mariaDBCommand);
78
79 void commandStart(const utils::Timeval& currentTime);
80 void commandContinue(int status);
81 void commandCompleted();
82
83 void unmanaged();
84
85 protected:
86 void checkStatus(int status);
87
88 void readEvent() override;
89 void writeEvent() override;
90 void outOfBandEvent() override;
91
92 void readTimeout() override;
93 void writeTimeout() override;
94 void outOfBandTimeout() override;
95
96 void unobservedEvent() override;
97
98 private:
101
103
105 bool connected = false;
106
108 };
109
110} // namespace database::mariadb
111
112#endif // DATABASE_MARIADB_MARIADBCONNECTION
MariaDBClient(const MariaDBConnectionDetails &details)
void execute_sync(MariaDBCommandSync *mariaDBCommand) final
MariaDBCommandSequence & execute_async(MariaDBCommand *mariaDBCommand) final
MariaDBConnection * mariaDBConnection
MariaDBConnectionDetails details
MariaDBCommandSequence & execute_async(MariaDBCommand *mariaDBCommand) final
void onEvent(const utils::Timeval &currentTime) override
MariaDBCommandStartEvent(const std::string &name, MariaDBConnection *mariaDBConnection)
MariaDBCommandStartEvent commandStartEvent
std::deque< MariaDBCommandSequence > commandSequenceQueue
MariaDBCommandSequence & execute_async(MariaDBCommandSequence &&commandSequence)
MariaDBConnection(MariaDBClient *mariaDBClient, const MariaDBConnectionDetails &connectionDetails)
void commandStart(const utils::Timeval &currentTime)
void execute_sync(MariaDBCommand *mariaDBCommand)
MariaDBConnection(const MariaDBConnection &)=delete
MariaDBConnection & operator=(const MariaDBConnection &)=delete