Skip to content

Commit

Permalink
hack to improve "Output Module Inserter" (plugin names with ::)
Browse files Browse the repository at this point in the history
  • Loading branch information
missirol authored and mmusich committed Mar 11, 2024
1 parent fca2e86 commit 7ec9e46
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/confdb/gui/ConfigurationTreeActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public static boolean insertESSource(JTree tree, String templateName) {
ConfigurationTreeModel model = (ConfigurationTreeModel) tree.getModel();
Configuration config = (Configuration) model.getRoot();

if (templateName.indexOf(':') >= 0) {
if (templateName.indexOf(":") >= 0) {
String[] s = templateName.split(":");
Template template = config.release().essourceTemplate(s[1]);
Instance original = null;
Expand Down Expand Up @@ -326,7 +326,7 @@ public static boolean insertESModule(JTree tree, String templateName) {
ConfigurationTreeModel model = (ConfigurationTreeModel) tree.getModel();
Configuration config = (Configuration) model.getRoot();

if (templateName.indexOf(':') > 0) {
if (templateName.indexOf(":") > 0) {
String[] s = templateName.split(":");
Template template = config.release().esmoduleTemplate(s[1]);
Instance original = null;
Expand Down Expand Up @@ -2011,8 +2011,7 @@ private static Configuration getConfigurationCopy(Configuration sourceConf) {
index = 0;
while (ESMit.hasNext()) {
ESModuleInstance esmodule = ESMit.next();
ESModuleInstance NewModule = configurationCopy.insertESModule(index, esmodule.template().name(),
esmodule.name());
ESModuleInstance NewModule = configurationCopy.insertESModule(index, esmodule.template().name(), esmodule.name());
index++;
Iterator<Parameter> itP = esmodule.parameterIterator();
while (itP.hasNext()) {
Expand Down Expand Up @@ -3068,7 +3067,19 @@ public static boolean insertReference(JTree tree, String type, String name) {
return false;
reference = config.insertOutputModuleReference(parent, index, referencedOutput);
} else if (type.equalsIgnoreCase("Module")) {
String[] s = name.split(":");
// The "unlikely string" hack.
// Here, the variable "name" can presumably take values of the form
// "pluginType", "pluginType:moduleLabel", or "copy:pluginType:moduleLabel".
// Unfortunately, this convention does not take into account the fact that
// pluginType itself can contain the substring "::" (e.g. plugin types with namespace specification,
// like Alpaka plugins with explicit backend selection).
// The hack below consists in replacing "::" in "name" with "##", before "name" is split by ":".
// After that, the replacement of "::" with this unlikely string is undone in "templateName".
// NOTE.
// This hack assumes that plugin types in CMSSW will never
// have "##" in their name, since that would be invalid in C++.
String unlikelyStr = "##";
String[] s = name.replaceAll("::", unlikelyStr).split(":");
String templateName = "";
String instanceName = "";
boolean copy = false;
Expand All @@ -3083,7 +3094,9 @@ public static boolean insertReference(JTree tree, String type, String name) {
templateName = s[1];
instanceName = s[2];
}


templateName = templateName.replaceAll(unlikelyStr, "::");

ModuleTemplate template = config.release().moduleTemplate(templateName);

if (!copy) {
Expand Down

0 comments on commit 7ec9e46

Please sign in to comment.