1 /*
2  * Copyright (c) 2022 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 #include "remote_object_wrapper.h"
17 
18 namespace OHOS {
19 namespace AAFwk {
20 IINTERFACE_IMPL_1(RemoteObjectWrap, Object, IRemoteObjectWrap);
21 
RemoteObjectWrap(sptr<IRemoteObject> remoteObject)22 RemoteObjectWrap::RemoteObjectWrap(sptr<IRemoteObject> remoteObject) : remoteObject_(remoteObject) {}
23 
Equals(IObject & other)24 bool RemoteObjectWrap::Equals(IObject &other)
25 {
26     RemoteObjectWrap *otherObj = static_cast<RemoteObjectWrap *>(IRemoteObjectWrap::Query(&other));
27     return otherObj != nullptr && otherObj->remoteObject_ == remoteObject_;
28 }
29 
Box(sptr<IRemoteObject> remoteObject)30 sptr<IRemoteObjectWrap> RemoteObjectWrap::Box(sptr<IRemoteObject> remoteObject)
31 {
32     return sptr<IRemoteObjectWrap>(new RemoteObjectWrap(remoteObject));
33 }
34 
UnBox(IRemoteObjectWrap * object)35 sptr<IRemoteObject> RemoteObjectWrap::UnBox(IRemoteObjectWrap *object)
36 {
37     return object->GetValue();
38 }
39 
GetValue()40 sptr<IRemoteObject> RemoteObjectWrap::GetValue()
41 {
42     return this->remoteObject_;
43 }
44 }  // namespace AAFwk
45 }  // namespace OHOS