From 69d571248864ef0c4d810080aae2990fb2c27381 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 11 Jul 2016 22:23:29 +0200 Subject: Centrally define global types --- common/domain/applicationdomaintype.cpp | 7 +++++++ common/domain/applicationdomaintype.h | 3 +++ common/store.cpp | 6 ++---- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index ce113c2..4d63cc8 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -336,6 +336,13 @@ QByteArray getTypeName() return "folder"; } +bool isGlobalType(const QByteArray &type) { + if (type == ApplicationDomain::getTypeName() || type == ApplicationDomain::getTypeName() || type == ApplicationDomain::getTypeName()) { + return true; + } + return false; +} + } } diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 5efb936..d969cc8 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -342,6 +342,9 @@ QByteArray SINK_EXPORT getTypeName(); template<> QByteArray SINK_EXPORT getTypeName(); +bool SINK_EXPORT isGlobalType(const QByteArray &type); + + /** * Type implementation. * diff --git a/common/store.cpp b/common/store.cpp index a58287b..d7b277d 100644 --- a/common/store.cpp +++ b/common/store.cpp @@ -65,7 +65,7 @@ static QMap getResources(const QList &resour QMap resources; // Return the global resource (signified by an empty name) for types that don't belong to a specific resource - if (type == "sinkresource" || type == "sinkaccount" || type == "identity") { + if (ApplicationDomain::isGlobalType(type)) { resources.insert("", ""); return resources; } @@ -145,9 +145,7 @@ QSharedPointer Store::loadModel(Query query) template static std::shared_ptr> getFacade(const QByteArray &resourceInstanceIdentifier) { - - const auto type = ApplicationDomain::getTypeName(); - if (type == "sinkresource" || type == "sinkaccount") { + if (ApplicationDomain::isGlobalType(ApplicationDomain::getTypeName())) { if (auto facade = FacadeFactory::instance().getFacade("", "")) { return facade; } -- cgit v1.2.3