1 /****************************************************************************\
2 * Copyright (C) 2017 Infineon Technologies & pmdtechnologies ag
4 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
9 \****************************************************************************/
19 namespace sample_utils
22 * Some platforms (and certain frameworks on those platforms) require the application to call an
23 * initialization method before the library can use certain features.
25 * The only one currently affecting us is Windows COM, which is needed for the UVC camera
28 * Qt will also create these resources, in a Qt app the application does not need to create them
29 * (and Qt will fail to start if the application creates them with conflicting settings).
31 class PlatformResources
35 PlatformResources () :
36 m_initializedSuccessfully {false}
38 auto hr = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
41 std::cout << "Can not initialize for the COM framework, UVC devices will not work" << std::endl;
45 m_initializedSuccessfully = true;
51 if (m_initializedSuccessfully)
58 bool m_initializedSuccessfully;
61 PlatformResources () = default;
64 // non-trivial destructor to avoid an "unused variable platformResources" warning