1 #ifndef DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H
2 #define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
24 #include <unordered_map>
28 #include <dali/internal/accessibility/bridge/bridge-base.h>
31 * @brief The BridgeCollection class is to correspond with Dali::Accessibility::Collection.
33 * Collection interface is designed to allow AT-Clients to query the tree of accessibility objects
34 * exposed by an application with a single dbus call.
35 * The query takes as an input a match rule and returns zero or more matching accessibility objects as a result.
37 * A match rule can be a combination of at least one of four criteria :
38 * Interface, Attribute, Role, State
40 * If more than one criteria is specified, the matching rule combines them using "AND" semantics.
42 class BridgeCollection : public virtual BridgeBase
48 * @brief Visits all nodes of Accessible object and pushes the object to 'result' container.
50 * To query the entire tree, the BridgeCollection::Comparer is used inside this method,
51 * which traverse the tree using GetChildAtIndex().
52 * @param[in] obj The Accessible object to search
53 * @param[out] result The vector container for result
54 * @param[in] comparer BridgeCollection::Comparer which do the comparison against a single accessible object
55 * @param[in] maxCount The maximum count of containing Accessible object
57 static void VisitNodes(Dali::Accessibility::Accessible* obj, std::vector<Dali::Accessibility::Accessible*>& result, Comparer& comparer, size_t maxCount);
60 BridgeCollection() = default;
63 * @brief Registers Collection functions to dbus interfaces.
65 void RegisterInterfaces();
68 * @brief Returns the Collection object of the currently executed DBus method call.
70 * @return The Collection object
72 Dali::Accessibility::Collection* FindSelf() const;
76 * MatchRule type is a tuple that only carries data of de-serialized parameter from BridgeCollection::GetMatches dbus method.
78 using MatchRule = std::tuple<
79 std::array<int32_t, 2>,
81 std::unordered_map<std::string, std::string>,
83 std::array<int32_t, 4>,
85 std::vector<std::string>,
90 * @brief Enumeration for Collection Index.
97 ATTRIBUTES_MATCH_TYPE,
101 INTERFACES_MATCH_TYPE,
105 * @brief Gets the matching Accessible objects with MatchRule.
107 * @param[in] rule BridgeCollection::MatchRule
108 * @param[in] sortBy SortOrder::CANONICAL or SortOrder::REVERSE_CANONICAL
109 * @param[in] count The maximum number of objects
110 * @param[in] traverse True if it is traverse, otherwise false.
111 * @return The matching Accessible objects
113 DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetMatches(MatchRule rule, uint32_t sortBy, int32_t count, bool traverse);
116 #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H