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