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

Dependency injection container for database components. More...

#include <database_context.h>

Collaboration diagram for database::database_context:
Collaboration graph

Public Member Functions

 database_context ()
 Default constructor - creates default implementations.
 
 ~database_context ()
 Destructor - ensures clean shutdown.
 
 database_context (const database_context &)=delete
 
database_contextoperator= (const database_context &)=delete
 
 database_context (database_context &&)=delete
 
database_contextoperator= (database_context &&)=delete
 
bool is_initialized () const noexcept
 Check if context is initialized.
 
std::shared_ptr< monitoring::performance_monitorget_performance_monitor () const noexcept
 Get performance monitor instance.
 
std::shared_ptr< orm::entity_managerget_entity_manager () const noexcept
 Get entity manager instance.
 
std::shared_ptr< async::transaction_coordinatorget_transaction_coordinator () const noexcept
 Get transaction coordinator instance.
 
std::shared_ptr< security::credential_managerget_credential_manager () const noexcept
 Get credential manager instance.
 
std::shared_ptr< security::access_controlget_access_control () const noexcept
 Get access control instance.
 
std::shared_ptr< security::audit_loggerget_audit_logger () const noexcept
 Get audit logger instance.
 
std::shared_ptr< security::security_monitorget_security_monitor () const noexcept
 Get security monitor instance.
 
std::shared_ptr< security::encryption_managerget_encryption_manager () const noexcept
 Get encryption manager instance.
 

Private Attributes

std::shared_ptr< monitoring::performance_monitorperformance_monitor_
 Performance monitor instance (Sprint 3, Task 3.2)
 
std::shared_ptr< orm::entity_managerentity_manager_
 Entity manager instance (Sprint 3, Task 3.1)
 
std::shared_ptr< async::transaction_coordinatortransaction_coordinator_
 Transaction coordinator instance (Sprint 3, Task 3.1)
 
std::shared_ptr< security::credential_managercredential_manager_
 Security component instances (Sprint 3, Task 3.3)
 
std::shared_ptr< security::access_controlaccess_control_
 
std::shared_ptr< security::audit_loggeraudit_logger_
 
std::shared_ptr< security::security_monitorsecurity_monitor_
 
std::shared_ptr< security::encryption_managerencryption_manager_
 
std::mutex mutex_
 Mutex for thread-safe access.
 

Detailed Description

Dependency injection container for database components.

This class manages the lifetime and dependencies of database components. It replaces singleton pattern with dependency injection, enabling:

  • Testing with mock objects
  • Multiple independent database instances
  • Better separation of concerns
  • No hidden global state

Thread Safety: All methods are thread-safe. Component access is protected by internal synchronization.

Definition at line 79 of file database_context.h.

Constructor & Destructor Documentation

◆ database_context() [1/3]

database::database_context::database_context ( )

Default constructor - creates default implementations.

Creates a context with default implementations:

  • Connection pool management (Sprint 3)
  • Performance monitoring (Sprint 3)
  • Other components as needed (Sprint 3+)
Note
For custom/mock implementations, additional constructors will be added in Sprint 3 when implementing other singleton conversions.
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 14 of file database_context.cpp.

15 : performance_monitor_(std::make_shared<monitoring::performance_monitor>())
16 , entity_manager_(std::make_shared<orm::entity_manager>())
17 , transaction_coordinator_(std::make_shared<async::transaction_coordinator>())
18 , credential_manager_(std::make_shared<security::credential_manager>())
19 , access_control_(std::make_shared<security::access_control>())
20 , audit_logger_(std::make_shared<security::audit_logger>())
21 , security_monitor_(std::make_shared<security::security_monitor>())
22 , encryption_manager_(std::make_shared<security::encryption_manager>())
23{
24 // Sprint 3, Task 3.2: Initialize performance monitor
25 // Sprint 3, Task 3.1: Initialize ORM components
26 // Sprint 3, Task 3.3: Initialize security components
27}
std::shared_ptr< security::credential_manager > credential_manager_
Security component instances (Sprint 3, Task 3.3)
std::shared_ptr< security::encryption_manager > encryption_manager_
std::shared_ptr< security::security_monitor > security_monitor_
std::shared_ptr< security::access_control > access_control_
std::shared_ptr< orm::entity_manager > entity_manager_
Entity manager instance (Sprint 3, Task 3.1)
std::shared_ptr< security::audit_logger > audit_logger_
std::shared_ptr< monitoring::performance_monitor > performance_monitor_
Performance monitor instance (Sprint 3, Task 3.2)
std::shared_ptr< async::transaction_coordinator > transaction_coordinator_
Transaction coordinator instance (Sprint 3, Task 3.1)

◆ ~database_context()

database::database_context::~database_context ( )

Destructor - ensures clean shutdown.

Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 29 of file database_context.cpp.

30{
31 // Cleanup: All shared_ptrs will be automatically destroyed
32}

◆ database_context() [2/3]

database::database_context::database_context ( const database_context & )
delete

◆ database_context() [3/3]

database::database_context::database_context ( database_context && )
delete

Member Function Documentation

◆ get_access_control()

std::shared_ptr< security::access_control > database::database_context::get_access_control ( ) const
inlinenoexcept

Get access control instance.

Returns
Shared pointer to access control

Returns the access control for RBAC (Role-Based Access Control).

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.3)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 175 of file database_context.h.

175 {
176 return access_control_;
177 }

References access_control_.

◆ get_audit_logger()

std::shared_ptr< security::audit_logger > database::database_context::get_audit_logger ( ) const
inlinenoexcept

Get audit logger instance.

Returns
Shared pointer to audit logger

Returns the audit logger for security event logging.

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.3)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 188 of file database_context.h.

188 {
189 return audit_logger_;
190 }

References audit_logger_.

◆ get_credential_manager()

std::shared_ptr< security::credential_manager > database::database_context::get_credential_manager ( ) const
inlinenoexcept

Get credential manager instance.

Returns
Shared pointer to credential manager

Returns the credential manager for encrypted credential storage.

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.3)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 162 of file database_context.h.

162 {
163 return credential_manager_;
164 }

References credential_manager_.

◆ get_encryption_manager()

std::shared_ptr< security::encryption_manager > database::database_context::get_encryption_manager ( ) const
inlinenoexcept

Get encryption manager instance.

Returns
Shared pointer to encryption manager

Returns the encryption manager for data encryption and key management.

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.3)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 214 of file database_context.h.

214 {
215 return encryption_manager_;
216 }

References encryption_manager_.

◆ get_entity_manager()

std::shared_ptr< orm::entity_manager > database::database_context::get_entity_manager ( ) const
inlinenoexcept

Get entity manager instance.

Returns
Shared pointer to entity manager

Returns the ORM entity manager for entity metadata and query building.

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.1)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 136 of file database_context.h.

136 {
137 return entity_manager_;
138 }

References entity_manager_.

◆ get_performance_monitor()

std::shared_ptr< monitoring::performance_monitor > database::database_context::get_performance_monitor ( ) const
inlinenoexcept

Get performance monitor instance.

Returns
Shared pointer to performance monitor

Returns the performance monitor for tracking query metrics, connection usage, and system performance.

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.2)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 123 of file database_context.h.

123 {
125 }

References performance_monitor_.

◆ get_security_monitor()

std::shared_ptr< security::security_monitor > database::database_context::get_security_monitor ( ) const
inlinenoexcept

Get security monitor instance.

Returns
Shared pointer to security monitor

Returns the security monitor for threat detection and alerting.

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.3)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 201 of file database_context.h.

201 {
202 return security_monitor_;
203 }

References security_monitor_.

◆ get_transaction_coordinator()

std::shared_ptr< async::transaction_coordinator > database::database_context::get_transaction_coordinator ( ) const
inlinenoexcept

Get transaction coordinator instance.

Returns
Shared pointer to transaction coordinator

Returns the transaction coordinator for distributed transaction management.

Note
Lock-free read, inline for performance.
Since
Sprint 3 (Task 3.1)
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 149 of file database_context.h.

149 {
151 }

References transaction_coordinator_.

◆ is_initialized()

bool database::database_context::is_initialized ( ) const
inlinenoexcept

Check if context is initialized.

Returns
true if all required components are initialized
Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 109 of file database_context.h.

109 {
110 return performance_monitor_ != nullptr;
111 }

References performance_monitor_.

◆ operator=() [1/2]

◆ operator=() [2/2]

database_context & database::database_context::operator= ( database_context && )
delete

Member Data Documentation

◆ access_control_

std::shared_ptr<security::access_control> database::database_context::access_control_
private

◆ audit_logger_

std::shared_ptr<security::audit_logger> database::database_context::audit_logger_
private

◆ credential_manager_

std::shared_ptr<security::credential_manager> database::database_context::credential_manager_
private

Security component instances (Sprint 3, Task 3.3)

Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 229 of file database_context.h.

Referenced by get_credential_manager().

◆ encryption_manager_

std::shared_ptr<security::encryption_manager> database::database_context::encryption_manager_
private

◆ entity_manager_

std::shared_ptr<orm::entity_manager> database::database_context::entity_manager_
private

Entity manager instance (Sprint 3, Task 3.1)

Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 223 of file database_context.h.

Referenced by get_entity_manager().

◆ mutex_

std::mutex database::database_context::mutex_
mutableprivate

Mutex for thread-safe access.

Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 236 of file database_context.h.

◆ performance_monitor_

std::shared_ptr<monitoring::performance_monitor> database::database_context::performance_monitor_
private

Performance monitor instance (Sprint 3, Task 3.2)

Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 220 of file database_context.h.

Referenced by get_performance_monitor(), and is_initialized().

◆ security_monitor_

std::shared_ptr<security::security_monitor> database::database_context::security_monitor_
private

◆ transaction_coordinator_

std::shared_ptr<async::transaction_coordinator> database::database_context::transaction_coordinator_
private

Transaction coordinator instance (Sprint 3, Task 3.1)

Examples
/home/runner/work/database_system/database_system/database/core/database_context.h.

Definition at line 226 of file database_context.h.

Referenced by get_transaction_coordinator().


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