15490a39dSopenharmony_ci/*
25490a39dSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
35490a39dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45490a39dSopenharmony_ci * you may not use this file except in compliance with the License.
55490a39dSopenharmony_ci * You may obtain a copy of the License at
65490a39dSopenharmony_ci *
75490a39dSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
85490a39dSopenharmony_ci *
95490a39dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105490a39dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115490a39dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125490a39dSopenharmony_ci * See the License for the specific language governing permissions and
135490a39dSopenharmony_ci * limitations under the License.
145490a39dSopenharmony_ci */
155490a39dSopenharmony_ci#ifndef BASE_MACROS_H
165490a39dSopenharmony_ci#define BASE_MACROS_H
175490a39dSopenharmony_ci
185490a39dSopenharmony_ci#define ROLE(role) Get##role()
195490a39dSopenharmony_ci#define ROLE_PROTO_TYPE(role) role& ROLE(role) const
205490a39dSopenharmony_ci#define USE_ROLE(role) virtual ROLE_PROTO_TYPE(role) = 0
215490a39dSopenharmony_ci#define HAS_ROLE(role) USE_ROLE(role)
225490a39dSopenharmony_ci
235490a39dSopenharmony_ci#define IMPL_ROLE(role)                                        \
245490a39dSopenharmony_ciROLE_PROTO_TYPE(role) override                                 \
255490a39dSopenharmony_ci{                                                              \
265490a39dSopenharmony_ci    return const_cast<role&>(static_cast<const role&>(*this)); \
275490a39dSopenharmony_ci}
285490a39dSopenharmony_ci
295490a39dSopenharmony_ci#endif
30