1 /*
2  * Copyright (C) 2021-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 BASE_DEF_H
17 #define BASE_DEF_H
18 
19 #include <memory>
20 #include <string>
21 
22 #if (__cplusplus < 201703L)
23 #error "CXX Version Error!!!"
24 #endif
25 
26 #ifdef DEBUG
27 #include <assert.h>
28 #define ASSERT(x) assert(x)
29 #else
30 #define ASSERT(x)
31 #endif
32 
33 #ifndef BT_DISALLOW_COPY
34 #define BT_DISALLOW_COPY(TypeName) TypeName(const TypeName &) = delete
35 #endif
36 
37 #ifndef BT_DISALLOW_ASSIGN
38 #define BT_DISALLOW_ASSIGN(TypeName) TypeName &operator=(const TypeName &) = delete
39 #endif
40 
41 #ifndef BT_DISALLOW_COPY_AND_ASSIGN
42 #define BT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
43     BT_DISALLOW_COPY(TypeName);               \
44     BT_DISALLOW_ASSIGN(TypeName)
45 #endif
46 
47 #ifndef BT_DISALLOW_MOVE_AND_ASSIGN
48 #define BT_DISALLOW_MOVE_AND_ASSIGN(TypeName)   \
49     TypeName(TypeName &&) noexcept = delete; \
50     TypeName &operator=(TypeName &&) noexcept = delete
51 #endif
52 
53 #ifndef DECLARE_IMPL
54 #define DECLARE_IMPL() \
55     struct impl;       \
56     std::unique_ptr<impl> pimpl
57 #endif
58 
59 /**
60  * @brief Bluetooth system config path.
61  */
62 const std::string BT_CONFIG_PATH_BASE = "/system/etc/bluetooth/";
63 const std::string BT_CONFIG_PATH = "/data/service/el1/public/bluetooth/";
64 
65 
66 #ifndef CHECK_EXCEPT_INTR
67 #define CHECK_EXCEPT_INTR(fn) \
68     do {                      \
69     } while ((fn) == -1 && errno == EINTR)
70 #endif
71 
72 #endif  // BASE_DEF_H