| 1 | /***** |
| 2 | * |
| 3 | * Copyright (C) 2008-2020 CS GROUP - France. All Rights Reserved. |
| 4 | * Author: Yoann Vandoorselaere <[email protected]> |
| 5 | * |
| 6 | * This file is part of the Prelude library. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Lesser General Public License as published by |
| 10 | * the Free Software Foundation; either version 2.1, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | *****/ |
| 23 | |
| 24 | #include <vector> |
| 25 | |
| 26 | #include "prelude.h"cxx . . $ `<file>/src/include/prelude.h`/ |
| 27 | #include "prelude-connection-pool.h"cxx . . $ `<file>/src/include/prelude-connection-pool.h`/ |
| 28 | |
| 29 | #include "prelude-connection-pool.hxx"cxx . . $ `<file>/bindings/c++/include/prelude-connection-pool.hxx`/ |
| 30 | #include "prelude-client.hxx"cxx . . $ `<file>/bindings/c++/include/prelude-client.hxx`/ |
| 31 | #include "prelude-error.hxx"cxx . . $ `<file>/bindings/c++/include/prelude-error.hxx`/ |
| 32 | |
| 33 | using namespace Prelude; |
| 34 | |
| 35 | |
| 36 | ConnectionPoolcxx . . $ Prelude/ConnectionPool#::~cxx . . $ Prelude/ConnectionPool#`~ConnectionPool`(ced63f7c635d850d).ConnectionPoolcxx . . $ Prelude/ConnectionPool#() |
| 37 | { |
| 38 | if ( _poolcxx . . $ Prelude/ConnectionPool#_pool. ) |
| 39 | prelude_connection_pool_destroy(_poolcxx . . $ Prelude/ConnectionPool#_pool.); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | ConnectionPoolcxx . . $ Prelude/ConnectionPool#::ConnectionPoolcxx . . $ Prelude/ConnectionPool#ConnectionPool(49f6e7a06ebc5aa8).() |
| 44 | { |
| 45 | _poolcxx . . $ Prelude/ConnectionPool#_pool. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | ConnectionPoolcxx . . $ Prelude/ConnectionPool#::ConnectionPoolcxx . . $ Prelude/ConnectionPool#ConnectionPool(911adfbf518b3d35).(prelude_connection_pool_t *pool) |
| 50 | { |
| 51 | _poolcxx . . $ Prelude/ConnectionPool#_pool. = pool; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | ConnectionPoolcxx . . $ Prelude/ConnectionPool#::ConnectionPoolcxx . . $ Prelude/ConnectionPool#ConnectionPool(9f252b65ddf58ff3).(const ConnectionPoolcxx . . $ Prelude/ConnectionPool# &con) |
| 56 | { |
| 57 | _poolcxx . . $ Prelude/ConnectionPool#_pool. = (con._poolcxx . . $ Prelude/ConnectionPool#_pool.) ? prelude_connection_pool_ref(con._poolcxx . . $ Prelude/ConnectionPool#_pool.) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | ConnectionPoolcxx . . $ Prelude/ConnectionPool#::ConnectionPoolcxx . . $ Prelude/ConnectionPool#ConnectionPool(8d5876fbdb3a8991).(ClientProfilecxx . . $ Prelude/ClientProfile# &cp, int permission) |
| 62 | { |
| 63 | int ret; |
| 64 | |
| 65 | ret = prelude_connection_pool_new(&_poolcxx . . $ Prelude/ConnectionPool#_pool., cp, (prelude_connection_permission_t) permission); |
| 66 | if ( ret < 0 ) |
| 67 | throw PreludeErrorcxx . . $ Prelude/PreludeError#(ret); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | |
| 72 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::initcxx . . $ Prelude/ConnectionPool#init(49f6e7a06ebc5aa8).() |
| 73 | { |
| 74 | int ret; |
| 75 | |
| 76 | ret = prelude_connection_pool_init(_poolcxx . . $ Prelude/ConnectionPool#_pool.); |
| 77 | if ( ret < 0 ) |
| 78 | throw PreludeErrorcxx . . $ Prelude/PreludeError#(ret); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Preludecxx . . $ Prelude/::Connectioncxx . . $ Prelude/Connection#> ConnectionPoolcxx . . $ Prelude/ConnectionPool#::getConnectionListcxx . . $ Prelude/ConnectionPool#getConnectionList(461b2c5ea4a186ba).() const |
| 83 | { |
| 84 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Preludecxx . . $ Prelude/::Connectioncxx . . $ Prelude/Connection#> clistcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 85 | prelude_connection_t *con; |
| 86 | prelude_list_t *head, *tmp; |
| 87 | |
| 88 | head = prelude_connection_pool_get_connection_list(_poolcxx . . $ Prelude/ConnectionPool#_pool.); |
| 89 | |
| 90 | prelude_list_for_eachcxx . . $ `src/include/prelude-list.h:216:9`!(head, tmp) { |
| 91 | con = (prelude_connection_t *) prelude_linked_object_get_objectcxx . . $ `src/include/prelude-linked-object.h:83:9`!(tmp); |
| 92 | clist.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Connectioncxx . . $ Prelude/Connection#(prelude_connection_ref(con))); |
| 93 | } |
| 94 | |
| 95 | return clistcxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::addConnectioncxx . . $ Prelude/ConnectionPool#addConnection(82b638af4b026dd4).(Connectioncxx . . $ Prelude/Connection# con) |
| 100 | { |
| 101 | prelude_connection_pool_add_connection(_poolcxx . . $ Prelude/ConnectionPool#_pool., prelude_connection_ref(con)); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::delConnectioncxx . . $ Prelude/ConnectionPool#delConnection(82b638af4b026dd4).(Connectioncxx . . $ Prelude/Connection# con) |
| 106 | { |
| 107 | prelude_connection_pool_del_connection(_poolcxx . . $ Prelude/ConnectionPool#_pool., con); |
| 108 | } |
| 109 | |
| 110 | |
| 111 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::setConnectionDeadcxx . . $ Prelude/ConnectionPool#setConnectionDead(7c922c7aff01310c).(Connectioncxx . . $ Prelude/Connection# &con) |
| 112 | { |
| 113 | prelude_connection_pool_set_connection_dead(_poolcxx . . $ Prelude/ConnectionPool#_pool., con); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::setConnectionAlivecxx . . $ Prelude/ConnectionPool#setConnectionAlive(7c922c7aff01310c).(Connectioncxx . . $ Prelude/Connection# &con) |
| 118 | { |
| 119 | prelude_connection_pool_set_connection_alive(_poolcxx . . $ Prelude/ConnectionPool#_pool., con); |
| 120 | } |
| 121 | |
| 122 | |
| 123 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::setConnectionStringcxx . . $ Prelude/ConnectionPool#setConnectionString(85c52e162fed56f9).(const char *str) |
| 124 | { |
| 125 | int ret; |
| 126 | |
| 127 | ret = prelude_connection_pool_set_connection_string(_poolcxx . . $ Prelude/ConnectionPool#_pool., str); |
| 128 | if ( ret < 0 ) |
| 129 | throw PreludeErrorcxx . . $ Prelude/PreludeError#(ret); |
| 130 | } |
| 131 | |
| 132 | |
| 133 | const char *ConnectionPoolcxx . . $ Prelude/ConnectionPool#::getConnectionStringcxx . . $ Prelude/ConnectionPool#getConnectionString(a9f41ea0e82d88cf).() const |
| 134 | { |
| 135 | return prelude_connection_pool_get_connection_string(_poolcxx . . $ Prelude/ConnectionPool#_pool.); |
| 136 | } |
| 137 | |
| 138 | |
| 139 | int ConnectionPoolcxx . . $ Prelude/ConnectionPool#::getFlagscxx . . $ Prelude/ConnectionPool#getFlags(455f465bc33b4cdf).() const |
| 140 | { |
| 141 | return prelude_connection_pool_get_flags(_poolcxx . . $ Prelude/ConnectionPool#_pool.); |
| 142 | } |
| 143 | |
| 144 | |
| 145 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::setFlagscxx . . $ Prelude/ConnectionPool#setFlags(d4f767463ce0a6b3).(int flags) |
| 146 | { |
| 147 | prelude_connection_pool_set_flags(_poolcxx . . $ Prelude/ConnectionPool#_pool., (prelude_connection_pool_flags_t) flags); |
| 148 | } |
| 149 | |
| 150 | |
| 151 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::setRequiredPermissioncxx . . $ Prelude/ConnectionPool#setRequiredPermission(d4f767463ce0a6b3).(int permission) |
| 152 | { |
| 153 | prelude_connection_pool_set_required_permission(_poolcxx . . $ Prelude/ConnectionPool#_pool., (prelude_connection_permission_t) permission); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | void ConnectionPoolcxx . . $ Prelude/ConnectionPool#::setDatacxx . . $ Prelude/ConnectionPool#setData(5d22bdacc48458e8).(void *data) |
| 158 | { |
| 159 | prelude_connection_pool_set_data(_poolcxx . . $ Prelude/ConnectionPool#_pool., data); |
| 160 | } |
| 161 | |
| 162 | |
| 163 | void *ConnectionPoolcxx . . $ Prelude/ConnectionPool#::getDatacxx . . $ Prelude/ConnectionPool#getData(45a5c5ac6be858a8).() const |
| 164 | { |
| 165 | return prelude_connection_pool_get_data(_poolcxx . . $ Prelude/ConnectionPool#_pool.); |
| 166 | } |
| 167 | |
| 168 | |
| 169 | ConnectionPoolcxx . . $ Prelude/ConnectionPool# &ConnectionPoolcxx . . $ Prelude/ConnectionPool#::operatorcxx . . $ Prelude/ConnectionPool#`operator=`(97d438a5523cad7f).=(const ConnectionPoolcxx . . $ Prelude/ConnectionPool# &pool) |
| 170 | { |
| 171 | if ( this != &pool && _poolcxx . . $ Prelude/ConnectionPool#_pool. != pool._poolcxx . . $ Prelude/ConnectionPool#_pool. ) { |
| 172 | if ( _poolcxx . . $ Prelude/ConnectionPool#_pool. ) |
| 173 | prelude_connection_pool_destroy(_poolcxx . . $ Prelude/ConnectionPool#_pool.); |
| 174 | |
| 175 | _poolcxx . . $ Prelude/ConnectionPool#_pool. = (pool._poolcxx . . $ Prelude/ConnectionPool#_pool.) ? prelude_connection_pool_ref(pool._poolcxx . . $ Prelude/ConnectionPool#_pool.) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 176 | } |
| 177 | |
| 178 | return *this; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | ConnectionPoolcxx . . $ Prelude/ConnectionPool#::operatorcxx . . $ Prelude/ConnectionPool#`operator prelude_connection_pool *`(7db8b2485b487953). prelude_connection_pool_t *() |
| 183 | { |
| 184 | return _poolcxx . . $ Prelude/ConnectionPool#_pool.; |
| 185 | } |