Files
刘瓒 8ef91b3c3c 告警修改
修复 RequestBuffers 中 num 变量重复声明导致的编译错误
拆分 BufferExtraDataImpl::ReadFromParcel 和
BufferClientProducer::RequestBuffers 超大函数
提取 ReadExtraDataItem 和 ReadRequestBuffersReply 辅助函数

Co-Authored-By: Agent
Signed-off-by: 刘瓒 <liuzan9@huawei.com>
Change-Id: Ida357f2752c6e9c92e49ed07a9d097ad49774bc2
2026-07-10 06:30:10 +00:00

59 lines
2.3 KiB
C++

/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_SURFACE_INCLUDE_BUFFER_EXTRA_DATA_IMPL_H
#define FRAMEWORKS_SURFACE_INCLUDE_BUFFER_EXTRA_DATA_IMPL_H
#include <buffer_extra_data.h>
#include <any>
#include <mutex>
namespace OHOS {
class BufferExtraDataImpl : public BufferExtraData {
public:
virtual GSError ReadFromParcel(MessageParcel &parcel) override;
virtual GSError WriteToParcel(MessageParcel &parcel) override;
virtual GSError ExtraGet(const std::string &key, int32_t &value) const override;
virtual GSError ExtraGet(const std::string &key, int64_t &value) const override;
virtual GSError ExtraGet(const std::string &key, double &value) const override;
virtual GSError ExtraGet(const std::string &key, std::string &value) const override;
virtual GSError ExtraSet(const std::string &key, int32_t value) override;
virtual GSError ExtraSet(const std::string &key, int64_t value) override;
virtual GSError ExtraSet(const std::string &key, double value) override;
virtual GSError ExtraSet(const std::string &key, const std::string& value) override;
private:
enum class ExtraDataType : int32_t {
i32,
i64,
f64,
string,
};
template<class T>
GSError ExtraGet(const std::string &key, ExtraDataType type, T &value) const;
GSError ExtraSet(const std::string &key, ExtraDataType type, const std::any& val);
GSError ReadExtraDataItem(MessageParcel &parcel, const std::string &key, ExtraDataType type);
struct ExtraData {
std::any val;
ExtraDataType type;
};
std::map<std::string, struct ExtraData> datas_;
mutable std::mutex mtx_;
};
} // namespace OHOS
#endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_EXTRA_DATA_IMPL_H