File indexing completed on 2024-05-12 04:44:35

0001 // SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT
0003 
0004 #ifndef RGBCOLORSPACEFACTORY_H
0005 #define RGBCOLORSPACEFACTORY_H
0006 
0007 #include "importexport.h"
0008 #include <qglobal.h>
0009 #include <qsharedpointer.h>
0010 #include <qstring.h>
0011 
0012 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
0013 #include <qcontainerfwd.h>
0014 #else
0015 #include <qstringlist.h>
0016 #endif
0017 
0018 namespace PerceptualColor
0019 {
0020 class RgbColorSpace;
0021 
0022 /** @brief Factory for color space objects.
0023  *
0024  * These color space objects are needed in the constructors of various classes
0025  * of this library.
0026  *
0027  * Creating color space objects can be slow. But once created, they can be
0028  * used simultaneously on various widgets. Thanks to the QSharedPointer, you
0029  * can easily create a color space object, pass it to the widget constructors
0030  * you like, and then forget about it – it will be deleted automatically when
0031  * the last widget that used it has been deleted. And passing the shared
0032  * pointer to widget constructors is fast! Usage example:
0033  *
0034  * @snippet testrgbcolorspacefactory.cpp Create */
0035 class PERCEPTUALCOLOR_IMPORTEXPORT RgbColorSpaceFactory
0036 {
0037 public:
0038     // No Q_INVOKABLE here because the class does not inherit QObject:
0039     [[nodiscard]] static QSharedPointer<PerceptualColor::RgbColorSpace> createSrgb();
0040     [[nodiscard]] static QSharedPointer<PerceptualColor::RgbColorSpace> createFromFile(const QString &fileName);
0041     [[nodiscard]] static QStringList colorProfileDirectories();
0042 
0043 private:
0044     /** @internal
0045      *
0046      * @brief Private default constructor.
0047      *
0048      * This class should have no instances, therefore the constructor
0049      * is private. */
0050     RgbColorSpaceFactory() = default;
0051 
0052     /** @internal
0053      *
0054      * @brief Only for unit tests. */
0055     friend class TestRgbColorSpaceFactory;
0056 };
0057 
0058 } // namespace PerceptualColor
0059 
0060 #endif // RGBCOLORSPACEFACTORY_H