<commit_before>/*
 * Copyright (c) 2016 SeNDA
 *
 * 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.
 *
 */
/**
 * FILE Framework1Processor.cpp
 * AUTHOR Blackcatn13
 * DATE Apr 4, 2016
 * VERSION 1
 *
 */

#include "Node/BundleProcessor/FirstADTNPlusFwk.h"
#include <memory>
#include <vector>
#include <string>
#include <fstream>
#include "Node/BundleProcessor/BundleProcessor.h"
#include "Node/BundleQueue/BundleQueue.h"
#include "Node/Neighbour/NeighbourTable.h"
#include "Node/Config.h"
#include "Node/BundleQueue/BundleContainer.h"
#include "Bundle/Bundle.h"
#include "Bundle/PrimaryBlock.h"
#include "Bundle/FrameworkMEB.h"
#include "Bundle/FrameworkExtension.h"
#include "Bundle/BundleInfo.h"
#include "Utils/Logger.h"
#include "Node/AppListener/ListeningAppsTable.h"
#include "Node/BundleProcessor/PluginAPI.h"
#include "Utils/globals.h"

NEW_PLUGIN(FirstADTNPlusFwk, "First active DTN framework", "1.0",
           "This processor allows to implement up to 5 functions.")

const std::string FirstADTNPlusFwk::m_header = "#include <vector>\n"
    "#include <exception>\n"
    "#include <stdexcept>\n"
    "#include <string>\n"
    "#include <algorithm>\n"
    "#include <cstdlib>\n"
    "#include <ctime>\n"
    "#include \"Bundle/BundleInfo.h\"\n"
    "#include \"adtnPlus/Json.h\"\n"
    "#include \"adtnPlus/Worker.h\"\n"
    "extern \"C\" {\n"
    "const uint64_t g_timeFrom2000 = 946684800;\n";
const std::string FirstADTNPlusFwk::m_bigSignature =
    "%s f(Json ns, nlohmann::json bs, nlohmann::json bps, BundleInfo bi,"
        " Worker<%s, Json, nlohmann::json, BundleInfo> worker) {\n"
        "auto super = [&]() {try{\n"
        "worker.execute(ns, bps, bi);\n"
        "return worker.getResult();\n"
        "} catch (const WorkerException &e) {\n"
        "throw e;\n"
        "}};";
const std::string FirstADTNPlusFwk::m_littleSignature =
    "%s f(Json ns, nlohmann::json bps, BundleInfo bi) {\n";
const std::string FirstADTNPlusFwk::m_footer = "return %s;}}";
const std::string FirstADTNPlusFwk::m_commandLine =
    "g++ -w -fPIC -shared -std=c++14 %s -o %s 2>&1";

FirstADTNPlusFwk::FirstADTNPlusFwk()
    : m_voidWorker(m_header + stringFormat(m_bigSignature, "bool", "bool"),
                   stringFormat(m_footer, "true"), "f", m_commandLine, "./"),
      m_boolWorker(m_header + stringFormat(m_bigSignature, "bool", "bool"),
                   stringFormat(m_footer, "true"), "f", m_commandLine, "./"),
      m_vectorWorker(
          m_header
              + stringFormat(m_bigSignature, "std::vector<std::string>",
                             "std::vector<std::string>"),
          m_footer, "f", m_commandLine, "./"),
      m_ext1DefaultWorker(m_header + stringFormat(m_littleSignature, "bool"),
                          stringFormat(m_footer, "true"), "f", m_commandLine,
                          "./"),
      m_ext2DefaultWorker(m_header + stringFormat(m_littleSignature, "bool"),<commit_msg>Fixes missing stringFormat in vectorWorker.<commit_after>/*
 * Copyright (c) 2016 SeNDA
 *
 * 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.
 *
 */
/**
 * FILE Framework1Processor.cpp
 * AUTHOR Blackcatn13
 * DATE Apr 4, 2016
 * VERSION 1
 *
 */

#include "Node/BundleProcessor/FirstADTNPlusFwk.h"
#include <memory>
#include <vector>
#include <string>
#include <fstream>
#include "Node/BundleProcessor/BundleProcessor.h"
#include "Node/BundleQueue/BundleQueue.h"
#include "Node/Neighbour/NeighbourTable.h"
#include "Node/Config.h"
#include "Node/BundleQueue/BundleContainer.h"
#include "Bundle/Bundle.h"
#include "Bundle/PrimaryBlock.h"
#include "Bundle/FrameworkMEB.h"
#include "Bundle/FrameworkExtension.h"
#include "Bundle/BundleInfo.h"
#include "Utils/Logger.h"
#include "Node/AppListener/ListeningAppsTable.h"
#include "Node/BundleProcessor/PluginAPI.h"
#include "Utils/globals.h"

NEW_PLUGIN(FirstADTNPlusFwk, "First active DTN framework", "1.0",
           "This processor allows to implement up to 5 functions.")

const std::string FirstADTNPlusFwk::m_header = "#include <vector>\n"
    "#include <exception>\n"
    "#include <stdexcept>\n"
    "#include <string>\n"
    "#include <algorithm>\n"
    "#include <cstdlib>\n"
    "#include <ctime>\n"
    "#include \"Bundle/BundleInfo.h\"\n"
    "#include \"adtnPlus/Json.h\"\n"
    "#include \"adtnPlus/Worker.h\"\n"
    "extern \"C\" {\n"
    "const uint64_t g_timeFrom2000 = 946684800;\n";
const std::string FirstADTNPlusFwk::m_bigSignature =
    "%s f(Json ns, nlohmann::json bs, nlohmann::json bps, BundleInfo bi,"
        " Worker<%s, Json, nlohmann::json, BundleInfo> worker) {\n"
        "auto super = [&]() {try{\n"
        "worker.execute(ns, bps, bi);\n"
        "return worker.getResult();\n"
        "} catch (const WorkerException &e) {\n"
        "throw e;\n"
        "}};";
const std::string FirstADTNPlusFwk::m_littleSignature =
    "%s f(Json ns, nlohmann::json bps, BundleInfo bi) {\n";
const std::string FirstADTNPlusFwk::m_footer = "return %s;}}";
const std::string FirstADTNPlusFwk::m_commandLine =
    "g++ -w -fPIC -shared -std=c++14 %s -o %s 2>&1";

FirstADTNPlusFwk::FirstADTNPlusFwk()
    : m_voidWorker(m_header + stringFormat(m_bigSignature, "bool", "bool"),
                   stringFormat(m_footer, "true"), "f", m_commandLine, "./"),
      m_boolWorker(m_header + stringFormat(m_bigSignature, "bool", "bool"),
                   stringFormat(m_footer, "true"), "f", m_commandLine, "./"),
      m_vectorWorker(
          m_header
              + stringFormat(m_bigSignature, "std::vector<std::string>",
                             "std::vector<std::string>"),
          stringFormat(m_footer, "std::vector<std::string>()"), "f",
          m_commandLine, "./"),
      m_ext1DefaultWorker(m_header + stringFormat(m_littleSignature, "bool"),
                          stringFormat(m_footer, "true"), "f", m_commandLine,
                          "./"),
      m_ext2DefaultWorker(m_header + stringFormat(m_littleSignature, "bool"),
{'fraction_non_alphanumeric': 0.14811619211964336, 'fraction_numerical': 0.01179177451826287, 'mean_word_length': 3.578670177748519, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1081760', 'n_tokens_mistral': 2359, 'n_tokens_neox': 2266, 'n_words': 548}