<commit_before>// MIT License
//
// Copyright (c) 2017-2018 <NAME>, aljen at hitomi dot pl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#pragma once
#ifndef SPAGHETTI_PACKAGE_H
#define SPAGHETTI_PACKAGE_H

#include <atomic>

// clang-format off
#ifdef _MSC_VER
# include <unordered_map>
#else
# include <sparsepp/spp.h>
#endif
// clang-format on

#include <spaghetti/api.h>
#include <spaghetti/element.h>
#include <spaghetti/strings.h>

// clang-format off
#define PACKAGE_SPP_MAP 1
#define PACKAGE_STD_UNORDERED_MAP 2
#ifdef _MSC_VER
# define PACKAGE_MAP PACKAGE_STD_UNORDERED_MAP
#else
# define PACKAGE_MAP PACKAGE_SPP_MAP
#endif
// clang-format on

namespace spaghetti {

class SPAGHETTI_API Package final : public Element {
 public:
  using Elements = std::vector<Element *>;
  struct Connection {
    size_t from_id{};
    uint8_t from_socket{};
    size_t to_id{};
    uint8_t to_socket{};
  };

  using Connections = std::vector<Connection>;

  Package();
  ~Package() override;

  static constexpr char const *const TYPE{ "logic/package" };
  static constexpr string::hash_t const HASH{ string::hash(TYPE) };

  char const *type() const noexcept override { return TYPE; }
  string::hash_t hash() const noexcept override { return HASH; }

  std::string_view packageDescription() const { return m_packageDescription; }
  void setPackageDescription(std::string a_description) { m_packageDescription = a_description; }

  std::string_view packagePath() const { return m_packagePath; }
  void setPackagePath(std::string a_path) { m_packagePath = a_path; }

  std::string_view packageIcon() const { return m_packageIcon; }
  void setPackageIcon(std::string a_icon) { m_packageIcon = a_icon; }

  void serialize(Json &a_json) override;
  void deserialize(Json const &a_json) override;

  Element *add(char const *const a_name) { return add(string::hash(a_name)); }
  Element *add(string::hash_t const a_hash);

  void remove(Element *const a_element) { remove(a_element->id()); }
  void remove(size_t const a_id);

  Element *get(size_t const a_id) const;

  bool connect(size_t const a_sourceId, uint8_t const a_outputId, size_t const a_targetId, uint8_t const a_inputId);
  bool disconnect(size_t const a_sourceId, uint8_t const a_outputId, size_t const a_targetId, uint8_t const a_inputId);<commit_msg>Pass std::string by const reference<commit_after>// MIT License
//
// Copyright (c) 2017-2018 <NAME>, aljen at hitomi dot pl
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#pragma once
#ifndef SPAGHETTI_PACKAGE_H
#define SPAGHETTI_PACKAGE_H

#include <atomic>

// clang-format off
#ifdef _MSC_VER
# include <unordered_map>
#else
# include <sparsepp/spp.h>
#endif
// clang-format on

#include <spaghetti/api.h>
#include <spaghetti/element.h>
#include <spaghetti/strings.h>

// clang-format off
#define PACKAGE_SPP_MAP 1
#define PACKAGE_STD_UNORDERED_MAP 2
#ifdef _MSC_VER
# define PACKAGE_MAP PACKAGE_STD_UNORDERED_MAP
#else
# define PACKAGE_MAP PACKAGE_SPP_MAP
#endif
// clang-format on

namespace spaghetti {

class SPAGHETTI_API Package final : public Element {
 public:
  using Elements = std::vector<Element *>;
  struct Connection {
    size_t from_id{};
    uint8_t from_socket{};
    size_t to_id{};
    uint8_t to_socket{};
  };

  using Connections = std::vector<Connection>;

  Package();
  ~Package() override;

  static constexpr char const *const TYPE{ "logic/package" };
  static constexpr string::hash_t const HASH{ string::hash(TYPE) };

  char const *type() const noexcept override { return TYPE; }
  string::hash_t hash() const noexcept override { return HASH; }

  std::string_view packageDescription() const { return m_packageDescription; }
  void setPackageDescription(std::string const &a_description) { m_packageDescription = a_description; }

  std::string_view packagePath() const { return m_packagePath; }
  void setPackagePath(std::string const &a_path) { m_packagePath = a_path; }

  std::string_view packageIcon() const { return m_packageIcon; }
  void setPackageIcon(std::string const &a_icon) { m_packageIcon = a_icon; }

  void serialize(Json &a_json) override;
  void deserialize(Json const &a_json) override;

  Element *add(char const *const a_name) { return add(string::hash(a_name)); }
  Element *add(string::hash_t const a_hash);

  void remove(Element *const a_element) { remove(a_element->id()); }
  void remove(size_t const a_id);

  Element *get(size_t const a_id) const;

  bool connect(size_t const a_sourceId, uint8_t const a_outputId, size_t const a_targetId, uint8_t const a_inputId);
  bool disconnect(size_t const a_sourceId, uint8_t const a_outputId, size_t const a_targetId, uint8_t const a_inputId);
{'fraction_non_alphanumeric': 0.09185648354920352, 'fraction_numerical': 0.004764031561709096, 'mean_word_length': 4.741880341880342, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '513446', 'n_tokens_mistral': 2127, 'n_tokens_neox': 2018, 'n_words': 738}