#pragma once
#include <vector>
#include "dvm.h"
#include "../GraphCall/graph_calls.h"

class ParallelStats
{
public:
    ParallelStats()
    {
        RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
    }
     
    int RemoteCount;
    int ShadowCount;
    int ReductionCount;
    int AcrossCount;
};

class PredictorStats
{
public:
    PredictorStats()
    {
        ParallelCount = RemoteCount = RedistributeCount = IntervalCount = 0;
        TotalScorePar = TotalScoreComm = TotalScoreDist = 0;
    }
     
    ParallelStats ParallelStat;
    int ParallelCount;
    int RemoteCount;
    int RedistributeCount;
    int IntervalCount;
    int TotalScoreComm;
    int TotalScorePar;
    int TotalScoreDist;

    std::string to_string()
    {
        std::string res = "";
        res += std::to_string(ParallelCount) + "|";
        res += std::to_string(RemoteCount) + "|";
        res += std::to_string(RedistributeCount) + "|";
        res += std::to_string(IntervalCount) + "|";

        res += std::to_string(ParallelStat.RemoteCount) + "|";
        res += std::to_string(ParallelStat.ShadowCount) + "|";
        res += std::to_string(ParallelStat.ReductionCount) + "|";
        res += std::to_string(ParallelStat.AcrossCount);

        return res;
    }
};

void processFileToPredict(SgFile *file, PredictorStats &predictorCounts);

void calculateStatsForPredictor(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo);
void parseDvmDirForPredictor(const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays, const std::map<std::string, CommonBlock*>& commonBlocks, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo);