void BlackBoard::addMission(Mission* mission) { hash_map<string, vector<Mission*>>::iterator FindIter = openMissions.find(mission->getSkillName()); if(FindIter == openMissions.end() ) { //스킬 등록 vector<Mission*> vecMission; vecMission.push_back(mission); openMissions.insert(pair<string,vector<Mission*>>(mission->getSkillName(),vecMission)); //스킬네임과 함께 미션 등록 } else {//그 벡터 안에 미션 포함되어 있지 않다면 벡터 안에 mission 삽입 vector<Mission*>::iterator result; result = find_if(FindIter->second.begin(), FindIter->second.end(), FindMission(mission)); if(result == FindIter->second.end()) { FindIter->second.push_back(mission); } else //같은 아이디의 미션이 등록되어 있다면 메모릭 방지를 위해 delete { delete mission; } } }
void BlackBoard::removeMission(Mission* mission) { hash_map<string, vector<Mission*>>::iterator FindIter = openMissions.find(mission->getSkillName()); if (FindIter != openMissions.end()) { vector<Mission*>::iterator result; result = find_if(FindIter->second.begin(), FindIter->second.end(), FindMission(mission)); if(result != FindIter->second.end()) { FindIter->second.erase(result); } } }
// // RegisterMission // // Register the given mission // const Mission * Group::RegisterMission(const FileIdent &name) { // Is it already registered if (const Mission *existing = FindMission(name)) { return (existing); } // Create a new mission record Mission *mission = new Mission(*this, name); // Add to the tree missions.Add(mission->GetName().crc, mission); // Return the mission return (mission); }
void BlackBoard::removeFromMission(/*Agent agent,*/ Mission* mission) { if (mission == NULL) return; //mission.removeMember(agent); if (//!mission.isFull() && !mission->getMissionComplete()) { hash_map<std::string,vector<Mission*>>::iterator iter = openMissions.find(mission->getSkillName()); if (iter == openMissions.end()) { vector<Mission*> v; openMissions.insert(pair<string,vector<Mission*>>(mission->getSkillName(),v)); iter = openMissions.find(mission->getSkillName()); } vector<Mission*>::iterator result; result = find_if(iter->second.begin(), iter->second.end(), FindMission(mission)); if(result == iter->second.end()) { iter->second.push_back(mission); } } }