MCPcopy Create free account
hub / github.com/MITK/MITK / ToolAlreadyRecorded

Function ToolAlreadyRecorded

Modules/Multilabel/src/mitkLabel.cpp:94–108  ·  view source on GitHub ↗

True if toolName is already one of the recorded tools in an algorithm_name. The encoding is "[ : ]tool1|tool2|...", so we strip the framework prefix (when present) and compare against the "|"-separated tool tokens for an exact match. A plain substring search would wrongly treat a name that is a substring of the prefix or of another tool (e.g. "Net" inside "nnUNet") as present.

Source from the content-addressed store, hash-verified

92 // the "|"-separated tool tokens for an exact match. A plain substring search would wrongly treat a
93 // name that is a substring of the prefix or of another tool (e.g. "Net" inside "nnUNet") as present.
94 bool ToolAlreadyRecorded(const std::string& algorithmName, const std::string& toolName)
95 {
96 if (algorithmName == DEFAULT_ALGORITHM_NAME) // bare prefix: no tool recorded yet
97 return false;
98
99 const std::string internalPrefix = DEFAULT_ALGORITHM_NAME + PREFIX_SEPARATOR;
100 const std::string toolChain = algorithmName.starts_with(internalPrefix)
101 ? algorithmName.substr(internalPrefix.size())
102 : algorithmName;
103
104 // Wrap both chain and needle in separators so the search only matches whole tokens (e.g. "Net"
105 // is not found inside "nnUNet"). Valid because AddToolUse rejects TOOL_SEPARATOR inside names.
106 return (TOOL_SEPARATOR + toolChain + TOOL_SEPARATOR)
107 .find(TOOL_SEPARATOR + toolName + TOOL_SEPARATOR) != std::string::npos;
108 }
109}
110
111mitk::Label::Label() : PropertyList(), m_Value(UNLABELED_VALUE)

Callers 1

AddToolUseMethod · 0.85

Calls 2

sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected