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_SRC_CONNECTOR_H
17 #define META_SRC_CONNECTOR_H
18 
19 #include <meta/ext/attachment/attachment.h>
20 #include <meta/interface/intf_connector.h>
21 #include <meta/interface/intf_object.h>
22 #include <meta/interface/serialization/intf_serializable.h>
23 
META_BEGIN_NAMESPACE()24 META_BEGIN_NAMESPACE()
25 
26 class Connector : public META_NS::AttachmentFwd<Connector, ClassId::Connector, IConnector, ISerializable> {
27 public:
28     bool AttachTo(const META_NS::IAttach::Ptr& target, const META_NS::IObject::Ptr& dataContext) override;
29     bool DetachFrom(const META_NS::IAttach::Ptr& target) override;
30 
31     bool Connect(const IObject::Ptr& source, const BASE_NS::string& event, const BASE_NS::string& func) override;
32     IObject::Ptr GetSource() const override;
33     BASE_NS::string GetEventName() const override;
34     BASE_NS::string GetFunctionName() const override;
35 
36     ReturnError Export(IExportContext&) const override;
37     ReturnError Import(IImportContext&) override;
38 
39 private:
40     IEvent::Token handle_ {};
41     RefUri uri_;
42     IMetadata::WeakPtr source_;
43     BASE_NS::string eventName_;
44     BASE_NS::string funcName_;
45 };
46 
47 META_END_NAMESPACE()
48 
49 #endif
50