Redesign inheritance from Message (#62)

... so that the code is more idiomatic, clear and expressive about its intended use
This commit is contained in:
Stanislav Angelovič
2019-06-10 21:38:30 +02:00
committed by GitHub
parent 57c840637c
commit dcad208ffe
12 changed files with 136 additions and 62 deletions
+29 -1
View File
@@ -30,7 +30,35 @@
namespace sdbus
{
Message createPlainMessage();
class Message::Factory
{
public:
template<typename _Msg>
static _Msg create()
{
return _Msg{};
}
template<typename _Msg>
static _Msg create(void *msg)
{
return _Msg{msg};
}
template<typename _Msg>
static _Msg create(void *msg, internal::ISdBus* sdbus)
{
return _Msg{msg, sdbus};
}
template<typename _Msg>
static _Msg create(void *msg, internal::ISdBus* sdbus, adopt_message_t)
{
return _Msg{msg, sdbus, adopt_message};
}
};
PlainMessage createPlainMessage();
}
#endif /* SDBUS_CXX_INTERNAL_MESSAGEUTILS_H_ */