Cbeam
Loading...
Searching...
No Matches
cbeam::platform::com_initializer Class Reference

Manages the initialization and deinitialization of COM. More...

#include <com_initializer.hpp>

Public Member Functions

 com_initializer (const bool multi_threaded, const bool do_throw=true)
 Constructor: If we are on Windows and COM is not initialized, initialize it in the specified mode.
 
 ~com_initializer () noexcept
 Destructor: Deinitializes COM in case the constructor initialized it. Does nothing if COM was already initialized at construction time.
 
bool should_deinitialize_on_destruction () const
 Checks if COM will be deinitialized upon destruction of this object.
 
 com_initializer (const com_initializer &)=delete
 
com_initializeroperator= (const com_initializer &)=delete
 

Protected Attributes

bool _deinitialize_on_destruction
 

Detailed Description

Manages the initialization and deinitialization of COM.

This class will initialize COM for the process when created and deinitialize it when destroyed. It does nothing on non-Windows platforms. It also does nothing if COM is already initialized.

Constructor & Destructor Documentation

◆ com_initializer() [1/2]

cbeam::platform::com_initializer::com_initializer ( const bool multi_threaded,
const bool do_throw = true )
inline

Constructor: If we are on Windows and COM is not initialized, initialize it in the specified mode.

Parameters
multi_threadedIf true, initializes COM in multithreaded apartment (MTA) mode. If false, initializes COM in single-threaded apartment (STA) mode.
do_throwIf true, throw a cbeam::error::runtime_error in case COM cannot be initialized. Default: true. Note that it is not error if COM was already initialized.

◆ ~com_initializer()

cbeam::platform::com_initializer::~com_initializer ( )
inlinenoexcept

Destructor: Deinitializes COM in case the constructor initialized it. Does nothing if COM was already initialized at construction time.

◆ com_initializer() [2/2]

cbeam::platform::com_initializer::com_initializer ( const com_initializer & )
delete

Member Function Documentation

◆ operator=()

com_initializer & cbeam::platform::com_initializer::operator= ( const com_initializer & )
delete

◆ should_deinitialize_on_destruction()

bool cbeam::platform::com_initializer::should_deinitialize_on_destruction ( ) const
inline

Checks if COM will be deinitialized upon destruction of this object.

Returns
Returns true if this object will deinitialize COM on destruction, false otherwise.

Member Data Documentation

◆ _deinitialize_on_destruction

bool cbeam::platform::com_initializer::_deinitialize_on_destruction
protected

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