1 /*****
2 *
3 * Copyright (C) 2008-2015 CS-SI. All Rights Reserved.
4 * Author: Yoann Vandoorselaere <yoann@prelude-ids.com>
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 General Public License as published by
10 * the Free Software Foundation; either version 2, 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 General Public License for more details.
17 *
18 * You should have received a copy of the GNU 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 #ifndef _LIBPRELUDE_PRELUDE_CONNECTION_POOL_HXX
25 #define _LIBPRELUDE_PRELUDE_CONNECTION_POOL_HXX
26 
27 #include "prelude.h"
28 #include "prelude-client-profile.hxx"
29 #include "prelude-connection.hxx"
30 
31 namespace Prelude {
32         class ConnectionPool {
33             private:
34                 prelude_connection_pool_t *_pool;
35 
36             public:
37                 ~ConnectionPool();
38                 ConnectionPool();
39                 ConnectionPool(prelude_connection_pool_t *pool);
40                 ConnectionPool(const ConnectionPool &pool);
41                 ConnectionPool(Prelude::ClientProfile &cp, int permission);
42 
43                 void init();
44 
45                 void setConnectionString(const char *str);
46                 const char *getConnectionString() const;
47                 std::vector<Prelude::Connection> getConnectionList() const;
48 
49                 void setFlags(int flags);
50                 int getFlags() const;
51 
52                 void setData(void *data);
53                 void *getData() const;
54 
55                 void addConnection(Prelude::Connection con);
56                 void delConnection(Prelude::Connection con);
57 
58                 void setConnectionAlive(Prelude::Connection &con);
59                 void setConnectionDead(Prelude::Connection &con);
60 
61                 void setRequiredPermission(int permission);
62                 ConnectionPool &operator=(const ConnectionPool &pool);
63                 operator prelude_connection_pool_t *();
64         };
65 };
66 
67 #endif /* __PRELUDE_CONNECTION_POOL__ */
68