Skip to content

Commit

Permalink
Addressed code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbehne committed Aug 3, 2024
1 parent c8205c8 commit 8cfbdfb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 51 deletions.
59 changes: 43 additions & 16 deletions framework/include/utils/MultiMooseEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ class MultiMooseEnum : public MooseEnumBase
bool operator!=(const MultiMooseEnum & value) const;
///@}

///@{
/**
* Methods for seeing if a value is set in the MultiMooseEnum.
* @return bool - the truth value indicating whether the value is set
*/
bool contains(const std::string & value) const { return isValueSet(value); }
bool contains(int value) const { return isValueSet(value); }
bool contains(unsigned short value) const { return isValueSet(value); }
bool contains(const MultiMooseEnum & value) const { return isValueSet(value); }
bool contains(const MooseEnumItem & value) const { return isValueSet(value); }
///@}

// The following are aliases for contains with more descriptive name
///@{
/**
* Methods for seeing if a value is set in the MultiMooseEnum.
Expand All @@ -104,11 +117,6 @@ class MultiMooseEnum : public MooseEnumBase
bool isValueSet(unsigned short value) const;
bool isValueSet(const MultiMooseEnum & value) const;
bool isValueSet(const MooseEnumItem & value) const;
bool contains(const std::string & value) const;
bool contains(int value) const;
bool contains(unsigned short value) const;
bool contains(const MultiMooseEnum & value) const;
bool contains(const MooseEnumItem & value) const;
///@}

///@{
Expand All @@ -122,6 +130,17 @@ class MultiMooseEnum : public MooseEnumBase
MultiMooseEnum & operator=(const std::set<std::string> & names);
///@}

///@{
/**
* Un-assign, or unset a value. Deprecated, use eraseSetValue instead.
* @param names - a string, set, or vector giving the name to erase from the enumeration values
*/
void erase(const std::string & names);
void erase(const std::vector<std::string> & names);
void erase(const std::set<std::string> & names);
///@}

// The following replaces erase with a more descriptive name
///@{
/**
* Un-assign, or unset a value
Expand All @@ -130,11 +149,22 @@ class MultiMooseEnum : public MooseEnumBase
void eraseSetValue(const std::string & names);
void eraseSetValue(const std::vector<std::string> & names);
void eraseSetValue(const std::set<std::string> & names);
void erase(const std::string & names);
void erase(const std::vector<std::string> & names);
void erase(const std::set<std::string> & names);
///@}

///@{
/**
* Insert operators
* Operator to insert (push_back) values into the enum. Existing values are preserved and
* duplicates are stored. Deprecated, use setAdditionalValue instead.
* @param names - a string, set, or vector representing the enumeration values to set.
*/
void push_back(const std::string & names);
void push_back(const std::vector<std::string> & names);
void push_back(const std::set<std::string> & names);
void push_back(const MultiMooseEnum & other_enum);
///@}

// The following replaces push_back with a more descriptive name
///@{
/**
* Insert operators
Expand All @@ -146,10 +176,6 @@ class MultiMooseEnum : public MooseEnumBase
void setAdditionalValue(const std::vector<std::string> & names);
void setAdditionalValue(const std::set<std::string> & names);
void setAdditionalValue(const MultiMooseEnum & other_enum);
void push_back(const std::string & names);
void push_back(const std::vector<std::string> & names);
void push_back(const std::set<std::string> & names);
void push_back(const MultiMooseEnum & other_enum);
///@}

/**
Expand All @@ -169,13 +195,14 @@ class MultiMooseEnum : public MooseEnumBase
*/
unsigned int get(unsigned int i) const;

///@{
/// get the current values cast to a vector of enum type T. Deprecated, use getSetValueIDs instead.
template <typename T>
std::vector<T> getEnum() const;

// The following replaces getEnum with a more descriptive name
/// get the current values cast to a vector of enum type T
template <typename T>
std::vector<T> getSetValueIDs() const;
template <typename T>
std::vector<T> getEnum() const;
///@}

///@{
/**
Expand Down
35 changes: 0 additions & 35 deletions framework/src/utils/MultiMooseEnum.C
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ MultiMooseEnum::isValueSet(const std::string & value) const
{ return item == value; }) != _current_values.end();
}

bool
MultiMooseEnum::contains(const std::string & value) const
{
mooseDeprecated("MultiMooseEnum::contains is deprecated, use MultiMooseEnum::isValueSet");
return isValueSet(value);
}

bool
MultiMooseEnum::isValueSet(int value) const
{
Expand All @@ -97,13 +90,6 @@ MultiMooseEnum::isValueSet(int value) const
{ return item == value; }) != _current_values.end();
}

bool
MultiMooseEnum::contains(int value) const
{
mooseDeprecated("MultiMooseEnum::contains is deprecated, use MultiMooseEnum::isValueSet");
return isValueSet(value);
}

bool
MultiMooseEnum::isValueSet(unsigned short value) const
{
Expand All @@ -113,13 +99,6 @@ MultiMooseEnum::isValueSet(unsigned short value) const
{ return item == value; }) != _current_values.end();
}

bool
MultiMooseEnum::contains(unsigned short value) const
{
mooseDeprecated("MultiMooseEnum::contains is deprecated, use MultiMooseEnum::isValueSet");
return isValueSet(value);
}

bool
MultiMooseEnum::isValueSet(const MultiMooseEnum & value) const
{
Expand All @@ -129,13 +108,6 @@ MultiMooseEnum::isValueSet(const MultiMooseEnum & value) const
return true;
}

bool
MultiMooseEnum::contains(const MultiMooseEnum & value) const
{
mooseDeprecated("MultiMooseEnum::contains is deprecated, use MultiMooseEnum::isValueSet");
return isValueSet(value);
}

bool
MultiMooseEnum::isValueSet(const MooseEnumItem & value) const
{
Expand All @@ -145,13 +117,6 @@ MultiMooseEnum::isValueSet(const MooseEnumItem & value) const
{ return item == value; }) != _current_values.end();
}

bool
MultiMooseEnum::contains(const MooseEnumItem & value) const
{
mooseDeprecated("MultiMooseEnum::contains is deprecated, use MultiMooseEnum::isValueSet");
return isValueSet(value);
}

MultiMooseEnum &
MultiMooseEnum::operator=(const std::string & names)
{
Expand Down

0 comments on commit 8cfbdfb

Please sign in to comment.