diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-21 14:36:05 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-21 14:36:05 +0200 |
commit | 40bc3c0607757159e274a72c4dca6f2445196ef0 (patch) | |
tree | 58af345ea9f9455480adce1b34b1782ae8a12893 /common | |
parent | a3a694db437cf88d11f141150702d5ca80774b3d (diff) | |
download | sink-40bc3c0607757159e274a72c4dca6f2445196ef0.tar.gz sink-40bc3c0607757159e274a72c4dca6f2445196ef0.zip |
Specify the resource name in one place
Diffstat (limited to 'common')
-rw-r--r-- | common/facadefactory.cpp | 2 | ||||
-rw-r--r-- | common/resource.cpp | 7 | ||||
-rw-r--r-- | common/resource.h | 6 |
3 files changed, 8 insertions, 7 deletions
diff --git a/common/facadefactory.cpp b/common/facadefactory.cpp index 107d575..9342831 100644 --- a/common/facadefactory.cpp +++ b/common/facadefactory.cpp | |||
@@ -68,7 +68,7 @@ std::shared_ptr<void> FacadeFactory::getFacade(const QByteArray &resource, const | |||
68 | if (!mFacadeRegistry.contains(k)) { | 68 | if (!mFacadeRegistry.contains(k)) { |
69 | locker.unlock(); | 69 | locker.unlock(); |
70 | // This will call FacadeFactory::instace() internally | 70 | // This will call FacadeFactory::instace() internally |
71 | Sink::ResourceFactory::load(QString::fromLatin1(resource)); | 71 | Sink::ResourceFactory::load(resource); |
72 | locker.relock(); | 72 | locker.relock(); |
73 | } | 73 | } |
74 | 74 | ||
diff --git a/common/resource.cpp b/common/resource.cpp index f4c2ad4..db64d33 100644 --- a/common/resource.cpp +++ b/common/resource.cpp | |||
@@ -80,7 +80,7 @@ ResourceFactory::~ResourceFactory() | |||
80 | // delete d; | 80 | // delete d; |
81 | } | 81 | } |
82 | 82 | ||
83 | ResourceFactory *ResourceFactory::load(const QString &resourceName) | 83 | ResourceFactory *ResourceFactory::load(const QByteArray &resourceName) |
84 | { | 84 | { |
85 | ResourceFactory *factory = Private::s_loadedFactories.value(resourceName); | 85 | ResourceFactory *factory = Private::s_loadedFactories.value(resourceName); |
86 | if (factory) { | 86 | if (factory) { |
@@ -106,8 +106,9 @@ ResourceFactory *ResourceFactory::load(const QString &resourceName) | |||
106 | factory = qobject_cast<ResourceFactory *>(object); | 106 | factory = qobject_cast<ResourceFactory *>(object); |
107 | if (factory) { | 107 | if (factory) { |
108 | Private::s_loadedFactories.insert(resourceName, factory); | 108 | Private::s_loadedFactories.insert(resourceName, factory); |
109 | factory->registerFacades(FacadeFactory::instance()); | 109 | //TODO: Instead of always loading both facades and adaptorfactories into the respective singletons, we could also leave this up to the caller. (ResourceFactory::loadFacades(...)) |
110 | factory->registerAdaptorFactories(AdaptorFactoryRegistry::instance()); | 110 | factory->registerFacades(resourceName, FacadeFactory::instance()); |
111 | factory->registerAdaptorFactories(resourceName, AdaptorFactoryRegistry::instance()); | ||
111 | // TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject(); | 112 | // TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject(); |
112 | return factory; | 113 | return factory; |
113 | } else { | 114 | } else { |
diff --git a/common/resource.h b/common/resource.h index 426585d..1dbc365 100644 --- a/common/resource.h +++ b/common/resource.h | |||
@@ -71,14 +71,14 @@ private: | |||
71 | class SINK_EXPORT ResourceFactory : public QObject | 71 | class SINK_EXPORT ResourceFactory : public QObject |
72 | { | 72 | { |
73 | public: | 73 | public: |
74 | static ResourceFactory *load(const QString &resourceName); | 74 | static ResourceFactory *load(const QByteArray &resourceName); |
75 | 75 | ||
76 | ResourceFactory(QObject *parent); | 76 | ResourceFactory(QObject *parent); |
77 | virtual ~ResourceFactory(); | 77 | virtual ~ResourceFactory(); |
78 | 78 | ||
79 | virtual Resource *createResource(const ResourceContext &context) = 0; | 79 | virtual Resource *createResource(const ResourceContext &context) = 0; |
80 | virtual void registerFacades(FacadeFactory &factory) = 0; | 80 | virtual void registerFacades(const QByteArray &resourceName, FacadeFactory &factory) = 0; |
81 | virtual void registerAdaptorFactories(AdaptorFactoryRegistry ®istry) {}; | 81 | virtual void registerAdaptorFactories(const QByteArray &resourceName, AdaptorFactoryRegistry ®istry) {}; |
82 | virtual void removeDataFromDisk(const QByteArray &instanceIdentifier) = 0; | 82 | virtual void removeDataFromDisk(const QByteArray &instanceIdentifier) = 0; |
83 | 83 | ||
84 | private: | 84 | private: |