Example #1
0
		void setId(Util::Reference<Obj> obj,const Util::StringIdentifier & id){
			if(!id.empty()) // remove a obj possibly previously registered with the id
				removeId( id );
			if(obj.isNotNull()) // remove the obj's old id
				removeId( obj.get() ); 
			if(obj.isNotNull()&&!id.empty()){ // register the obj using the new id
				map_objToId.emplace(obj.get(),id);
				map_idToObj.emplace(id, std::move(obj));
			}
		}
Example #2
0
		Util::StringIdentifier createAndSetId(Util::Reference<Obj> obj){
			Util::StringIdentifier id = getId(obj.get());
			if(obj.isNotNull() && id.empty()) {
				do { // Create a new, random identifier....
					id = Util::StringIdentifier("$" + Util::StringUtils::createRandomString(6));
				}while( get(id) ); // ... until an unused one is found.
				setId(obj,id);
			}
			return id;
		}