File indexing completed on 2024-05-19 05:44:25

0001 /*
0002     SPDX-FileCopyrightText: 2020 Milian Wolff <mail@milianw.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef RESULTDATA_H
0008 #define RESULTDATA_H
0009 
0010 #include <analyze/allocationdata.h>
0011 
0012 #include "locationdata.h"
0013 #include "util.h"
0014 
0015 #include <QVector>
0016 
0017 #include <memory>
0018 
0019 class ResultData
0020 {
0021 public:
0022     ResultData(AllocationData totalCosts, QVector<QString> strings)
0023         : m_totalCosts(std::move(totalCosts))
0024         , m_strings(std::move(strings))
0025     {
0026     }
0027 
0028     QString string(StringIndex stringId) const
0029     {
0030         return m_strings.value(stringId.index - 1);
0031     }
0032 
0033     QString string(FunctionIndex functionIndex) const
0034     {
0035         return functionIndex ? string(static_cast<StringIndex>(functionIndex)) : Util::unresolvedFunctionName();
0036     }
0037 
0038     const AllocationData& totalCosts() const
0039     {
0040         return m_totalCosts;
0041     }
0042 
0043 private:
0044     AllocationData m_totalCosts;
0045     QVector<QString> m_strings;
0046 };
0047 
0048 Q_DECLARE_METATYPE(const ResultData*)
0049 
0050 #endif // RESULTDATA_H