19#include <unordered_map>
34 using ErrorHandler = std::function<void(
const std::ostringstream &)>;
39 static constexpr unsigned INVALID_ID = std::numeric_limits<unsigned>::max();
45 std::vector<DataType>
data{};
58 EntityGroup(
const std::string &type,
const std::string &namePrefix,
59 const std::vector<std::string> &invalidNamePrefixes)
70 GroupData *
add_group_data(
const std::string &name,
const std::vector<DataType> &data)
73 groupData.data = data;
78 groupData.name = name;
79 groupData.hasInputName =
true;
94 std::ostringstream errmsg;
95 errmsg <<
"Error populating " <<
m_type <<
" map";
136 unsigned nextPartId = 1;
144 if (!groupData.has_name()) {
145 std::ostringstream errmsg;
146 errmsg <<
m_type <<
" has no name";
150 if (!groupData.has_valid_id()) {
151 std::ostringstream errmsg;
152 errmsg <<
m_type <<
" named " << groupData.name <<
" has invalid id";
157 std::ostringstream errmsg;
158 errmsg <<
"Multiple declarations of " <<
m_type <<
": " << groupData.name;
171 m_ids[groupData.name] = groupData.id;
172 m_parts[groupData.id] = groupData.name;
180 if (groupData.has_name()) {
181 std::pair<unsigned, bool> result =
185 groupData.id = result.first;
196 if (!groupData.has_name()) {
199 std::ostringstream oss;
202 std::string name = oss.str();
205 groupData.name = name;
215 if (groupData.has_name()) {
216 std::pair<unsigned, bool> result =
219 if (!result.second) {
232 const unsigned prefixLength = invalidPrefix.length();
233 const std::string namePrefix = name.substr(0, prefixLength);
235 if (strcasecmp(namePrefix.c_str(), invalidPrefix.c_str()) == 0) {
236 std::ostringstream errmsg;
237 errmsg <<
"Invalid name '" << name <<
"' for a " <<
m_type <<
" part";
244 mutable std::unordered_map<std::string, unsigned>
m_ids;
245 mutable std::unordered_map<unsigned, std::string>
m_parts;
Definition Iotm_TextMeshEntityGroup.h:53
void verify_name(const std::string &name)
Definition Iotm_TextMeshEntityGroup.h:229
std::vector< GroupData > m_groupDataVec
Definition Iotm_TextMeshEntityGroup.h:252
const std::string & get_group_type() const
Definition Iotm_TextMeshEntityGroup.h:107
const std::vector< std::string > & get_part_names() const
Definition Iotm_TextMeshEntityGroup.h:105
void assign_id_for_non_default_exodus_name()
Definition Iotm_TextMeshEntityGroup.h:211
const GroupData * get_group_data(std::string name) const
Definition Iotm_TextMeshEntityGroup.h:119
unsigned get_unassigned_id() const
Definition Iotm_TextMeshEntityGroup.h:134
std::vector< std::string > m_invalidPrefixes
Definition Iotm_TextMeshEntityGroup.h:251
typename GroupData::DataType DataType
Definition Iotm_TextMeshEntityGroup.h:55
std::unordered_map< unsigned, std::string > m_parts
Definition Iotm_TextMeshEntityGroup.h:245
void finalize_parse()
Definition Iotm_TextMeshEntityGroup.h:87
void assign_id_from_default_exodus_name()
Definition Iotm_TextMeshEntityGroup.h:176
void validate_group_meta_data(const GroupData &groupData)
Definition Iotm_TextMeshEntityGroup.h:142
void assign(size_t index)
Definition Iotm_TextMeshEntityGroup.h:163
std::unordered_map< std::string, size_t > m_groupDataMap
Definition Iotm_TextMeshEntityGroup.h:247
ErrorHandler m_errorHandler
Definition Iotm_TextMeshEntityGroup.h:254
const GroupData * get_group_data(unsigned id) const
Definition Iotm_TextMeshEntityGroup.h:109
std::vector< std::string > m_partNames
Definition Iotm_TextMeshEntityGroup.h:243
bool is_assigned(unsigned id) const
Definition Iotm_TextMeshEntityGroup.h:227
virtual ~EntityGroup()
Definition Iotm_TextMeshEntityGroup.h:66
GroupData * add_group_data(const std::string &name, const std::vector< DataType > &data)
Definition Iotm_TextMeshEntityGroup.h:70
virtual void set_error_handler(ErrorHandler errorHandler)
Definition Iotm_TextMeshEntityGroup.h:68
bool m_idsAssigned
Definition Iotm_TextMeshEntityGroup.h:246
bool is_registered(const std::string &name) const
Definition Iotm_TextMeshEntityGroup.h:129
std::string m_type
Definition Iotm_TextMeshEntityGroup.h:249
const std::vector< GroupData > & get_group_data() const
Definition Iotm_TextMeshEntityGroup.h:103
size_t size() const
Definition Iotm_TextMeshEntityGroup.h:101
std::unordered_map< std::string, unsigned > m_ids
Definition Iotm_TextMeshEntityGroup.h:244
std::string m_exodusPrefix
Definition Iotm_TextMeshEntityGroup.h:250
void assign_id_and_name_for_empty_name()
Definition Iotm_TextMeshEntityGroup.h:192
EntityGroup(const std::string &type, const std::string &namePrefix, const std::vector< std::string > &invalidNamePrefixes)
Definition Iotm_TextMeshEntityGroup.h:58
void convert_to_upper_case(std::string &str)
Definition Iotm_TextMeshFuncs.h:88
std::function< void(const std::ostringstream &)> ErrorHandler
Definition Iotm_TextMeshAdjacencyGraph.h:35
void default_error_handler(const std::ostringstream &message)
Definition Iotm_TextMeshFuncs.h:32
std::pair< unsigned, bool > get_id_from_part_name(const std::string &name, const std::string &prefix)
Definition Iotm_TextMeshFuncs.h:118
A namespace for the textmesh database format.
Definition Iotm_DatabaseIO.C:95
Definition Iotm_TextMeshEntityGroup.h:37
T DataType
Definition Iotm_TextMeshEntityGroup.h:38
bool hasInputName
Definition Iotm_TextMeshEntityGroup.h:41
std::string name
Definition Iotm_TextMeshEntityGroup.h:43
static constexpr unsigned INVALID_ID
Definition Iotm_TextMeshEntityGroup.h:39
std::string type
Definition Iotm_TextMeshEntityGroup.h:44
std::vector< DataType > data
Definition Iotm_TextMeshEntityGroup.h:45
bool has_valid_id() const
Definition Iotm_TextMeshEntityGroup.h:47
bool has_name() const
Definition Iotm_TextMeshEntityGroup.h:48