summaryrefslogtreecommitdiff
path: root/indra/llui/llfloaterreg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llfloaterreg.cpp')
-rw-r--r--indra/llui/llfloaterreg.cpp165
1 files changed, 91 insertions, 74 deletions
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index fd5a370bc3..a818e72f59 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -40,9 +40,9 @@
LLFloaterReg::instance_list_t LLFloaterReg::sNullInstanceList;
LLFloaterReg::instance_map_t LLFloaterReg::sInstanceMap;
LLFloaterReg::build_map_t LLFloaterReg::sBuildMap;
-std::map<std::string,std::string> LLFloaterReg::sGroupMap;
+std::map<std::string, std::string, std::less<>> LLFloaterReg::sGroupMap;
bool LLFloaterReg::sBlockShowFloaters = false;
-std::set<std::string> LLFloaterReg::sAlwaysShowableList;
+std::set<std::string, std::less<>> LLFloaterReg::sAlwaysShowableList;
static LLFloaterRegListener sFloaterRegListener;
@@ -58,27 +58,31 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con
}
//static
-bool LLFloaterReg::isRegistered(const std::string& name)
+bool LLFloaterReg::isRegistered(std::string_view name)
{
return sBuildMap.find(name) != sBuildMap.end();
}
//static
-LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name)
+LLFloater* LLFloaterReg::getLastFloaterInGroup(std::string_view name)
{
- const std::string& groupname = sGroupMap[name];
- if (!groupname.empty())
+ auto it = sGroupMap.find(name);
+ if (it != sGroupMap.end())
{
- instance_list_t& list = sInstanceMap[groupname];
- if (!list.empty())
+ const std::string& groupname = it->second;
+ if (!groupname.empty())
{
- for (instance_list_t::reverse_iterator iter = list.rbegin(); iter != list.rend(); ++iter)
+ instance_list_t& list = sInstanceMap[groupname];
+ if (!list.empty())
{
- LLFloater* inst = *iter;
-
- if (inst->getVisible() && !inst->isMinimized())
+ for (instance_list_t::reverse_iterator iter = list.rbegin(), end = list.rend(); iter != end; ++iter)
{
- return inst;
+ LLFloater* inst = *iter;
+
+ if (inst->getVisible() && !inst->isMinimized())
+ {
+ return inst;
+ }
}
}
}
@@ -99,10 +103,8 @@ LLFloater* LLFloaterReg::getLastFloaterCascading()
instance_list_t& instances = sInstanceMap[group_name];
- for (instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); ++iter)
+ for (LLFloater* inst : instances)
{
- LLFloater* inst = *iter;
-
if (inst->getVisible()
&& (inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADING)
|| inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADE_GROUP)))
@@ -120,20 +122,23 @@ LLFloater* LLFloaterReg::getLastFloaterCascading()
}
//static
-LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key)
+LLFloater* LLFloaterReg::findInstance(std::string_view name, const LLSD& key)
{
LLFloater* res = NULL;
- const std::string& groupname = sGroupMap[name];
- if (!groupname.empty())
+ auto it = sGroupMap.find(name);
+ if (it != sGroupMap.end())
{
- instance_list_t& list = sInstanceMap[groupname];
- for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter)
+ const std::string& groupname = it->second;
+ if (!groupname.empty())
{
- LLFloater* inst = *iter;
- if (inst->matchesKey(key))
+ instance_list_t& list = sInstanceMap[groupname];
+ for (LLFloater* inst : list)
{
- res = inst;
- break;
+ if (inst->matchesKey(key))
+ {
+ res = inst;
+ break;
+ }
}
}
}
@@ -141,47 +146,55 @@ LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key)
}
//static
-LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
+LLFloater* LLFloaterReg::getInstance(std::string_view name, const LLSD& key)
{
LLFloater* res = findInstance(name, key);
if (!res)
{
- const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc;
- const std::string& xui_file = sBuildMap[name].mFile;
- if (build_func)
+ auto it = sBuildMap.find(name);
+ if (it != sBuildMap.end())
{
- const std::string& groupname = sGroupMap[name];
- if (!groupname.empty())
+ const LLFloaterBuildFunc& build_func = it->second.mFunc;
+ const std::string& xui_file = it->second.mFile;
+ if (build_func)
{
- instance_list_t& list = sInstanceMap[groupname];
-
- res = build_func(key);
- if (!res)
- {
- LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
- return NULL;
- }
- bool success = res->buildFromFile(xui_file);
- if (!success)
+ auto it = sGroupMap.find(name);
+ if (it != sGroupMap.end())
{
- LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
- return NULL;
+ const std::string& groupname = it->second;
+ if (!groupname.empty())
+ {
+ instance_list_t& list = sInstanceMap[groupname];
+
+ res = build_func(key);
+ if (!res)
+ {
+ LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
+ return NULL;
+ }
+ bool success = res->buildFromFile(xui_file);
+ if (!success)
+ {
+ LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
+ return NULL;
+ }
+
+ // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
+ if (res->mKey.isUndefined())
+ {
+ res->mKey = key;
+ }
+ res->setInstanceName(std::string(name));
+
+ LLFloater* last_floater = (list.empty() ? NULL : list.back());
+
+ res->applyControlsAndPosition(last_floater);
+
+ gFloaterView->adjustToFitScreen(res, false);
+
+ list.push_back(res);
+ }
}
-
- // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
- if (res->mKey.isUndefined())
- {
- res->mKey = key;
- }
- res->setInstanceName(name);
-
- LLFloater *last_floater = (list.empty() ? NULL : list.back());
-
- res->applyControlsAndPosition(last_floater);
-
- gFloaterView->adjustToFitScreen(res, false);
-
- list.push_back(res);
}
}
if (!res)
@@ -193,21 +206,25 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
}
//static
-LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key)
+LLFloater* LLFloaterReg::removeInstance(std::string_view name, const LLSD& key)
{
LLFloater* res = NULL;
- const std::string& groupname = sGroupMap[name];
- if (!groupname.empty())
+ auto it = sGroupMap.find(name);
+ if (it != sGroupMap.end())
{
- instance_list_t& list = sInstanceMap[groupname];
- for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter)
+ const std::string& groupname = it->second;
+ if (!groupname.empty())
{
- LLFloater* inst = *iter;
- if (inst->matchesKey(key))
+ instance_list_t& list = sInstanceMap[groupname];
+ for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter)
{
- res = inst;
- list.erase(iter);
- break;
+ LLFloater* inst = *iter;
+ if (inst->matchesKey(key))
+ {
+ res = inst;
+ list.erase(iter);
+ break;
+ }
}
}
}
@@ -216,7 +233,7 @@ LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key
//static
// returns true if the instance existed
-bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key)
+bool LLFloaterReg::destroyInstance(std::string_view name, const LLSD& key)
{
LLFloater* inst = removeInstance(name, key);
if (inst)
@@ -232,7 +249,7 @@ bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key)
// Iterators
//static
-LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::string& name)
+LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(std::string_view name)
{
instance_map_t::iterator iter = sInstanceMap.find(name);
if (iter != sInstanceMap.end())
@@ -248,7 +265,7 @@ LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::str
// Visibility Management
//static
-LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, bool focus)
+LLFloater* LLFloaterReg::showInstance(std::string_view name, const LLSD& key, bool focus)
{
if( sBlockShowFloaters
// see EXT-7090
@@ -266,7 +283,7 @@ LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key,
//static
// returns true if the instance exists
-bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key)
+bool LLFloaterReg::hideInstance(std::string_view name, const LLSD& key)
{
LLFloater* instance = findInstance(name, key);
if (instance)
@@ -278,7 +295,7 @@ bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key)
//static
// returns true if the instance is visible when completed
-bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key)
+bool LLFloaterReg::toggleInstance(std::string_view name, const LLSD& key)
{
LLFloater* instance = findInstance(name, key);
if (instance && instance->isShown())
@@ -294,7 +311,7 @@ bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key)
//static
// returns true if the instance exists and is visible (doesnt matter minimized or not)
-bool LLFloaterReg::instanceVisible(const std::string& name, const LLSD& key)
+bool LLFloaterReg::instanceVisible(std::string_view name, const LLSD& key)
{
LLFloater* instance = findInstance(name, key);
return LLFloater::isVisible(instance);