Skip to content

Commit

Permalink
add const&
Browse files Browse the repository at this point in the history
Signed-off-by: Laurynas Jagutis <[email protected]>
  • Loading branch information
Laurynas-Jagutis committed Oct 7, 2024
1 parent f42fb55 commit ab637af
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ create_const_dataset_from_container(const power_grid_model::Container<power_grid
return const_dataset;
}

inline std::string get_serialized_data(power_grid_model::ConstDataset& const_dataset) {
inline std::string serialize_data(power_grid_model::ConstDataset& const_dataset) {
power_grid_model::meta_data::Serializer serializer(const_dataset, power_grid_model::SerializationFormat::json);
std::string serialized_pgm_data = serializer.get_string(false, -1);
return serialized_pgm_data;
Expand All @@ -35,13 +35,15 @@ class PgmVnfConverter {

// Public member functions
void parse_vnf_file();
std::string convert_input();
void convert_input();
std::string const& get_serialized_data();

private:
// Private attributes
char* f_file_buffer;
power_grid_model::WritableDataset*
deserialized_data; // this type because it is generated by a deserializer type structure
std::string serialized_data;

// Private setters/getters
void set_file_buffer(char* file_buffer);
Expand Down Expand Up @@ -76,7 +78,7 @@ inline void PgmVnfConverter::parse_vnf_file() {
// will be implemented later
}

inline std::string PgmVnfConverter::convert_input() {
inline void PgmVnfConverter::convert_input() {
std::vector<power_grid_model::Node> const nodes = convert_node_input();
convert_line_input();
convert_sources_input();
Expand All @@ -96,14 +98,14 @@ inline std::string PgmVnfConverter::convert_input() {

power_grid_model::ConstDataset const_dataset = create_const_dataset_from_container(container, meta_data);

std::string serialized_pgm_data = get_serialized_data(const_dataset);
std::string serialized_pgm_data = serialize_data(const_dataset);

// 1. our vnf importer it directly understands the vnf format
// 2. convert vnf like dataset to internal types (take raw data and convert it to pgm component container)
// 3. another function which 1. makes const dataset view from pgm component container 2. const dataset to
// serializer

return serialized_pgm_data;
this->serialized_data = serialized_pgm_data;
}

inline void PgmVnfConverter::set_file_buffer(char* file_buffer) { this->f_file_buffer = file_buffer; }
Expand All @@ -116,6 +118,8 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; }

inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; }

inline std::string const& PgmVnfConverter::get_serialized_data() { return this->serialized_data; }

inline std::vector<power_grid_model::Node>
PgmVnfConverter::convert_node_input() { // NOLINT(readability-convert-member-functions-to-static)

Expand Down Expand Up @@ -161,6 +165,9 @@ inline void PgmVnfConverter::convert_links_input() {

inline void parse_vnf_file_wrapper(PgmVnfConverter* obj) { obj->parse_vnf_file(); }

inline std::string convert_input_wrapper(PgmVnfConverter* obj) { return obj->convert_input(); }
inline std::string const& convert_input_wrapper(PgmVnfConverter* obj) {
obj->convert_input();
return obj->get_serialized_data();
}

#endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP

0 comments on commit ab637af

Please sign in to comment.