-
Notifications
You must be signed in to change notification settings - Fork 14
Form read write split #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2ffcd6b
0be8f74
75fdbc5
471b535
b7ddde1
c0071a7
e464bda
3e7360e
aac5c6a
23e120b
0e84f5f
d586ade
ee7bae1
a28c500
0c07e0a
4346c13
7c9742a
82aa92f
0153e49
c47a8c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright (C) 2025 ... | ||
|
|
||
| #include "form_reader.hpp" | ||
|
|
||
| #include <stdexcept> | ||
| #include <typeinfo> | ||
|
|
||
| namespace form::experimental { | ||
|
|
||
| form_reader_interface::form_reader_interface(config::output_item_config const& output_config, | ||
| config::tech_setting_config const& tech_config) : | ||
| m_pers(nullptr) | ||
| { | ||
| for (auto const& item : output_config.getItems()) { | ||
| m_product_to_config.emplace(item.product_name, | ||
| form::experimental::config::PersistenceItem( | ||
| item.product_name, item.file_name, item.technology)); | ||
| } | ||
|
|
||
| m_pers = form::detail::experimental::createPersistenceReader(); | ||
| m_pers->configureOutputItems(output_config); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Reader?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're correct about this. Will review and probably change. Thanks.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs a rename but can't be eliminated without rewriting more of PersistenceReader. We use |
||
| m_pers->configureTechSettings(tech_config); | ||
| } | ||
|
|
||
| void form_reader_interface::read(std::string const& creator, | ||
| std::string const& segment_id, | ||
| product_with_name& pb) | ||
| { | ||
|
|
||
| auto it = m_product_to_config.find(pb.label); | ||
| if (it == m_product_to_config.end()) { | ||
| throw std::runtime_error("No configuration found for product: " + pb.label); | ||
| } | ||
|
|
||
| m_pers->read(creator, pb.label, segment_id, &pb.data, *pb.type); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright (C) 2025 ... | ||
|
|
||
| #ifndef FORM_FORM_FORM_READER_HPP | ||
| #define FORM_FORM_FORM_READER_HPP | ||
|
|
||
| #include "form/config.hpp" | ||
| #include "form/product_with_name.hpp" | ||
| #include "persistence/ipersistence_reader.hpp" | ||
|
|
||
| #include <map> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <typeinfo> | ||
| #include <vector> | ||
|
|
||
| namespace form::experimental { | ||
|
|
||
| class form_reader_interface { | ||
| public: | ||
| form_reader_interface(config::output_item_config const& output_config, | ||
| config::tech_setting_config const& tech_config); | ||
| ~form_reader_interface() = default; | ||
|
|
||
| void read(std::string const& creator, | ||
| std::string const& segment_id, | ||
| product_with_name& product); | ||
|
|
||
| private: | ||
| std::unique_ptr<form::detail::experimental::IPersistenceReader> m_pers; | ||
| std::map<std::string, form::experimental::config::PersistenceItem> m_product_to_config; | ||
| }; | ||
| } | ||
|
|
||
| #endif // FORM_FORM_FORM_READER_HPP |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| // Copyright (C) 2025 ... | ||
|
|
||
| #include "form.hpp" | ||
| #include "form_writer.hpp" | ||
|
|
||
| #include <stdexcept> | ||
| #include <typeinfo> | ||
|
|
||
| namespace form::experimental { | ||
|
|
||
| form_interface::form_interface(config::output_item_config const& output_config, | ||
| config::tech_setting_config const& tech_config) : | ||
| form_writer_interface::form_writer_interface(config::output_item_config const& output_config, | ||
| config::tech_setting_config const& tech_config) : | ||
| m_pers(nullptr) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest rename |
||
| { | ||
| for (auto const& item : output_config.getItems()) { | ||
|
|
@@ -17,14 +17,14 @@ namespace form::experimental { | |
| item.product_name, item.file_name, item.technology)); | ||
| } | ||
|
|
||
| m_pers = form::detail::experimental::createPersistence(); | ||
| m_pers = form::detail::experimental::createPersistenceWriter(); | ||
| m_pers->configureOutputItems(output_config); | ||
| m_pers->configureTechSettings(tech_config); | ||
| } | ||
|
|
||
| void form_interface::write(std::string const& creator, | ||
| std::string const& segment_id, | ||
| product_with_name const& pb) | ||
| void form_writer_interface::write(std::string const& creator, | ||
| std::string const& segment_id, | ||
| product_with_name const& pb) | ||
| { | ||
|
|
||
| auto it = m_product_to_config.find(pb.label); | ||
|
|
@@ -40,9 +40,9 @@ namespace form::experimental { | |
| m_pers->commitOutput(creator, segment_id); | ||
| } | ||
|
|
||
| void form_interface::write(std::string const& creator, | ||
| std::string const& segment_id, | ||
| std::vector<product_with_name> const& products) | ||
| void form_writer_interface::write(std::string const& creator, | ||
| std::string const& segment_id, | ||
| std::vector<product_with_name> const& products) | ||
| { | ||
|
|
||
| if (products.empty()) | ||
|
|
@@ -69,16 +69,4 @@ namespace form::experimental { | |
| m_pers->commitOutput(creator, segment_id); | ||
| } | ||
|
|
||
| void form_interface::read(std::string const& creator, | ||
| std::string const& segment_id, | ||
| product_with_name& pb) | ||
| { | ||
|
|
||
| auto it = m_product_to_config.find(pb.label); | ||
| if (it == m_product_to_config.end()) { | ||
| throw std::runtime_error("No configuration found for product: " + pb.label); | ||
| } | ||
|
|
||
| m_pers->read(creator, pb.label, segment_id, &pb.data, *pb.type); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright (C) 2025 ... | ||
|
|
||
| #ifndef FORM_FORM_FORM_WRITER_HPP | ||
| #define FORM_FORM_FORM_WRITER_HPP | ||
|
|
||
| #include "form/config.hpp" | ||
| #include "form/product_with_name.hpp" | ||
| #include "persistence/ipersistence_writer.hpp" | ||
|
|
||
| #include <map> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace form::experimental { | ||
|
|
||
| class form_writer_interface { | ||
| public: | ||
| form_writer_interface(config::output_item_config const& output_config, | ||
| config::tech_setting_config const& tech_config); | ||
| ~form_writer_interface() = default; | ||
|
|
||
| void write(std::string const& creator, | ||
| std::string const& segment_id, | ||
| product_with_name const& product); | ||
|
|
||
| void write(std::string const& creator, | ||
| std::string const& segment_id, | ||
| std::vector<product_with_name> const& products); | ||
|
|
||
| private: | ||
| std::unique_ptr<form::detail::experimental::IPersistenceWriter> m_pers; | ||
| std::map<std::string, form::experimental::config::PersistenceItem> m_product_to_config; | ||
| }; | ||
| } | ||
|
|
||
| #endif // FORM_FORM_FORM_WRITER_HPP |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will investigate. I agree that it shouldn't change. Thank you for catching this. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #ifndef FORM_FORM_PRODUCT_WITH_NAME_HPP | ||
| #define FORM_FORM_PRODUCT_WITH_NAME_HPP | ||
|
|
||
| #include <string> | ||
| #include <typeinfo> | ||
|
|
||
| namespace form::experimental { | ||
| struct product_with_name { | ||
| std::string label; | ||
| void const* data; | ||
| std::type_info const* type; | ||
| }; | ||
| } | ||
|
|
||
| #endif // FORM_FORM_PRODUCT_WITH_NAME_HPP |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # Copyright (C) 2025 ... | ||
|
|
||
| # Component(s) in the package: | ||
| add_library(persistence persistence.cpp) | ||
| add_library(persistence persistence_reader.cpp persistence_writer.cpp persistence_utils.cpp) | ||
| target_link_libraries(persistence core storage) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright (C) 2025 ... | ||
|
|
||
| #ifndef FORM_PERSISTENCE_IPERSISTENCE_READER_HPP | ||
| #define FORM_PERSISTENCE_IPERSISTENCE_READER_HPP | ||
|
|
||
| #include <map> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <typeinfo> | ||
|
|
||
| namespace form::experimental::config { | ||
| class output_item_config; | ||
| struct tech_setting_config; | ||
| } | ||
|
|
||
| namespace form::detail::experimental { | ||
|
|
||
| class IPersistenceReader { | ||
| public: | ||
| IPersistenceReader() {}; | ||
| virtual ~IPersistenceReader() = default; | ||
|
|
||
| virtual void configureTechSettings( | ||
| form::experimental::config::tech_setting_config const& tech_config_settings) = 0; | ||
|
|
||
| virtual void configureOutputItems( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, I expect that I can remove everything dealing with output config from the reader-flavor components. I'll report back if it doesn't work for some reason. |
||
| form::experimental::config::output_item_config const& outputItems) = 0; | ||
|
|
||
| virtual void read(std::string const& creator, | ||
| std::string const& label, | ||
| std::string const& id, | ||
| void const** data, | ||
| std::type_info const& type) = 0; | ||
| }; | ||
|
|
||
| std::unique_ptr<IPersistenceReader> createPersistenceReader(); | ||
|
|
||
| } // namespace form::detail::experimental | ||
|
|
||
| #endif // FORM_PERSISTENCE_IPERSISTENCE_READER_HPP | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest rename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
output_item_config->io_item_config?container_config? I think we're going to need it in both the reader and the writer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The location information on data to read should not depend on configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the (global) input file-names, a reading job does not need to tell FORM where and what objects are stored, FORM should find them. Whereas on output, configuration does determine which outputs are written where.