Skip to content
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

No Singleton: Configuration #2541

Merged
merged 3 commits into from
Jun 15, 2023
Merged

Conversation

Klaim
Copy link
Member

@Klaim Klaim commented May 23, 2023

No description provided.

@Klaim Klaim force-pushed the klaim/context-not-singleton branch 3 times, most recently from 7b7586a to f4c11fd Compare May 25, 2023 13:58
@Klaim Klaim force-pushed the klaim/context-not-singleton branch 2 times, most recently from 2b34389 to 227e61d Compare June 6, 2023 16:40
@Klaim Klaim force-pushed the klaim/context-not-singleton branch 2 times, most recently from 03b57cd to a74fc0b Compare June 8, 2023 06:51
@Klaim Klaim marked this pull request as ready for review June 8, 2023 07:46
Copy link
Member

@AntoinePrv AntoinePrv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a few questions

std::string m_name;
std::string m_group = "Default";
std::string m_description = "No description provided";
std::string m_long_description = "";
Configuration* m_config = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the mechanism here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See:

My understanding of the original code is that Configurables in a Configuration can be manipulated before Configuration::load() is done and in that case Configurable::value() can throw an exception if called before Configuration::load(). This is not ideal but I didnt want to change the logic and Configurable was accessing Configuration through the singleton accessor, so removing it lead to Configurable needing to be able to check that the Configuration is or not in the loading phase. The only way I found was adding the pointer to the Configuration once the Configurable is stored in the Configuration (because it could be created before that point).
When we rewrite Configuration itself to be as discussed last live meeting (real fields, no magically casting dynamic fields), this issue can be completely removed by having 2 types of configurations: one that is being set and one "locked".

@@ -149,10 +137,13 @@ namespace mamba
virtual YAML::Node yaml_value() const = 0;
virtual void dump_json(nlohmann::json& node, const std::string& name) const = 0;

bool is_config_loading() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does that do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my last comment.

@Klaim Klaim mentioned this pull request Jun 9, 2023
@@ -54,9 +56,9 @@ namespace mamba

void create_empty_target(const fs::u8path& prefix);

void file_specs_hook(std::vector<std::string>& file_specs);
void file_specs_hook(std::vector<std::string>& file_specs, Configuration& config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: config should be the first argument to be consistent with other functions in this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes nice catch, will fix

@Klaim Klaim force-pushed the klaim/context-not-singleton branch 2 times, most recently from 7dc940b to 2c5c753 Compare June 13, 2023 08:55
@Klaim Klaim force-pushed the klaim/context-not-singleton branch from 2c5c753 to 7df49ef Compare June 14, 2023 16:39
@Klaim Klaim merged commit ec95d18 into mamba-org:main Jun 15, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants