-
Notifications
You must be signed in to change notification settings - Fork 39
Add QueueManager (Juan Chavez's WAVES project) #414
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
Open
emilydolson
wants to merge
21
commits into
devosoft:master
Choose a base branch
from
emilydolson:queue-manage-clean
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c95f473
Add QueueManager
emilydolson 0f33550
Updates to queue manager
emilydolson 058ce80
Updated Spatial Coop demo to use QueueManager
emilydolson f19c10c
Cleanup and documentation
emilydolson e95018e
Add tests for QueueManager
emilydolson eb29b79
Fix name collision issue in SettingConfig
emilydolson d76edef
Merge branch 'master' into queue-manage-clean
emilydolson e221c99
Get test coverage for QueueManager
emilydolson a440e47
Fix bug where compiler was confused by has functions
emilydolson 404dff4
Improve queuemanager test coverage
emilydolson ba0e452
Test settingconfig
emilydolson eee7bcc
Fix include on map utils
emilydolson 02a27e7
Fix memory management error in copy constructor
emilydolson 47eb05b
Test fixing formatting
emilydolson ab22149
Actually fix whitespace
emilydolson 99ce788
Merging master to fix docs
emilydolson 239511d
another attempted formatting fix
emilydolson df03da2
maybe actually fix formatting
emilydolson f5e4091
final formatting fixes
emilydolson 1207299
final formatting fixes
emilydolson 32121ab
final formatting fixes
emilydolson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ namespace emp { | |
| virtual bool SetValueID(size_t) {return false; } ///< Setup cur value in linked variable | ||
| virtual bool IsComboSetting() { return false; } ///< Do we have a combo setting? | ||
| virtual size_t GetID() const { return (size_t) -1; } ///< Combination ID for this setting. | ||
| virtual emp::Ptr<SettingBase> Clone() const = 0; | ||
|
|
||
| bool IsOptionMatch(const std::string & test_option) const { return test_option == option; } | ||
| bool IsFlagMatch(const char test_flag) const { return test_flag == flag; } | ||
|
|
@@ -70,6 +71,18 @@ namespace emp { | |
| emp::Ptr<T> _var=nullptr) ///< Pointer to variable to set (optional) | ||
| : SettingBase(_name, _desc, _flag, _arg), var_ptr(_var) { } | ||
|
|
||
| ~SettingInfo(){if(var_ptr){var_ptr.Delete();}} | ||
|
|
||
| emp::Ptr<SettingBase> Clone() const override { | ||
emilydolson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| emp::Ptr<T> new_var_ptr = nullptr; | ||
| if (var_ptr) { | ||
| new_var_ptr = NewPtr<T>(*var_ptr); | ||
| } | ||
| emp::Ptr<SettingInfo<T>> setting_info_ptr = emp::NewPtr<SettingInfo<T>>(name, desc, flag, args_label, new_var_ptr); | ||
| setting_info_ptr->value = this->value; | ||
| return setting_info_ptr; | ||
| } | ||
|
|
||
| size_t GetSize() const override { return 1; } | ||
| std::string AsString() const override { return emp::to_string(value); } | ||
| std::string AsString(size_t id) const override { | ||
|
|
@@ -99,6 +112,19 @@ namespace emp { | |
| emp::Ptr<T> _var=nullptr) ///< Pointer to variable to set (optional) | ||
| : SettingBase(_name, _desc, _flag, _args), var_ptr(_var) { } | ||
|
|
||
| ~ComboSettingInfo(){if(var_ptr){var_ptr.Delete();}} | ||
|
|
||
| emp::Ptr<SettingBase> Clone() const override { | ||
| emp::Ptr<T> new_var_ptr = nullptr; | ||
| if (var_ptr) { | ||
| new_var_ptr = NewPtr<T>(*var_ptr); | ||
| } | ||
| auto csi_ptr = emp::NewPtr<ComboSettingInfo<T>>(name, desc, flag, args_label, new_var_ptr); | ||
| csi_ptr->values = this->values; | ||
| csi_ptr->id = this->id; | ||
| return csi_ptr; | ||
| } | ||
|
|
||
| size_t GetSize() const override { return values.size(); } | ||
| std::string AsString() const override { | ||
| std::stringstream ss; | ||
|
|
@@ -108,8 +134,11 @@ namespace emp { | |
| } | ||
| return ss.str(); | ||
| } | ||
|
|
||
| std::string AsString(size_t id) const override { | ||
| return emp::to_string(values[id]); | ||
| std::stringstream ss; | ||
| ss << values[id]; | ||
| return ss.str(); | ||
| } | ||
|
|
||
| bool FromString(const std::string_view & input) override { | ||
|
|
@@ -172,6 +201,23 @@ namespace emp { | |
| public: | ||
| SettingConfig() = default; | ||
|
|
||
| SettingConfig(const SettingConfig &other) { | ||
| combo_settings.resize(other.combo_settings.size()); | ||
| for (const auto &entry : other.setting_map) { | ||
| setting_map[entry.first] = other.setting_map.at(entry.first)->Clone(); | ||
| } | ||
| for (size_t i = 0; i < combo_settings.size(); i++) { | ||
| combo_settings[i] = setting_map[other.combo_settings[i]->name]; | ||
| } | ||
|
|
||
| action_map = other.action_map; | ||
| cur_combo = other.cur_combo; | ||
| combo_id = other.combo_id; | ||
| unused_args = other.unused_args; | ||
| errors = other.errors; | ||
| exe_name = other.exe_name; | ||
| } | ||
|
|
||
| ~SettingConfig() { | ||
| for (auto [name,ptr] : setting_map) ptr.Delete(); | ||
| } | ||
|
|
@@ -184,6 +230,24 @@ namespace emp { | |
| bool HasUnusedArgs() const { return unused_args.size(); } | ||
| bool HasErrors() const { return errors.size(); } | ||
|
|
||
| /// Retrieves all of the setting names in config and places into std::vector | ||
| std::vector<std::string> GetSettingMapNames() const { | ||
| std::vector<std::string> result; | ||
| for (const auto &p : setting_map) { | ||
| result.push_back(p.first); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| /// Retrieves all of the setting names in config and places into std::vector | ||
|
Member
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. don't think this docstring is quite right |
||
| std::vector<emp::Ptr<SettingBase>> GetSettingMapBase() const { | ||
| std::vector<emp::Ptr<SettingBase>> result; | ||
| for (const auto &p : setting_map) { | ||
| result.push_back(p.second); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| /// Get the current value of a specified setting. | ||
| template <typename T> | ||
| const T & GetValue(const std::string & name) const { | ||
|
|
@@ -235,6 +299,18 @@ namespace emp { | |
| return new_ptr->value; | ||
| } | ||
|
|
||
| /// Add a new setting not linked to a variable | ||
|
|
||
| template <typename T> | ||
| T &AddSetting(const std::string &name, | ||
| const std::string &desc = "", | ||
| const char option_flag = '\0') { | ||
| emp_assert(!emp::Has(setting_map, name)); | ||
| auto new_ptr = emp::NewPtr<SettingInfo<T>>(name, desc, option_flag, "Value"); | ||
| setting_map[name] = new_ptr; | ||
| return new_ptr->value; | ||
| } | ||
|
|
||
| /// Add a new setting of a specified type. Returns the (initially empty) vector of values | ||
| /// to allow easy setting. | ||
| /// Example: | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.