13 #include <jsonrpccpp/server/abstractserverconnector.h>
17 #include <json/value.h>
26 #ifndef EXCEPTION_TO_DEFAULT
28 #define EXCEPTION_TO_DEFAULT(__default, __body) \
39 #ifndef EXCEPTION_TO_DEFAULT_AND_LOG
41 #define EXCEPTION_TO_DEFAULT_AND_LOG(__default, __body) \
46 catch (const std::exception& oEx) \
48 LOG_ERROR(oEx.what()); \
51 catch (const tResult& oResult) \
53 LOG_RESULT(oResult); \
62 #ifndef EXCEPTION_TO_RESULT
64 #if A_UTILS_VERSION_MAJOR < 4
65 #define EXCEPTION_TO_RESULT(__body) \
72 return a_util::result::Result(ERR_FAILED); \
75 #define EXCEPTION_TO_RESULT(__body) \
80 catch (const std::exception& oEx) \
82 RETURN_ERROR_DESC(ERR_FAILED, "RPC call failed: %s", oEx.what()); \
86 RETURN_ERROR(ERR_FAILED); \
105 if (oValue[
"ErrorCode"].asInt() == ERR_NOERROR.error_code)
111 return tResult(oValue[
"ErrorCode"].asInt(),
112 oValue[
"Description"].asString().c_str(),
113 oValue[
"Line"].asInt(),
114 oValue[
"File"].asString().c_str(),
115 oValue[
"Function"].asString().c_str());
133 adtf::util::cFilename(oResult.
getFile()).GetName(),
142 oResult[
"Line"] = nResult.
GetLine();
143 oResult[
"File"] = nResult.
GetFile();
148 static inline std::string ToString(uint64_t nValue)
150 #ifdef HAVE_STD_TO_STRING
154 std::ostringstream stream;
160 static inline std::string ToString(int64_t nValue)
162 #ifdef HAVE_STD_TO_STRING
166 std::ostringstream stream;
172 static inline int64_t Stoll(
const std::string& strValue)
174 #ifdef HAVE_STD_STOLL
175 return std::stoll(strValue);
178 return strtoll(strValue.c_str(), 0, 10);
182 static inline uint64_t Stoull(
const std::string& strValue)
184 #ifdef HAVE_STD_STOLL
185 return std::stoull(strValue);
188 return strtoull(strValue.c_str(), 0, 10);
194 template <
typename Stub,
typename Interface>
213 strIID.Set(adtf::ucom::get_iid<Interface>());
219 strName.Set(Interface::DEFAULT_NAME);
230 return *
const_cast<Stub*
>(
static_cast<const Stub*
>(
this));
235 template <
typename ServerStub,
typename Interface>
239 public ucom::catwo::object<remote::ant::IRPCObjectServer, remote::catwo::IRPCInterfaceDefinition>
247 auto pData =
static_cast<const char*
>(oRequest.
Get());
248 std::string strRequest(pData, pData + oRequest.
GetSize());
249 std::string strResponse;
251 oResponse.Set(strResponse.c_str(), strResponse.size());
263 return strIID.Set(adtf::ucom::get_iid<Interface>());
268 return strRPCName.Set(m_strRPCObjectName);
271 tResult SetRPCName(
const char* strRPCName)
override
273 m_strRPCObjectName = strRPCName;
279 return strInterfaceDefinition.Set(ServerStub::interface_definition);
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
A common result class usable as return value throughout.
const tChar * GetDescription() const
Get user provided error description.
tInt32 GetLine() const
Get line in source file where the error was reported.
tErrorCode GetErrorCode() const
Get error code.
const tChar * GetFunction() const
Get name of the function the error was reported in.
const tChar * GetFile() const
Get name of the file the error was reported in.
A common result class usable as return value throughout.
const char * getFunction() const
Get name of the function the error was reported in.
const char * getFile() const
Get name of the file the error was reported in.
std::int32_t getLine() const
Get line in source file where the error was reported.
const char * getDescription() const
Get user provided error description.
std::int32_t getErrorCode() const
Get error code.
The IRawMemory interface provides methods for getting and setting memory values through abstract inte...
virtual size_t GetSize() const =0
Returns the size in bytes of the memory.
virtual const void * Get() const =0
Returns the raw memory pointer.
The IString interface provides methods for getting and setting strings through abstract interfaces.
rpc_remote_interface(const adtf::util::cString &strUrl)
Constructor.
Stub & GetStub() const
Access the rpc stub.
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Template to implement an RPC object.
Template for direct usage of the stub methods.
jsonrpc_remote_object(const adtf::util::cString &oInitializer)
Constructor.
RPC Protocol declaration.
cString to_string(const tResult &i_oResult, eResultFormatFlags i_eFormatFlags=eResultFormatFlags::RFF_DisableNone, const tChar *i_strFormat=nullptr)
Copy all information of an assigned result object to a (formatted) string.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
RPC Protocol declaration.
Copyright © Audi Electronics Venture GmbH.
error_code_type value
Value of this error code.
Common include for component a_util::result.