<commit_before>// This is free and unencumbered software released into the public domain.
// For more information, please refer to <http://unlicense.org/>

#include "models/sagtension/line_cable_reloader.h"

#include "models/sagtension/catenary_cable_reloader.h"
#include "models/sagtension/line_cable_to_catenary_cable_converter.h"
#include "models/transmissionline/cable_unit_load_calculator.h"

LineCableReloader::LineCableReloader() {

  case_reloaded_ = nullptr;
  case_stretch_ = nullptr;
  line_cable_ = nullptr;

  is_updated_catenarycable_constraint_ = false;
  is_updated_load_stretch_ = false;
  is_updated_catenarycable_reloaded_ = false;
}

LineCableReloader::~LineCableReloader() {
}

Catenary3d LineCableReloader::CatenaryReloaded() const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return Catenary3d();
    }
  }

  Catenary3d catenary;
  catenary.set_spacing_endpoints(catenarycable_reloaded_.spacing_endpoints());
  catenary.set_tension_horizontal(catenarycable_reloaded_.tension_horizontal());
  catenary.set_weight_unit(catenarycable_reloaded_.weight_unit());
  return catenary;
}

double LineCableReloader::LoadStretch() const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return load_stretch_;
}

double LineCableReloader::TensionAverageComponent(
    const CableElongationModel::ComponentType& type_component) const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return solver_component_tension_.TensionAverageComponent(type_component);
}

double LineCableReloader::TensionHorizontal() const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return catenarycable_reloaded_.tension_horizontal();
}

double LineCableReloader::TensionHorizontalComponent(
    const CableElongationModel::ComponentType& type_component) const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return solver_component_tension_.TensionHorizontalComponent(type_component);
}

bool LineCableReloader::Validate(
    const bool& is_included_warnings,
    std::list<std::string>* messages_error) const {

  // initializes
  bool is_valid = true;

  // validates case-reloaded
  if (case_reloaded_ == nullptr) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELOADER - Invalid reloaded case");
    }
  } else {
    if (case_reloaded_->Validate(is_included_warnings,
                                 messages_error) == false) {
      is_valid = false;
    }
  }

  // validates loadcase-stretch
  if (case_stretch_ == nullptr) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELOADER - Invalid stretch case");
    }
  } else {
    if (case_stretch_->Validate(is_included_warnings,
                                messages_error) == false) {
      is_valid = false;
    }
  }

  // validates line cable
  if (line_cable_ == nullptr) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELOADER - Invalid lien cable");
    }
  } else {
    if (line_cable_->Validate(is_included_warnings, messages_error) == false) {
      is_valid = false;
    }
  }

  // further validates
  if (is_valid == true) {

    // validates update process
    if (Update() == false) {
      is_valid = false;
      if (messages_error != nullptr) {
        messages_error->push_back("LINE CABLE RELOADER - Error updating class");
      }
    }
  }

  return is_valid;
}

const WeatherLoadCase* LineCableReloader::case_reloaded() const {
  return case_reloaded_;<commit_msg>Updated validate function to check strongly typed enums.<commit_after>// This is free and unencumbered software released into the public domain.
// For more information, please refer to <http://unlicense.org/>

#include "models/sagtension/line_cable_reloader.h"

#include "models/sagtension/catenary_cable_reloader.h"
#include "models/sagtension/line_cable_to_catenary_cable_converter.h"
#include "models/transmissionline/cable_unit_load_calculator.h"

LineCableReloader::LineCableReloader() {

  case_reloaded_ = nullptr;
  case_stretch_ = nullptr;
  line_cable_ = nullptr;

  is_updated_catenarycable_constraint_ = false;
  is_updated_load_stretch_ = false;
  is_updated_catenarycable_reloaded_ = false;
}

LineCableReloader::~LineCableReloader() {
}

Catenary3d LineCableReloader::CatenaryReloaded() const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return Catenary3d();
    }
  }

  Catenary3d catenary;
  catenary.set_spacing_endpoints(catenarycable_reloaded_.spacing_endpoints());
  catenary.set_tension_horizontal(catenarycable_reloaded_.tension_horizontal());
  catenary.set_weight_unit(catenarycable_reloaded_.weight_unit());
  return catenary;
}

double LineCableReloader::LoadStretch() const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return load_stretch_;
}

double LineCableReloader::TensionAverageComponent(
    const CableElongationModel::ComponentType& type_component) const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return solver_component_tension_.TensionAverageComponent(type_component);
}

double LineCableReloader::TensionHorizontal() const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return catenarycable_reloaded_.tension_horizontal();
}

double LineCableReloader::TensionHorizontalComponent(
    const CableElongationModel::ComponentType& type_component) const {

  // updates class if necessary
  if (IsUpdated() == false) {
    if (Update() == false) {
      return -999999;
    }
  }

  return solver_component_tension_.TensionHorizontalComponent(type_component);
}

bool LineCableReloader::Validate(
    const bool& is_included_warnings,
    std::list<std::string>* messages_error) const {

  // initializes
  bool is_valid = true;

  // validates case-reloaded
  if (case_reloaded_ == nullptr) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELOADER - Invalid reloaded case");
    }
  } else {
    if (case_reloaded_->Validate(is_included_warnings,
                                 messages_error) == false) {
      is_valid = false;
    }
  }

  // validates case-stretch
  if (case_stretch_ == nullptr) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELOADER - Invalid stretch case");
    }
  } else {
    if (case_stretch_->Validate(is_included_warnings,
                                messages_error) == false) {
      is_valid = false;
    }
  }

  // validates condition-reloaded
  if ((condition_reloaded_ != CableConditionType::kCreep)
      && (condition_reloaded_ != CableConditionType::kInitial)
      && (condition_reloaded_ != CableConditionType::kLoad)) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELAODER - Invalid reloaded "
                                "condition");
    }
  }

  // validates line cable
  if (line_cable_ == nullptr) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELOADER - Invalid line cable");
    }
  } else {
    if (line_cable_->Validate(is_included_warnings, messages_error) == false) {
      is_valid = false;
    }
  }

  // validates type-stretch
  if ((type_stretch_ != CableConditionType::kCreep)
      && (type_stretch_ != CableConditionType::kLoad)) {
    is_valid = false;
    if (messages_error != nullptr) {
      messages_error->push_back("LINE CABLE RELOADER - Invalid stretch type");
    }
  }

  // further validates
  if (is_valid == true) {

    // validates update process
    if (Update() == false) {
      is_valid = false;
      if (messages_error != nullptr) {
        messages_error->push_back("LINE CABLE RELOADER - Error updating class");
      }
    }
  }

  return is_valid;
}

const WeatherLoadCase* LineCableReloader::case_reloaded() const {
  return case_reloaded_;
{'fraction_non_alphanumeric': 0.10831471245442785, 'fraction_numerical': 0.006350699753028343, 'mean_word_length': 3.523404255319149, 'pattern_counts': {'":': 0, '<': 7, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1066530', 'n_tokens_mistral': 2860, 'n_tokens_neox': 2728, 'n_words': 542}