Line data Source code
1 1 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : /// \file 5 : /// Utilities to work with block names and groups 6 : 7 : #pragma once 8 : 9 : #include <string> 10 : #include <unordered_map> 11 : #include <unordered_set> 12 : #include <vector> 13 : 14 : namespace domain { 15 : 16 : /*! 17 : * \brief Check if a block is in the given group 18 : * 19 : * \param block_name The name of the block to check 20 : * \param block_or_group_name The group name we're testing. Returns true if 21 : * the block is in this group. This can also be the name of the block itself. 22 : * \param block_groups All block groups. 23 : */ 24 1 : bool block_is_in_group( 25 : const std::string& block_name, const std::string& block_or_group_name, 26 : const std::unordered_map<std::string, std::unordered_set<std::string>>& 27 : block_groups); 28 : 29 : /*! 30 : * \brief Expand a list of block or group names into a list of block names 31 : * 32 : * \param block_or_group_names Block or group names to expand 33 : * \param all_block_names All block names in the domain 34 : * \param block_groups Block groups used to expand the names 35 : * \return std::unordered_set<std::string> List of block names that appear in 36 : * \p all_block_names. If one of the input names was a group, then all block 37 : * names from that group are included. Overlaps between groups are allowed. 38 : */ 39 1 : std::unordered_set<std::string> expand_block_groups_to_block_names( 40 : const std::vector<std::string>& block_or_group_names, 41 : const std::vector<std::string>& all_block_names, 42 : const std::unordered_map<std::string, std::unordered_set<std::string>>& 43 : block_groups); 44 : 45 : } // namespace domain