13920e296Sopenharmony_ci/*
23920e296Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
33920e296Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43920e296Sopenharmony_ci * you may not use this file except in compliance with the License.
53920e296Sopenharmony_ci * You may obtain a copy of the License at
63920e296Sopenharmony_ci *
73920e296Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
83920e296Sopenharmony_ci *
93920e296Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103920e296Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113920e296Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123920e296Sopenharmony_ci * See the License for the specific language governing permissions and
133920e296Sopenharmony_ci * limitations under the License.
143920e296Sopenharmony_ci */
153920e296Sopenharmony_ci
163920e296Sopenharmony_ci#ifndef OHOS_RESTOOL_RESOURCE_COMPILER_H
173920e296Sopenharmony_ci#define OHOS_RESTOOL_RESOURCE_COMPILER_H
183920e296Sopenharmony_ci
193920e296Sopenharmony_ci#include <vector>
203920e296Sopenharmony_ci#include "resource_data.h"
213920e296Sopenharmony_ci#include "resource_item.h"
223920e296Sopenharmony_ci
233920e296Sopenharmony_cinamespace OHOS {
243920e296Sopenharmony_cinamespace Global {
253920e296Sopenharmony_cinamespace Restool {
263920e296Sopenharmony_ciclass IResourceCompiler {
273920e296Sopenharmony_cipublic:
283920e296Sopenharmony_ci    IResourceCompiler(ResType type, const std::string &output);
293920e296Sopenharmony_ci    virtual ~IResourceCompiler();
303920e296Sopenharmony_ci    uint32_t Compile(const std::vector<DirectoryInfo> &directoryInfos);
313920e296Sopenharmony_ci    const std::map<int64_t, std::vector<ResourceItem>> &GetResult() const;
323920e296Sopenharmony_ci    uint32_t Compile(const FileInfo &fileInfo);
333920e296Sopenharmony_ci    void SetModuleName(const std::string &moduleName);
343920e296Sopenharmony_ci    uint32_t CompileForAppend(const FileInfo &fileInfo);
353920e296Sopenharmony_ci    const std::map<std::pair<ResType, std::string>, std::vector<ResourceItem>> &GetResourceItems() const;
363920e296Sopenharmony_ci
373920e296Sopenharmony_ciprotected:
383920e296Sopenharmony_ci    virtual uint32_t CompileSingleFile(const FileInfo &fileInfo);
393920e296Sopenharmony_ci    virtual uint32_t CompileFiles(const std::vector<FileInfo> &fileInfos);
403920e296Sopenharmony_ci    bool MergeResourceItem(const ResourceItem &resourceItem);
413920e296Sopenharmony_ci    std::string GetOutputFolder(const DirectoryInfo &directoryInfo) const;
423920e296Sopenharmony_ci    ResType type_;
433920e296Sopenharmony_ci    std::string output_;
443920e296Sopenharmony_ci    std::string moduleName_;
453920e296Sopenharmony_ci
463920e296Sopenharmony_ci    // id, resource items
473920e296Sopenharmony_ci    std::map<int64_t, std::vector<ResourceItem>> resourceInfos_;
483920e296Sopenharmony_ci    // ResType, name, resourceItems
493920e296Sopenharmony_ci    std::map<std::pair<ResType, std::string>, std::vector<ResourceItem>> nameInfos_;
503920e296Sopenharmony_ci
513920e296Sopenharmony_ciprivate:
523920e296Sopenharmony_ci    uint32_t PostCommit();
533920e296Sopenharmony_ci};
543920e296Sopenharmony_ci}
553920e296Sopenharmony_ci}
563920e296Sopenharmony_ci}
573920e296Sopenharmony_ci#endif