| 775 | //----------------------------------------------------------------------------- |
| 776 | |
| 777 | void SimObject::assignName(const char *name) |
| 778 | { |
| 779 | if(mObjectName && !isNameChangeAllowed() ) |
| 780 | { |
| 781 | Con::errorf( "SimObject::assignName - not allowed to change name of object '%s'", mObjectName); |
| 782 | return; |
| 783 | } |
| 784 | |
| 785 | // Added this assert 3/30/2007 because it is dumb to try to name |
| 786 | // a SimObject the same thing as it's class name -patw |
| 787 | //AssertFatal( dStricmp( getClassName(), name ), "Attempted to assign a name to a SimObject which matches it's type name." ); |
| 788 | if( dStricmp( getClassName(), name ) == 0 ) |
| 789 | Con::errorf( "SimObject::assignName - Assigning name '%s' to instance of object with type '%s'." |
| 790 | " This can cause namespace linking issues.", getClassName(), name ); |
| 791 | |
| 792 | StringTableEntry newName = NULL; |
| 793 | if(name[0]) |
| 794 | newName = StringTable->insert(name); |
| 795 | |
| 796 | onNameChange( newName ); |
| 797 | |
| 798 | if( mGroup ) |
| 799 | mGroup->mNameDictionary.remove( this ); |
| 800 | if( isProperlyAdded() ) |
| 801 | { |
| 802 | unlinkNamespaces(); |
| 803 | Sim::gNameDictionary->remove( this ); |
| 804 | } |
| 805 | |
| 806 | mObjectName = newName; |
| 807 | |
| 808 | if( mGroup ) |
| 809 | mGroup->mNameDictionary.insert( this ); |
| 810 | if( isProperlyAdded() ) |
| 811 | { |
| 812 | Sim::gNameDictionary->insert( this ); |
| 813 | linkNamespaces(); |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | //----------------------------------------------------------------------------- |
| 818 | |