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_CONNECTOR_H 17 #define META_INTERFACE_CONNECTOR_H 18 19 #include <core/plugin/intf_interface.h> 20 21 #include <meta/base/namespace.h> 22 #include <meta/base/types.h> 23 #include <meta/interface/intf_any.h> 24 #include <meta/interface/intf_call_context.h> 25 #include <meta/interface/intf_callable.h> 26 27 META_BEGIN_NAMESPACE() 28 29 /** 30 * @brief Interface for objects that do event <-> meta function connections. 31 * Such objects are usually attachments and so the actual connection is done when attaching to the destination 32 * object. 33 */ 34 class IConnector : public CORE_NS::IInterface { 35 META_INTERFACE(CORE_NS::IInterface, IConnector, "a6c9f964-da3e-45e1-8301-ca8c4ff1c628") 36 public: 37 /** 38 * @brief Connect event to meta function. 39 * @param source Object that contains the event. 40 * @param event Name of the event. 41 * @param func Name of the function, the attached object is used as destination object. 42 * @return True on success, otherwise false. 43 * Note: This doesn't do the actual connection, it is done when the attachement is added to an object. 44 */ 45 virtual bool Connect(const IObject::Ptr& source, const BASE_NS::string& event, const BASE_NS::string& func) = 0; 46 47 /** 48 * @brief Get the source object or null if not set (or alive). 49 */ 50 virtual IObject::Ptr GetSource() const = 0; 51 /** 52 * @brief Get the event name. 53 */ 54 virtual BASE_NS::string GetEventName() const = 0; 55 /** 56 * @brief Get the function name. 57 */ 58 virtual BASE_NS::string GetFunctionName() const = 0; 59 }; 60 61 META_END_NAMESPACE() 62 63 #endif 64