MeLOn
modelParser.h
Go to the documentation of this file.
1 /**********************************************************************************
2 * Copyright (c) 2020 Process Systems Engineering (AVT.SVT), RWTH Aachen University
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License 2.0 which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * SPDX-License-Identifier: EPL-2.0
9 *
10 * @file modelParser.h
11 *
12 * @brief File containing declaration of the ModelParser class.
13 *
14 **********************************************************************************/
15 
16 #pragma once
17 
18 #include <string> // std::string
19 
20 #include "exceptions.h"
21 #include "modelData.h"
22 #include "scaler.h"
23 
24 namespace melon {
25 
30  enum MODEL_FILE_TYPE {
31  CSV = 0,
32  XML,
33  JSON
34  };
35 
40  class ModelParser {
41  public:
51  virtual std::shared_ptr<ModelData> parse_model(const std::string modelPath, const std::string modelName) = 0;
52 
57  virtual ~ModelParser() = default;
58 
59  protected:
60  std::string _modelPath;
61  std::string _modelName;
74  std::string _format_file_path(const std::string modelPath, const std::string modelName, const MODEL_FILE_TYPE fileType);
75 
83  static SCALER_TYPE _string_to_scaler_type(const std::string scalerTypeName);
84 
92  static SCALER_PARAMETER _string_to_scaler_parameter(const std::string scalerParameterName);
93  };
94 
99  class ModelParserFactory {
100  public:
101 
109  virtual std::unique_ptr<ModelParser> create_model_parser(const MODEL_FILE_TYPE fileType) = 0;
110  };
111 }
melon::MODEL_FILE_TYPE
MODEL_FILE_TYPE
Enum for representing the parsable filetypes.
Definition: modelParser.h:43
exceptions.h
melon::ModelParserFactory::create_model_parser
virtual std::unique_ptr< ModelParser > create_model_parser(const MODEL_FILE_TYPE fileType)=0
Abstract factory function for creating a instance of an model parser corresponding to the specified f...
melon::ModelParser::_format_file_path
std::string _format_file_path(const std::string modelPath, const std::string modelName, const MODEL_FILE_TYPE fileType)
Applies the correct format to the path given by the user.
Definition: modelParser.cpp:28
melon::CSV
@ CSV
Definition: modelParser.h:44
scaler.h
modelData.h
melon::ModelParser::_modelPath
std::string _modelPath
Definition: modelParser.h:73
melon::XML
@ XML
Definition: modelParser.h:45
melon::ModelParser::_modelName
std::string _modelName
Definition: modelParser.h:74
melon::SCALER_TYPE
SCALER_TYPE
Enum for representing the available types of scalers.
Definition: scaler.h:44
melon::ModelParser::~ModelParser
virtual ~ModelParser()=default
Virtual desctructor to enable inheritance.
melon::JSON
@ JSON
Definition: modelParser.h:46
melon::ModelParser::_string_to_scaler_type
static SCALER_TYPE _string_to_scaler_type(const std::string scalerTypeName)
Turns a string containing the name of an scaler type in the correct enum representation.
Definition: modelParser.cpp:88
melon::ModelParserFactory
This class is a abstract parent class for model parser factories implemented in the MeLOn library.
Definition: modelParser.h:112
melon::SCALER_PARAMETER
SCALER_PARAMETER
Definition: scaler.h:54
melon
Definition: kernel.h:21
melon::ModelParser::parse_model
virtual std::shared_ptr< ModelData > parse_model(const std::string modelPath, const std::string modelName)=0
Abstract function for defining the structure of the parsing function which is used to get the model d...
melon::ModelParser::_string_to_scaler_parameter
static SCALER_PARAMETER _string_to_scaler_parameter(const std::string scalerParameterName)
Turns a string containing the name of an scaler type in the correct enum representation.
Definition: modelParser.cpp:106