-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
291 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
include/open_atmos/mechanism_configuration/parse_status.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (C) 2023-2024 National Center for Atmospheric Research, University of Illinois at Urbana-Champaign | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace open_atmos | ||
{ | ||
namespace mechanism_configuration | ||
{ | ||
enum class ConfigParseStatus | ||
{ | ||
Success, | ||
None, | ||
InvalidKey, | ||
UnknownKey, | ||
InvalidFilePath, | ||
ObjectTypeNotFound, | ||
RequiredKeyNotFound, | ||
MutuallyExclusiveOption, | ||
InvalidVersion, | ||
DuplicateSpeciesDetected, | ||
DuplicatePhasesDetected, | ||
PhaseRequiresUnknownSpecies, | ||
ReactionRequiresUnknownSpecies, | ||
UnknownPhase, | ||
RequestedAerosolSpeciesNotIncludedInAerosolPhase, | ||
TooManyReactionComponents, | ||
InvalidIonPair | ||
}; | ||
std::string configParseStatusToString(const ConfigParseStatus &status); | ||
|
||
} // namespace mechanism_configuration | ||
} // namespace open_atmos |
41 changes: 41 additions & 0 deletions
41
include/open_atmos/mechanism_configuration/yaml_parser.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (C) 2023-2024 National Center for Atmospheric Research, University of Illinois at Urbana-Champaign | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <filesystem> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <open_atmos/mechanism_configuration/parse_status.hpp> | ||
#include <yaml-cpp/yaml.h> | ||
#include <open_atmos/types.hpp> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace open_atmos | ||
{ | ||
namespace mechanism_configuration | ||
{ | ||
class YamlParser | ||
{ | ||
public: | ||
/// @brief Reads a configuration from a YAML node | ||
/// @param node a YAML node | ||
/// @return A pair containing the parsing status and mechanism | ||
std::pair<ConfigParseStatus, types::Mechanism> Parse(const YAML::Node& node); | ||
|
||
/// @brief Reads a configuration from a file path | ||
/// @param file_path A path to single YAML configuration | ||
/// @return A pair containing the parsing status and mechanism | ||
std::pair<ConfigParseStatus, types::Mechanism> Parse(const std::filesystem::path& file_path); | ||
|
||
/// @brief Reads a configuration from a file path | ||
/// @param file_path A path to single YAML configuration | ||
/// @return A pair containing the parsing status and mechanism | ||
std::pair<ConfigParseStatus, types::Mechanism> Parse(const std::string& file_path); | ||
}; | ||
} // namespace mechanism_configuration | ||
} // namespace open_atmos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <open_atmos/mechanism_configuration/parse_status.hpp> | ||
|
||
namespace open_atmos | ||
{ | ||
namespace mechanism_configuration | ||
{ | ||
std::string configParseStatusToString(const ConfigParseStatus& status) | ||
{ | ||
switch (status) | ||
{ | ||
case ConfigParseStatus::Success: return "Success"; | ||
case ConfigParseStatus::None: return "None"; | ||
case ConfigParseStatus::InvalidKey: return "InvalidKey"; | ||
case ConfigParseStatus::UnknownKey: return "UnknownKey"; | ||
case ConfigParseStatus::InvalidFilePath: return "InvalidFilePath"; | ||
case ConfigParseStatus::ObjectTypeNotFound: return "ObjectTypeNotFound"; | ||
case ConfigParseStatus::RequiredKeyNotFound: return "RequiredKeyNotFound"; | ||
case ConfigParseStatus::MutuallyExclusiveOption: return "MutuallyExclusiveOption"; | ||
case ConfigParseStatus::DuplicateSpeciesDetected: return "DuplicateSpeciesDetected"; | ||
case ConfigParseStatus::DuplicatePhasesDetected: return "DuplicatePhasesDetected"; | ||
case ConfigParseStatus::PhaseRequiresUnknownSpecies: return "PhaseRequiresUnknownSpecies"; | ||
case ConfigParseStatus::ReactionRequiresUnknownSpecies: return "ReactionRequiresUnknownSpecies"; | ||
case ConfigParseStatus::UnknownPhase: return "UnknownPhase"; | ||
case ConfigParseStatus::RequestedAerosolSpeciesNotIncludedInAerosolPhase: return "RequestedAerosolSpeciesNotIncludedInAerosolPhase"; | ||
case ConfigParseStatus::TooManyReactionComponents: return "TooManyReactionComponents"; | ||
case ConfigParseStatus::InvalidIonPair: return "InvalidIonPair"; | ||
default: return "Unknown"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.