1 /*
2  * Copyright (C) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_IPC_MESSAGE_OPTION_H
17 #define OHOS_IPC_MESSAGE_OPTION_H
18 
19 #include <memory>
20 namespace OHOS {
21 class MessageOption {
22 public:
23     enum {
24         TF_SYNC = 0x00,
25         TF_ASYNC = 0x01,
26         TF_STATUS_CODE = 0x08,
27         TF_ACCEPT_FDS = 0x10,
28         TF_WAIT_TIME = 0x8,
29         TF_ASYNC_WAKEUP_LATER = 0x100000,
30     };
31     MessageOption(int flags = TF_SYNC, int waitTime = TF_WAIT_TIME);
32     ~MessageOption() = default;
33 
34     /**
35      * @brief Sets flags.
36      * @param flags Indicates the identity to set.
37      * @return void
38      * @since 9
39      */
40     void SetFlags(int flags);
41 
42     /**
43      * @brief Gets flags.
44      * @return Returns the resulting flags.
45      * @since 9
46      */
47     int GetFlags() const;
48 
49     /**
50      * @brief Sets the wait time.
51      * @param waitTime Indicates the wait time to set.
52      * @return void
53      * @since 9
54      */
55     void SetWaitTime(int waitTime);
56 
57     /**
58      * @brief Gets the wait time.
59      * @return Returns the resulting wait time.
60      * @since 9
61      */
62     int GetWaitTime() const;
63 
64 private:
65     uint32_t flags_;
66     int waitTime_;
67 };
68 using MessageOptionPtr = std::shared_ptr<MessageOption>;
69 } // namespace OHOS
70 #endif // OHOS_IPC_MESSAGE_OPTION_H