13 #ifndef __BAOSLIB_BAOSRESPONSE_H__
14 #define __BAOSLIB_BAOSRESPONSE_H__
36 using SPtr = std::shared_ptr<BaseResponse>;
46 std::shared_ptr<BaosBaseResponse>;
76 using SPtr = std::shared_ptr<BaosResponse>;
110 const auto response = fut.get();
111 auto responseBaos = std::dynamic_pointer_cast<BaosBaseResponse>(
119 std::ostringstream oss;
121 throw wz::baos::WzResponseException(WZ_SL, oss.str().c_str(),
static_cast<std::uint32_t
>(responseBaos->code));
125 auto responseDerived = std::dynamic_pointer_cast<BaosResponse<T>>(
127 return responseDerived->getPayload();
Global BAOS protocol defines and types.
Custom exceptions for the SDK.
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition: Defines.h:32
BaosResponseCode
These are the BaosServerErrorCodes.
Definition: Defines.h:128
@ NoItemFound
No item found.
std::promise< BaseResponse::SPtr > ResponsePromise
Definition: Response.h:95
std::future< BaseResponse::SPtr > ResponseFuture
Definition: Response.h:97
void waitAndHandleEmptyBaosResponse(ResponseFuture &&fut)
Handle responses with no payload.
std::string baosResponseCodeToString(BaosResponseCode code)
Convert the enum value to a human readable string.
T waitAndHandleBaosResponse(ResponseFuture &&fut)
Helper function to wait for a ResponseFuture to become ready and handle it.
Definition: Response.h:108
Baseclass for BAOS Responses. Containes the response code and optional in derived classes the payload...
Definition: Response.h:44
BaosBaseResponse(protocol::BaosResponseCode code_)
Construct a new BaosBaseResponse object.
Definition: Response.h:55
protocol::BaosResponseCode code
holds the BaosResponse code
Definition: Response.h:58
An actual BAOS response with payload of template parameter T.
Definition: Response.h:65
void setPayload(T &&value)
Setter for payload.
Definition: Response.h:85
BaosResponse(protocol::BaosResponseCode code_, T &&items)
Construct a new BaosResponse object.
Definition: Response.h:73
T getPayload()
Getter for payload.
Definition: Response.h:79
Baseclass for generic responses.
Definition: Response.h:35
std::shared_ptr< BaseResponse > SPtr
An alias for a std::shared pointer holding an BaseResponse class.
Definition: Response.h:36