msg += " Existing netpoints: \n";
std::vector<simgrid::kernel::routing::NetPoint*> list;
- simgrid::s4u::Engine::instance()->netpointList(&list);
+ simgrid::s4u::Engine::getInstance()->getNetpointList(&list);
std::sort(list.begin(), list.end(),
[](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
return a->name() < b->name();
/* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
/* The default current property receiver. Setup in the corresponding opening callbacks. */
-xbt_dict_t current_property_set = nullptr;
+std::map<std::string, std::string>* current_property_set = nullptr;
std::map<std::string, std::string>* current_model_property_set = nullptr;
int ZONE_TAG = 0; // Whether we just opened a zone tag (to see what to do with the properties)
YY_BUFFER_STATE surf_input_buffer;
FILE *surf_file_to_parse = nullptr;
-/*
- * Stuff relative to storage
- */
+/* Stuff relative to storage */
void STag_surfxml_storage()
{
ZONE_TAG = 0;
XBT_DEBUG("STag_surfxml_storage");
xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
}
+
void ETag_surfxml_storage()
{
- s_sg_platf_storage_cbarg_t storage;
- memset(&storage,0,sizeof(storage));
+ StorageCreationArgs storage;
storage.properties = current_property_set;
current_property_set = nullptr;
storage.id = A_surfxml_storage_id;
storage.type_id = A_surfxml_storage_typeId;
storage.content = A_surfxml_storage_content;
-
storage.attach = A_surfxml_storage_attach;
+
sg_platf_new_storage(&storage);
}
void STag_surfxml_storage___type()
}
void ETag_surfxml_storage___type()
{
- s_sg_platf_storage_type_cbarg_t storage_type;
- memset(&storage_type,0,sizeof(storage_type));
+ StorageTypeCreationArgs storage_type;
storage_type.properties = current_property_set;
current_property_set = nullptr;
storage_type.model_properties = current_model_property_set;
current_model_property_set = nullptr;
- storage_type.content = A_surfxml_storage___type_content;
- storage_type.id = A_surfxml_storage___type_id;
- storage_type.model = A_surfxml_storage___type_model;
- storage_type.size = surf_parse_get_size(A_surfxml_storage___type_size,
- "size of storage type", storage_type.id);
+ storage_type.content = A_surfxml_storage___type_content;
+ storage_type.id = A_surfxml_storage___type_id;
+ storage_type.model = A_surfxml_storage___type_model;
+ storage_type.size =
+ surf_parse_get_size(A_surfxml_storage___type_size, "size of storage type", storage_type.id.c_str());
sg_platf_new_storage_type(&storage_type);
}
+
void STag_surfxml_mount()
{
XBT_DEBUG("STag_surfxml_mount");
}
+
void ETag_surfxml_mount()
{
- s_sg_platf_mount_cbarg_t mount;
- memset(&mount,0,sizeof(mount));
+ MountCreationArgs mount;
mount.name = A_surfxml_mount_name;
mount.storageId = A_surfxml_mount_storageId;
{
if (ZONE_TAG) { // We need to retrieve the most recently opened zone
XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
- simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::instance()->netzoneByNameOrNull(A_surfxml_zone_id);
+ simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::getInstance()->getNetzoneByNameOrNull(A_surfxml_zone_id);
netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
- }
- else{
+ } else {
if (not current_property_set)
- current_property_set = xbt_dict_new_homogeneous(&xbt_free_f); // Maybe, it should raise an error
- xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr);
+ current_property_set = new std::map<std::string, std::string>; // Maybe, it should raise an error
+ current_property_set->insert({A_surfxml_prop_id, A_surfxml_prop_value});
XBT_DEBUG("add prop %s=%s into current property set %p", A_surfxml_prop_id, A_surfxml_prop_value,
current_property_set);
}
void STag_surfxml_peer(){
parse_after_config();
- s_sg_platf_peer_cbarg_t peer;
- memset(&peer,0,sizeof(peer));
- peer.id = A_surfxml_peer_id;
- peer.speed = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id);
- peer.bw_in = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id);
- peer.bw_out = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id);
+ PeerCreationArgs peer;
+
+ peer.id = std::string(A_surfxml_peer_id);
+ peer.speed = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id.c_str());
+ peer.bw_in = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id.c_str());
+ peer.bw_out = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id.c_str());
peer.coord = A_surfxml_peer_coordinates;
peer.speed_trace = A_surfxml_peer_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_availability___file) : nullptr;
peer.state_trace = A_surfxml_peer_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_state___file) : nullptr;
void ETag_surfxml_config()
{
- xbt_dict_cursor_t cursor = nullptr;
- char *key;
- char *elem;
- xbt_dict_foreach(current_property_set, cursor, key, elem) {
- if (xbt_cfg_is_default_value(key)) {
- std::string cfg = std::string(key) + ":" + elem;
+ for (auto elm : *current_property_set) {
+ if (xbt_cfg_is_default_value(elm.first.c_str())) {
+ std::string cfg = elm.first + ":" + elm.second;
xbt_cfg_set_parse(cfg.c_str());
} else
- XBT_INFO("The custom configuration '%s' is already defined by user!",key);
+ XBT_INFO("The custom configuration '%s' is already defined by user!", elm.first.c_str());
}
XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
- xbt_dict_free(¤t_property_set);
+ delete current_property_set;
current_property_set = nullptr;
}
xbt_free(dir);
surf_file_to_parse = surf_fopen(file, "r");
- xbt_assert(surf_file_to_parse != nullptr, "Unable to open '%s'\n", file);
+ if (surf_file_to_parse == nullptr)
+ xbt_die("Unable to open '%s'\n", file);
surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
surf_parse__switch_to_buffer(surf_input_buffer);
surf_parse_lineno = 1;
}
}
-/* Call the lexer to parse the currently opened file. This pointer to function enables bypassing of the parser */
-static int _surf_parse() {
+/* Call the lexer to parse the currently opened file */
+int surf_parse()
+{
return surf_parse_lex();
}
-int_f_void_t surf_parse = &_surf_parse;
-
SG_END_DECL()