wxExtend/include/wxex/comutils.h
Simon Rozman 3c2e59b56c Switch to SPDX license notice
Signed-off-by: Simon Rozman <simon@rozman.si>
2021-11-22 12:59:54 +01:00

55 lines
1.2 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
SPDX-License-Identifier: GPL-3.0-or-later
Copyright © 2016-2021 Amebis
Copyright © 2016 GÉANT
*/
#pragma once
#include "common.h"
/// \addtogroup wxExtend
/// @{
///
/// Create an object of this class on stack to initialize/cleanup the COM automatically.
///
class WXEXTEND_API wxCoInitializer
{
public:
///
/// Initialize the COM
///
/// \param[in] dwCoInit The concurrency model and initialization options for the thread to pass to `CoInitializeEx()`
///
wxCoInitializer(DWORD dwCoInit = COINIT_MULTITHREADED);
///
/// Dtor clean up
///
virtual ~wxCoInitializer();
///
/// Has the initialization been successful? (explicit test)
///
/// \returns
/// - \c true if initialization succeeded
/// - \c false otherwise
///
bool IsOk() const { return m_ok; }
///
/// Has the initialization been successful? (implicit test)
///
/// \returns
/// - \c true if initialization succeeded
/// - \c false otherwise
///
operator bool() const { return m_ok; }
private:
bool m_ok, m_initialized;
};
/// @}