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/devel-api/atspi-interfaces/collection.h>
29 #include <dali/internal/accessibility/bridge/bridge-base.h>
32 * @brief The BridgeCollection class is to correspond with Dali::Accessibility::Collection.
34 * Collection interface is designed to allow AT-Clients to query the tree of accessibility objects
35 * exposed by an application with a single dbus call.
36 * The query takes as an input a match rule and returns zero or more matching accessibility objects as a result.
38 * A match rule can be a combination of at least one of four criteria :
39 * Interface, Attribute, Role, State
41 * If more than one criteria is specified, the matching rule combines them using "AND" semantics.
43 class BridgeCollection : public virtual BridgeBase
49 * @brief Visits all nodes of Accessible object and pushes the object to 'result' container.
51 * To query the entire tree, the BridgeCollection::Comparer is used inside this method,
52 * which traverse the tree using GetChildAtIndex().
53 * @param[in] obj The Accessible object to search
54 * @param[out] result The vector container for result
55 * @param[in] comparer BridgeCollection::Comparer which do the comparison against a single accessible object
56 * @param[in] maxCount The maximum count of containing Accessible object
58 static void VisitNodes(Dali::Accessibility::Accessible* obj, std::vector<Dali::Accessibility::Accessible*>& result, Comparer& comparer, size_t maxCount);
61 BridgeCollection() = default;
64 * @brief Registers Collection functions to dbus interfaces.
66 void RegisterInterfaces();
69 * @brief Returns the Collection object of the currently executed DBus method call.
71 * @return The Collection object
73 Dali::Accessibility::Collection* FindSelf() const;
77 * MatchRule type is a tuple that only carries data of de-serialized parameter from BridgeCollection::GetMatches dbus method.
79 using MatchRule = std::tuple<
80 std::array<int32_t, 2>,
82 std::unordered_map<std::string, std::string>,
84 std::array<int32_t, 4>,
86 std::vector<std::string>,
91 * @brief Enumeration for Collection Index.
98 ATTRIBUTES_MATCH_TYPE,
102 INTERFACES_MATCH_TYPE,
106 * @brief Gets the matching Accessible objects with MatchRule.
108 * @param[in] rule BridgeCollection::MatchRule
109 * @param[in] sortBy SortOrder::CANONICAL or SortOrder::REVERSE_CANONICAL
110 * @param[in] count The maximum number of objects
111 * @param[in] traverse True if it is traverse, otherwise false.
112 * @return The matching Accessible objects
114 DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetMatches(MatchRule rule, uint32_t sortBy, int32_t count, bool traverse);
117 #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H