/*! Creates and returns a TSessionStore object that matches the given key, or returns 0 if no matching session store is found. */ TSessionStore *TSessionStoreFactory::create(const QString &key) { T_TRACEFUNC("key: %s", qPrintable(key)); static const QString COOKIE_KEY = TSessionCookieStore().key().toLower(); static const QString SQLOBJECT_KEY = TSessionSqlObjectStore().key().toLower(); static const QString FILE_KEY = TSessionFileStore().key().toLower(); static const QString REDIS_KEY = TSessionRedisStore().key().toLower(); QMutexLocker locker(&mutex); loadPlugins(); TSessionStore *ret = 0; QString k = key.toLower(); if (k == COOKIE_KEY) { ret = new TSessionCookieStore; } else if (k == SQLOBJECT_KEY) { ret = new TSessionSqlObjectStore; } else if (k == FILE_KEY) { ret = new TSessionFileStore; } else if (k == REDIS_KEY) { ret = new TSessionRedisStore; } else { TSessionStoreInterface *ssif = sessIfMap->value(k); if (ssif) { ret = ssif->create(key); } } return ret; }
TSessionStore *TSessionStoreFactory::create(const QString &key) { T_TRACEFUNC("key: %s", qPrintable(key)); QMutexLocker locker(&mutex); loadPlugins(); TSessionStore *ret = 0; QString k = key.toLower(); int type = hash.value(k, Invalid); switch (type) { case SqlObject: ret = new TSessionSqlObjectStore; break; case Cookie: ret = new TSessionCookieStore; break; case File: ret = new TSessionFileStore; break; case Plugin: { for (QListIterator<TSessionStoreInterface *> i(*ssifs); i.hasNext(); ) { TSessionStoreInterface *p = i.next(); if (p->keys().contains(k)) { ret = p->create(k); break; } } break; } default: // do nothing break; } return ret; }