Merge "adding functionality to get the local name of an object from it's local name"

This commit is contained in:
David Turner
2011-05-18 06:52:22 -07:00
committed by Android Code Review
2 changed files with 38 additions and 0 deletions

View File

@@ -112,6 +112,20 @@ NameSpace::getGlobalName(unsigned int p_localName)
return 0;
}
unsigned int
NameSpace::getLocalName(unsigned int p_globalName)
{
for(NamesMap::iterator it = m_localToGlobalMap.begin(); it != m_localToGlobalMap.end();it++){
if((*it).second == p_globalName){
// object found - return its local name
return (*it).first;
}
}
// object does not exist;
return 0;
}
void
NameSpace::deleteName(unsigned int p_localName)
{
@@ -190,6 +204,18 @@ ShareGroup::getGlobalName(NamedObjectType p_type, unsigned int p_localName)
return globalName;
}
unsigned int
ShareGroup::getLocalName(NamedObjectType p_type, unsigned int p_globalName)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
mutex_lock(&m_lock);
unsigned int localName = m_nameSpace[p_type]->getLocalName(p_globalName);
mutex_unlock(&m_lock);
return localName;
}
void
ShareGroup::deleteName(NamedObjectType p_type, unsigned int p_localName)
{

View File

@@ -73,6 +73,12 @@ private:
//
unsigned int getGlobalName(unsigned int p_localName);
//
// getLocaalName - returns the local name of an object or 0 if the object
// does not exist.
//
unsigned int getLocalName(unsigned int p_globalName);
//
// deleteName - deletes and object from the namespace as well as its
// global name from the global name space.
@@ -124,6 +130,12 @@ public:
//
unsigned int getGlobalName(NamedObjectType p_type, unsigned int p_localName);
//
// getLocalName - retrieves the "local" name of an object or 0 if the
// object does not exist.
//
unsigned int getLocalName(NamedObjectType p_type, unsigned int p_globalName);
//
// deleteName - deletes and object from the namespace as well as its
// global name from the global name space.