Page 1 of 1
Change Entities name after creation?
Posted: Sun Oct 07, 2012 10:57 pm
by mude
Is it possible? I can't find anything about it, why it's not allowed?
Re: Change Entities name after creation?
Posted: Mon Oct 08, 2012 12:18 am
by Kojack
All entities are stored in a map, using the name as the key. It's not possible to change the key of an item in a map (it would break the tree hierarchy used for searching).
Re: Change Entities name after creation?
Posted: Mon Oct 08, 2012 5:34 am
by bstone
Yeah, if you want to associate entity with a name that can be updated you could use Entity::setUserAny() and Entity::getUserAny().
Re: Change Entities name after creation?
Posted: Thu Oct 11, 2012 12:24 pm
by mmixLinus
Or, if you REALLY want to use the Entity by a different name, clone it:
Code: Select all
//Entity * clone (const String &newName) const
renamedEntity = oldEntity->clone("NewName");