1 /*
2 * Copyright (c) 2024 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 CPP_ABCKIT_CORE_ANNOTATION_IMPL_H
17 #define CPP_ABCKIT_CORE_ANNOTATION_IMPL_H
18
19 #include "annotation.h"
20 #include "annotation_element.h"
21 #include "annotation_interface.h"
22
23 namespace abckit::core {
24
EnumerateElements(const std::function<bool (abckit::core::AnnotationElement)> & cb)25 inline bool Annotation::EnumerateElements(const std::function<bool(abckit::core::AnnotationElement)> &cb) const
26 {
27 Payload<const std::function<bool(core::AnnotationElement)> &> payload {cb, GetApiConfig(), GetResource()};
28
29 bool isNormalExit = GetApiConfig()->cIapi_->annotationEnumerateElements(
30 GetView(), &payload, [](AbckitCoreAnnotationElement *func, void *data) {
31 const auto &payload = *static_cast<Payload<const std::function<bool(core::AnnotationElement)> &> *>(data);
32 return payload.data(core::AnnotationElement(func, payload.config, payload.resource));
33 });
34 CheckError(GetApiConfig());
35 return isNormalExit;
36 }
37
GetInterface()38 inline core::AnnotationInterface Annotation::GetInterface() const
39 {
40 AnnotationInterface iface(GetApiConfig()->cIapi_->annotationGetInterface(GetView()), GetApiConfig(), GetResource());
41 CheckError(GetApiConfig());
42 return iface;
43 }
44
45 } // namespace abckit::core
46
47 #endif // CPP_ABCKIT_CORE_ANNOTATION_IMPL_H
48