File indexing completed on 2024-05-12 15:59:16

0001 /*
0002  *  SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #ifndef _KIS_META_DATA_SCHEMA_REGISTRY_H_
0008 #define _KIS_META_DATA_SCHEMA_REGISTRY_H_
0009 
0010 #include <kritametadata_export.h>
0011 
0012 class QString;
0013 class QDebug;
0014 
0015 namespace KisMetaData
0016 {
0017 
0018 class Schema;
0019 
0020 class KRITAMETADATA_EXPORT SchemaRegistry
0021 {
0022     struct Private;
0023 public:
0024     /**
0025      * DO NOT USE! Use instance() instead.
0026      * This constructor is public only to allow it to be used by
0027      * Q_GLOBAL_STATIC. Same for the destructor.
0028      */
0029     SchemaRegistry();
0030     ~SchemaRegistry();
0031 public:
0032     /**
0033      * Creates a new schema.
0034      * @param uri the name of the schema
0035      * @param prefix the namespace prefix used for this schema
0036      * @return the schema associated with the uri (it can return 0, if no schema exist
0037      * for the uri, but the prefix was already used, and it can be an already existing
0038      * schema if the uri was already included)
0039      */
0040     const KisMetaData::Schema* create(const QString & uri, const QString & prefix);
0041     /**
0042      * @return the schema for this uri
0043      */
0044     const Schema* schemaFromUri(const QString & uri) const;
0045     /**
0046      * @return the schema for this prefix
0047      */
0048     const Schema* schemaFromPrefix(const QString & prefix) const;
0049     /**
0050      * Return an instance of the SchemaRegistry.
0051      * Creates an instance if that has never happened before and returns
0052      * the singleton instance.
0053      * Initialize it with default schemas.
0054      */
0055     static KisMetaData::SchemaRegistry* instance();
0056 private:
0057     Private* const d;
0058 };
0059 }
0060 
0061 KRITAMETADATA_EXPORT QDebug operator<<(QDebug debug, const KisMetaData::Schema &c);
0062 
0063 #endif