46 #include <Xyce_config.h>
55 #include <N_ERH_Message.h>
56 #include <N_UTL_Demangle.h>
64 typedef std::map<EntityTypeId, Configuration *> EntityTypeIdConfigurationMap;
66 typedef unordered_map<std::string, EntityTypeId, HashNoCase, EqualNoCase> NameEntityTypeIdMap;
67 typedef unordered_map<NameLevelKey, EntityTypeId> NameLevelKeyEntityTypeIdMap;
101 std::vector<Configuration *> c;
102 for (ConfigurationMap::const_iterator it = configurationMap_.begin(); it != configurationMap_.end(); ++it)
103 c.push_back((*it).second);
104 std::sort(c.begin(), c.end());
105 c.erase(std::unique(c.begin(), c.end()), c.end());
106 for (std::vector<Configuration *>::iterator it = c.begin(); it != c.end(); ++it)
142 return getData().configurationMap_;
157 EntityTypeIdConfigurationMap::const_iterator it = getData().modelTypeConfigurationMap_.find(model_type_id);
158 return it == getData().modelTypeConfigurationMap_.end() ? 0 : (*it).second;
171 const std::string & device_name,
174 ConfigurationMap::const_iterator it = getData().configurationMap_.find(ConfigurationMap::key_type(device_name, level));
175 return it == getData().configurationMap_.end() ? 0 : (*it).second;
204 NameLevelKeyEntityTypeIdMap::const_iterator it = getData().modelTypeNameLevelModelTypeMap_.find(NameLevelKey(model_type_name, level));
222 NameEntityTypeIdMap::const_iterator it = getData().modelTypeNameModelGroupMap_.find(device_name);
239 const char * model_name,
240 const int model_level,
243 int model_type_nodes,
244 int model_group_nodes)
246 if (model_type_id == model_group_id) {
247 std::pair<NameEntityTypeIdMap::iterator, bool> result = getData().modelTypeNameModelGroupMap_.insert(NameEntityTypeIdMap::value_type(model_name, model_type_id));
248 if (!result.second && (*result.first).second != model_type_id)
249 Report::DevelFatal0().in(
"Configuration::addDevice")
250 <<
"Attempt to register more than one device model group to the name " << model_name;
253 if (model_type_nodes < model_group_nodes) {
262 std::pair<ConfigurationMap::iterator, bool> result
263 = getData().configurationMap_.insert(ConfigurationMap::value_type(NameLevelKey(model_name, model_level),
this));
265 Report::DevelFatal0().in(
"Configuration::addDevice")
266 <<
"Device with name " << model_name <<
" level " << model_level
267 <<
" already registered as " << (*result.first).second->getName();
271 std::pair<EntityTypeIdConfigurationMap::iterator, bool> result
272 = getData().modelTypeConfigurationMap_.insert(EntityTypeIdConfigurationMap::value_type(model_type_id,
this));
273 if (!result.second && (*result.first).second !=
this)
274 Report::DevelFatal().in(
"Configuration::addDevice")
275 <<
"Model " << demangle(model_type_id.type().name()) <<
" already registered to device " << (*result.first).second->getName()
276 <<
" while trying to register with device " << model_name <<
" level " << model_level;
291 const char * model_name,
296 if (model_type_id == model_group_id) {
297 std::pair<NameEntityTypeIdMap::iterator, bool> result = getData().modelTypeNameModelGroupMap_.insert(NameEntityTypeIdMap::value_type(model_name, model_type_id));
298 if (!result.second && (*result.first).second != model_type_id)
299 Report::DevelFatal0().in(
"Configuration::addDevice")
300 <<
"Attempt to register more than one device model group to the name " << model_name;
303 std::pair<NameLevelKeyEntityTypeIdMap::iterator, bool> result
304 = getData().modelTypeNameLevelModelTypeMap_.insert(NameLevelKeyEntityTypeIdMap::value_type(NameLevelKey(model_name, level), model_type_id));
305 if (!result.second && (*result.first).second != model_type_id)
306 Report::DevelFatal0() <<
"Attempt to register more than one model type to the device " << model_name <<
" level " << level;
NameLevelKeyEntityTypeIdMap modelTypeNameLevelModelTypeMap_
Model registration: Maps (name, level) -> model_type_id.
NameEntityTypeIdMap modelTypeNameModelGroupMap_
Model registration: Maps model_group_name -> model_group_id.
void addDevice(const char *model_name, const int model_level, ModelTypeId model_type_id, ModelTypeId model_group_id, int model_type_nodes, int model_group_nodes)
Adds the device to the configuration.
Pure virtual class to augment a linear system.
Device * createDevice(const FactoryBlock &factory_block) const
Creates the specified device.
static const Configuration * findConfiguration(ModelTypeId model_type_id)
Returns the configuration associated with the device name and level or 0 if not found.
EntityTypeIdConfigurationMap modelTypeConfigurationMap_
Device registration: Maps model_type_id -> configuration.
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual Device * factory(const FactoryBlock &factory_block) const =0
Overriding function creates an instance this device.
static ModelTypeId getModelGroup(const std::string &device_name)
Returns the model group of the device name.
The Device class is an interface for device implementations.
std::vector< std::string > modelTypeNames_
Vector of defined model type of this device's model.
Class Configuration contains device configuration data.
static const ConfigurationMap & getConfigurationMap()
Returns the configuration map of the system.
unordered_map< NameLevelKey, Configuration * > ConfigurationMap
static ModelTypeId getModelType(const std::string &model_name, const int level)
Returns the model type identifier for the specified device, if the model type and level is not found...
void addModel(const char *model_name, const int level, ModelTypeId model_type_id, ModelTypeId model_group_id)
Adds a model name for the device to the configuration.
ConfigurationMap configurationMap_
Device registration: Maps (name, level) -> configuration.