83da0fce245af2cacacdc4f456c8e5b9e2425704
[platform/core/appfw/pkgmgr-info.git] / src / server / request_handler / abstract_request_handler.hh
1 // Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef SERVER_ABSTRACT_REQUEST_HANDLER_HH_
6 #define SERVER_ABSTRACT_REQUEST_HANDLER_HH_
7
8 #include <string>
9
10 #include <sys/types.h>
11
12 #include <parcel.hh>
13
14 namespace pkgmgr_server {
15 namespace request_handler {
16
17 #ifndef EXPORT_API
18 #define EXPORT_API __attribute__((visibility("default")))
19 #endif
20
21 class EXPORT_API AbstractRequestHandler {
22  public:
23   virtual ~AbstractRequestHandler() = default;
24   virtual bool HandleRequest(unsigned char* data, int size,
25       const std::string& locale) = 0;
26
27   virtual std::vector<uint8_t> ExtractResult() = 0;
28
29   virtual void PreExec();
30   virtual void PostExec();
31   void SetPID(pid_t pid);
32   void SetUID(uid_t uid);
33
34  protected:
35   pid_t GetPID();
36   uid_t GetUID();
37
38  private:
39   pid_t pid_;
40   uid_t uid_;
41 };
42
43 }  // namespace request_handler
44 }  // namespace pkgmgr_server
45
46 #endif  // SERVER_ABSTRACT_REQUEST_HANDLER_HH_