void SimpleTransmissionGroups::GetGroupMembershipForProperties( const RouteList_t& route, const tProperties* properties, TransmissionGroupMembership_t* membershipOut ) const { (*membershipOut)[0] = GroupIndex(0); // map route 0 to index 0 std::ostringstream* msg = nullptr; if (LOG_LEVEL(DEBUG)) { msg = new std::ostringstream(); *msg << "(fn=GetGroupMembershipForProperties) "; } for (const auto& entry : (*properties)) { const string& propertyName = entry.first; const string& propertyValue = entry.second; if (propertyValueToIndexMap.find(propertyName) != propertyValueToIndexMap.end()) { if( propertyValueToIndexMap.at(propertyName).find( propertyValue ) != propertyValueToIndexMap.at(propertyName).end() ) { (*membershipOut)[0] += propertyValueToIndexMap.at(propertyName).at(propertyValue); } else { throw BadMapKeyException( __FILE__, __LINE__, __FUNCTION__, (std::string("propertyValueToIndexMap[")+propertyName+"]").c_str(), propertyValue.c_str() ); } } if (LOG_LEVEL(DEBUG)) { release_assert( msg ); // ensure someone doesn't change logic above so this is not allocated. *msg << propertyName << "=" << propertyValue << ", "; } } if (LOG_LEVEL(DEBUG)) { release_assert( msg ); // ensure someone doesn't change logic above so this is not allocated. *msg << "=> Group index for route 0 is " << (*membershipOut)[0] << std::endl; LOG_DEBUG( msg->str().c_str() ); delete msg; } }
inline std::size_t Groups::GroupIndex(HexPoint point, HexColor color) const { return GroupIndex(point, HexColorSetUtil::Only(color)); }