blob: fdfaed69dcf51d21798e3855a66ec321456968ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#ifndef __KONFORKA_PQXX_PILE_H
#define __KONFORKA_PQXX_PILE_H
#include <pqxx/connection>
#include <konforka/resource_pile.h>
/**
* @file
* @brief libpqxx-based postgresql connections pile.
*/
namespace konforka {
/**
* @brief the base for pqxx-based connection classes.
*
* @param pqxxc_t the type of libpqxx connection (pqxx::connection,
* pqxx::lazyconnection or pqxx::asyncconnection).
*/
template<typename pqxxc_t>
class pqxx_piled_connection_base : public resource_pile_base<string,pqxxc_t*, resource_pile_generic_ptr_factory<string,pqxxc_t> > {
public:
/**
* @brief the constractor based on connection info.
*
* @param ci connection info string.
*/
pqxx_piled_connection_base(const string& ci)
: resource_pile_base<string,pqxxc_t*, resource_pile_generic_ptr_factory<string,pqxxc_t> >(ci) { }
~pqxx_piled_connection_base() { this->drop(); }
/**
* @brief cast the object to the reference to the corresponding
* libpqxx type.
*/
operator pqxxc_t&(void) { return *this->get_content(); }
/**
* @brief cast the object to the const reference to the
* corresponding libpqxx type.
*/
operator const pqxxc_t&(void) const { return *this->get_content(); }
};
/**
* @brief the implementation for piling pqxx::connection objects.
*/
typedef pqxx_piled_connection_base<pqxx::connection> pqxx_piled_connection;
/**
* @brief the implementation for piling pqxx::lazyconnection objects.
*/
typedef pqxx_piled_connection_base<pqxx::lazyconnection> pqxx_piled_lazy_connection;
/**
* @brief the implementation for piling pqxx::asyncconnection objects.
*/
typedef pqxx_piled_connection_base<pqxx::asyncconnection> pqxx_piled_async_connection;
}
#endif /* __KONFORKA_PQXX_PILE_H */
/* vim:set ft=cpp: */
|