aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-12-26 09:29:00 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-12-27 20:15:59 +0100
commit58b2501aeecf2c169fd1f583dca292169568b5fa (patch)
treed1f670a8771f45fd5a1dee57edaf4a6f7085a363 /lib/connection.h
parent53c494f1b9f273395caade35c93e3fb520d083ec (diff)
downloadlibquotient-58b2501aeecf2c169fd1f583dca292169568b5fa.tar.gz
libquotient-58b2501aeecf2c169fd1f583dca292169568b5fa.zip
Connection: Simplify room/user factory code
There's no need to return lambdas where pointers to specialised function templates would work just fine.
Diffstat (limited to 'lib/connection.h')
-rw-r--r--lib/connection.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/connection.h b/lib/connection.h
index 52bf3cea..0713af16 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -81,11 +81,9 @@ using user_factory_t = std::function<User*(Connection*, const QString&)>;
* \sa Connection::setRoomFactory, Connection::setRoomType
*/
template <typename T = Room>
-static inline room_factory_t defaultRoomFactory()
+auto defaultRoomFactory(Connection* c, const QString& id, JoinState js)
{
- return [](Connection* c, const QString& id, JoinState js) {
- return new T(c, id, js);
- };
+ return new T(c, id, js);
}
/** The default factory to create user objects
@@ -94,9 +92,9 @@ static inline room_factory_t defaultRoomFactory()
* \sa Connection::setUserFactory, Connection::setUserType
*/
template <typename T = User>
-static inline user_factory_t defaultUserFactory()
+auto defaultUserFactory(Connection* c, const QString& id)
{
- return [](Connection* c, const QString& id) { return new T(id, c); };
+ return new T(id, c);
}
// Room ids, rather than room pointers, are used in the direct chat
@@ -469,14 +467,14 @@ public:
template <typename T>
static void setRoomType()
{
- setRoomFactory(defaultRoomFactory<T>());
+ setRoomFactory(defaultRoomFactory<T>);
}
/// Set the user factory to default with the overriden user type
template <typename T>
static void setUserType()
{
- setUserFactory(defaultUserFactory<T>());
+ setUserFactory(defaultUserFactory<T>);
}
public Q_SLOTS: