aboutsummaryrefslogtreecommitdiff
path: root/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-09-15 18:40:15 +0900
committerGitHub <noreply@github.com>2017-09-15 18:40:15 +0900
commit5ad32f13b8a7a8552e2b6c56571bd8177b3fabb2 (patch)
tree2f0069a1487573cc56856ab47758ac3993b125d5 /connection.cpp
parent180d62e094a1a6b6fc69c99b291ef075dc649135 (diff)
parentc4f690edf4cc2e11f19370f80ddd7428aba0b536 (diff)
downloadlibquotient-5ad32f13b8a7a8552e2b6c56571bd8177b3fabb2.tar.gz
libquotient-5ad32f13b8a7a8552e2b6c56571bd8177b3fabb2.zip
Merge pull request #82 from QMatrixClient/kitsune-uncouple-factories
Connection: Room and User factories are std::functions now
Diffstat (limited to 'connection.cpp')
-rw-r--r--connection.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/connection.cpp b/connection.cpp
index 7920125d..2c9ee88a 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -238,7 +238,7 @@ User* Connection::user(const QString& userId)
{
if( d->userMap.contains(userId) )
return d->userMap.value(userId);
- User* user = createUser(userId);
+ auto* user = createUser(this, userId);
d->userMap.insert(userId, user);
return user;
}
@@ -297,7 +297,7 @@ Room* Connection::provideRoom(const QString& id)
return d->roomMap.value(id);
// Not yet in the map, create a new one.
- Room* room = createRoom(id);
+ auto* room = createRoom(this, id);
if (room)
{
d->roomMap.insert( id, room );
@@ -309,15 +309,11 @@ Room* Connection::provideRoom(const QString& id)
return room;
}
-User* Connection::createUser(const QString& userId)
-{
- return new User(userId, this);
-}
+std::function<Room*(Connection*, const QString&)> Connection::createRoom =
+ [](Connection* c, const QString& id) { return new Room(c, id); };
-Room* Connection::createRoom(const QString& roomId)
-{
- return new Room(this, roomId);
-}
+std::function<User*(Connection*, const QString&)> Connection::createUser =
+ [](Connection* c, const QString& id) { return new User(id, c); };
QByteArray Connection::generateTxnId()
{