21 #include "cafDocument.h" 22 #include "cafLogger.h" 23 #include "cafNotNull.h" 24 #include "cafPortableDataType.h" 25 #include "cafSession.h" 40 Client(
const std::string& hostname,
int port )
41 : m_hostname( hostname )
45 virtual ~
Client() =
default;
48 virtual std::shared_ptr<caffa::ObjectHandle> document(
const std::string& documentId )
const = 0;
49 virtual std::vector<std::shared_ptr<caffa::ObjectHandle>> documents()
const = 0;
50 virtual std::string execute( caffa::not_null<const caffa::ObjectHandle*> selfObject,
51 const std::string& methodName,
52 const std::string& jsonArguments )
const = 0;
53 virtual bool stopServer() = 0;
54 virtual void sendKeepAlive() = 0;
55 virtual bool isReady( caffa::Session::Type type )
const = 0;
58 createSession( caffa::Session::Type type,
const std::string& username =
"",
const std::string& password =
"" ) = 0;
65 virtual void changeSession( caffa::Session::Type newType ) = 0;
66 virtual void destroySession() = 0;
67 virtual const std::string& sessionUuid()
const = 0;
68 virtual void startKeepAliveThread() = 0;
70 template <
typename DataType>
71 void set(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName,
const DataType& value );
73 template <
typename DataType>
74 DataType
get(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName )
const;
76 virtual std::shared_ptr<caffa::ObjectHandle> getChildObject(
const caffa::ObjectHandle* objectHandle,
77 const std::string& fieldName )
const = 0;
79 virtual std::vector<std::shared_ptr<caffa::ObjectHandle>> getChildObjects(
const caffa::ObjectHandle* objectHandle,
80 const std::string& fieldName )
const = 0;
83 const std::string& fieldName,
87 removeChildObject(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName,
size_t index ) = 0;
89 virtual void clearChildObjects(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName ) = 0;
92 const std::string& fieldName,
96 const std::string& hostname()
const {
return m_hostname; }
97 int port()
const {
return m_port; }
101 setJson(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName,
const nlohmann::json& value ) = 0;
102 virtual nlohmann::json getJson(
const caffa::ObjectHandle*,
const std::string& fieldName )
const = 0;
105 std::string m_hostname;
112 template <
typename DataType>
115 nlohmann::json jsonValue = getJson( objectHandle, fieldName );
116 return jsonValue.get<DataType>();
122 template <
typename DataType>
125 nlohmann::json jsonValue = value;
126 setJson( objectHandle, fieldName, jsonValue );
DataType get(const caffa::ObjectHandle *objectHandle, const std::string &fieldName) const
Get a value through RPC.
Definition: cafRpcClient.h:113
Basic Application Information.
Definition: cafApplication.h:38
Definition: cafRpcClient.h:37
Definition: cafObjectHandle.h:47
void set(const caffa::ObjectHandle *objectHandle, const std::string &fieldName, const DataType &value)
Set a value through RPC.
Definition: cafRpcClient.h:123
virtual caffa::Session::Type checkSession() const =0
Check the session. Will return a session type (including possibly INVALID) if the session exists...
Main Caffa namespace.
Definition: cafApplication.h:30
Definition: cafRestAppService.h:28