Loading...
Searching...
No Matches
MethodResult.h
Go to the documentation of this file.
#ifndef SDBUS_CXX_METHODRESULT_H_
#define SDBUS_CXX_METHODRESULT_H_
#include <sdbus-c++/Message.h>
#include <cassert>
// Forward declarations
namespace sdbus {
class Error;
}
namespace sdbus {
/********************************************/
template <typename... _Results>
class Result
{
public:
Result() = default;
Result(MethodCall call);
Result(const Result&) = delete;
Result& operator=(const Result&) = delete;
Result(Result&& other) = default;
Result& operator=(Result&& other) = default;
void returnResults(const _Results&... results) const;
void returnError(const Error& error) const;
private:
MethodCall call_;
};
template <typename... _Results>
inline Result<_Results...>::Result(MethodCall call)
: call_(std::move(call))
{
}
template <typename... _Results>
inline void Result<_Results...>::returnResults(const _Results&... results) const
{
assert(call_.isValid());
auto reply = call_.createReply();
(void)(reply << ... << results);
reply.send();
}
template <typename... _Results>
inline void Result<_Results...>::returnError(const Error& error) const
{
auto reply = call_.createErrorReply(error);
reply.send();
}
}
#endif /* SDBUS_CXX_METHODRESULT_H_ */
Message.h
sdbus::Error
Definition Error.h:44
sdbus::MethodCall
Definition Message.h:268