Commit 4c37eeaa authored by Mathieu Westphal's avatar Mathieu Westphal

Adding a alwaysAppend boolean to GetUniqueProxyName

parent 9beba2ad
......@@ -578,7 +578,8 @@ std::string vtkSMSessionProxyManager::RegisterProxy(const char* groupname, vtkSM
}
//---------------------------------------------------------------------------
std::string vtkSMSessionProxyManager::GetUniqueProxyName(const char* groupname, const char* prefix)
std::string vtkSMSessionProxyManager::GetUniqueProxyName(
const char* groupname, const char* prefix, bool alwaysAppend)
{
if (!groupname || !prefix)
{
......@@ -589,9 +590,13 @@ std::string vtkSMSessionProxyManager::GetUniqueProxyName(const char* groupname,
this->Internals->RegisteredProxyMap.find(groupname);
if (it == this->Internals->RegisteredProxyMap.end())
{
int suffix = 1;
std::ostringstream name_stream;
name_stream << prefix << suffix;
name_stream << prefix;
if (alwaysAppend)
{
int suffix = 1;
name_stream << suffix;
}
return name_stream.str();
}
......@@ -603,6 +608,14 @@ std::string vtkSMSessionProxyManager::GetUniqueProxyName(const char* groupname,
existingNames.insert(it2->first);
}
if (!alwaysAppend)
{
if (existingNames.find(prefix) == existingNames.end())
{
return prefix;
}
}
for (int suffix = 1; suffix < VTK_INT_MAX; ++suffix)
{
std::ostringstream name_stream;
......
......@@ -271,8 +271,11 @@ public:
/**
* Given a group, returns a name not already used for proxies registered in
* the given group. The prefix is used to come up with a new name.
* if alwaysAppend is true, then a suffix will always be appended, if not,
* the prefix may be used directly if possible.
*/
std::string GetUniqueProxyName(const char* groupname, const char* prefix);
std::string GetUniqueProxyName(
const char* groupname, const char* prefix, bool alwaysAppend = true);
/**
* If the proxy is in the given group, return its name, otherwise
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment