1 /*
2  * Copyright (c) 2022 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_MEMORY_MEMMGR_COMMON_INCLUDE_CONFIG_AVAIL_BUFFER_CONFIG_H
17 #define OHOS_MEMORY_MEMMGR_COMMON_INCLUDE_CONFIG_AVAIL_BUFFER_CONFIG_H
18 
19 #include <map>
20 #include <string>
21 #include <set>
22 #include "event_handler.h"
23 #include "libxml/parser.h"
24 #include "libxml/xpath.h"
25 
26 namespace OHOS {
27 namespace Memory {
28 class AvailBufferConfig {
29 public:
30     unsigned int GetAvailBuffer();
31     void SetAvailBuffer(unsigned int availBuffer);
32     unsigned int GetMinAvailBuffer();
33     void SetMinAvailBuffer(unsigned int minAvailBuffer);
34     unsigned int GetHighAvailBuffer();
35     void SetHighAvailBuffer(unsigned int highAvailBuffer);
36     unsigned int GetSwapReserve();
37     void SetSwapReserve(unsigned int swapReserve);
38     AvailBufferConfig();
39     AvailBufferConfig(unsigned int availBuffer, unsigned int minAvailBuffer,
40                       unsigned int highAvailBuffer, unsigned int swapReserve);
41     void SetDefaultConfig(unsigned int availBuffer, unsigned int minAvailBuffer,
42                           unsigned int highAvailBuffer, unsigned int swapReserve);
43     void ParseConfig(const xmlNodePtr &rootNodePtr);
44     void SetAvailBufferConfig(std::map<std::string, std::string> &param);
45     void Dump(int fd);
46 
47 private:
48     unsigned int availBuffer_;
49     unsigned int minAvailBuffer_;
50     unsigned int highAvailBuffer_;
51     unsigned int swapReserve_;
52 };
53 } // namespace Memory
54 } // namespace OHOS
55 #endif // OHOS_MEMORY_MEMMGR_COMMON_INCLUDE_CONFIG_AVAIL_BUFFER_CONFIG_H