Changed: #1459 Reserve functional group controller node names

This commit is contained in:
kaetemi 2012-04-13 13:59:24 +02:00
parent c340881992
commit 45a857b564
2 changed files with 17 additions and 0 deletions

View file

@ -59,6 +59,7 @@ protected:
virtual void calculateFinalGain();
virtual void increaseSources();
virtual void decreaseSources();
static bool isReservedName(const std::string &nodeName);
}; /* class CGroupControllerRoot */

View file

@ -78,6 +78,18 @@ void CGroupControllerRoot::decreaseSources()
--m_NbSourcesInclChild;
}
bool CGroupControllerRoot::isReservedName(const std::string &nodeName)
{
// These node names are reserved, in case these category controllers can be integrated with CDB.
// I do not forsee any functionality for changing environment effect settings for entire categories.
// The nodeName parameter is already lowercase, see CGroupControllerRoot::getGroupController.
if (nodeName == NLSOUND_GROUP_CONTROLLER_ROOT_PATH) return true; // Root node name can only used by root.
if (nodeName == "gain") return true;
if (nodeName == "pitch") return true;
if (nodeName == "enable" || nodeName == "enabled") return true;
return true;
}
CGroupController *CGroupControllerRoot::getGroupController(const std::string &path)
{
std::vector<std::string> pathNodes;
@ -91,6 +103,10 @@ CGroupController *CGroupControllerRoot::getGroupController(const std::string &pa
{
if (!(*it).empty())
{
if (isReservedName(*it))
{
nlerror("Attempt to use reserved node name '%s' in group controller path '%s'", (*it).c_str(), path.c_str());
}
std::map<std::string, CGroupController *>::iterator found = active->m_Children.find(*it);
if (found == active->m_Children.end())
{