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 META_INTERFACE_IREQUIRED_INTERFACES_H
17 #define META_INTERFACE_IREQUIRED_INTERFACES_H
18 
19 #include <base/util/uid.h>
20 
21 #include <meta/base/interface_utils.h>
22 #include <meta/base/object_traits.h>
23 #include <meta/interface/interface_macros.h>
24 #include <meta/interface/intf_object.h>
25 #include <meta/interface/property/intf_property.h>
26 
27 META_BEGIN_NAMESPACE()
28 
29 META_REGISTER_INTERFACE(IRequiredInterfaces, "d59ca1ee-e82d-4eb7-b323-728c0f5fdde3")
30 
31 /**
32  * @brief The IRequiredInterfaces interface can be implemented by objects which require objects handled by the
33  *        implementer to implement a set of interfaces.
34  *        TYpically implementers also implement IContainer or IContent.
35  */
36 class IRequiredInterfaces : public CORE_NS::IInterface {
37     META_INTERFACE(CORE_NS::IInterface, IRequiredInterfaces)
38 public:
39     /**
40      * @brief Sets a set of Uids which all objects handled by the implementer must implement. If the list is empty
41      *        no interface check is made.
42      * @param interfaces List of interfaces an object handled by the implementer must to implement.
43      * @note Calling this function may alter the implementing object in case some existing items do not fulfill the new
44      *       interface requirements.
45      * @note This function may only affect the direct children of the implementer. If the implementer e.g. implements
46      *       an object hierarchy, the hierarchy may contain  objects that do not fulfill the requirement.
47      * @note IObject is an implicit requirement of any objects handled by the implementer, meaning that IObject::UID
48      *       does not need to be included in the interface list.
49      * @note The implementer may also opt to not allow changes to the required interfaces, in such cases
50      *       SetRequiredInterfaces should return false.
51      * @return True if the interface list was successfully applied, false otherwise.
52      */
53     virtual bool SetRequiredInterfaces(const BASE_NS::vector<TypeId>& interfaces) = 0;
54     /**
55      * @brief Returns the list of interfaces required by the implementer.
56      */
57     virtual BASE_NS::vector<TypeId> GetRequiredInterfaces() const = 0;
58 };
59 
60 META_END_NAMESPACE()
61 
62 #endif // META_INTERFACE_IREQUIRED_INTERFACES_H
63