Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
database::testing::scoped_connection Class Reference

RAII wrapper for pool connections. More...

#include <mock_connection_pool.h>

Collaboration diagram for database::testing::scoped_connection:
Collaboration graph

Public Member Functions

 scoped_connection (mock_connection_pool &pool)
 
 scoped_connection (mock_connection_pool &pool, std::chrono::milliseconds timeout)
 
 ~scoped_connection ()
 
 scoped_connection (const scoped_connection &)=delete
 
scoped_connectionoperator= (const scoped_connection &)=delete
 
 scoped_connection (scoped_connection &&other) noexcept
 
mock_databaseget ()
 
mock_databaseoperator-> ()
 
mock_databaseoperator* ()
 
 operator bool () const
 

Private Attributes

mock_connection_poolpool_
 
mock_databaseconn_
 

Detailed Description

RAII wrapper for pool connections.

Definition at line 110 of file mock_connection_pool.h.

Constructor & Destructor Documentation

◆ scoped_connection() [1/4]

database::testing::scoped_connection::scoped_connection ( mock_connection_pool & pool)
inline

Definition at line 112 of file mock_connection_pool.h.

113 : pool_(pool), conn_(pool.acquire())
114 {}

◆ scoped_connection() [2/4]

database::testing::scoped_connection::scoped_connection ( mock_connection_pool & pool,
std::chrono::milliseconds timeout )
inline

Definition at line 116 of file mock_connection_pool.h.

117 : pool_(pool), conn_(pool.acquire(timeout))
118 {}

◆ ~scoped_connection()

database::testing::scoped_connection::~scoped_connection ( )
inline

Definition at line 120 of file mock_connection_pool.h.

120 {
121 if (conn_) {
123 }
124 }
void release(mock_database *conn)
Release a connection back to the pool.

References conn_, pool_, and database::testing::mock_connection_pool::release().

Here is the call graph for this function:

◆ scoped_connection() [3/4]

database::testing::scoped_connection::scoped_connection ( const scoped_connection & )
delete

◆ scoped_connection() [4/4]

database::testing::scoped_connection::scoped_connection ( scoped_connection && other)
inlinenoexcept

Definition at line 131 of file mock_connection_pool.h.

132 : pool_(other.pool_), conn_(other.conn_)
133 {
134 other.conn_ = nullptr;
135 }

Member Function Documentation

◆ get()

mock_database * database::testing::scoped_connection::get ( )
inline

Definition at line 137 of file mock_connection_pool.h.

137{ return conn_; }

References conn_.

◆ operator bool()

database::testing::scoped_connection::operator bool ( ) const
inlineexplicit

Definition at line 140 of file mock_connection_pool.h.

140{ return conn_ != nullptr; }

References conn_.

◆ operator*()

mock_database & database::testing::scoped_connection::operator* ( )
inline

Definition at line 139 of file mock_connection_pool.h.

139{ return *conn_; }

References conn_.

◆ operator->()

mock_database * database::testing::scoped_connection::operator-> ( )
inline

Definition at line 138 of file mock_connection_pool.h.

138{ return conn_; }

References conn_.

◆ operator=()

scoped_connection & database::testing::scoped_connection::operator= ( const scoped_connection & )
delete

Member Data Documentation

◆ conn_

mock_database* database::testing::scoped_connection::conn_
private

Definition at line 144 of file mock_connection_pool.h.

Referenced by get(), operator bool(), operator*(), operator->(), and ~scoped_connection().

◆ pool_

mock_connection_pool& database::testing::scoped_connection::pool_
private

Definition at line 143 of file mock_connection_pool.h.

Referenced by ~scoped_connection().


The documentation for this class was generated from the following file: