Path: blob/main/src/utils/distribution/DistributionCont.cpp
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file DistributionCont.cpp14/// @author Daniel Krajzewicz15/// @date Sept 200216///17// A container for distributions18/****************************************************************************/19#include <config.h>2021#include "DistributionCont.h"222324// ===========================================================================25// static variable definitions26// ===========================================================================27DistributionCont::TypedDistDict DistributionCont::myDict;282930// ===========================================================================31// method definitions32// ===========================================================================33bool34DistributionCont::dictionary(const std::string& type, const std::string& id,35Distribution* d) {36TypedDistDict::iterator i = myDict.find(type);3738if (i == myDict.end()) {39myDict[type][id] = d;40return true;41}42DistDict& dict = (*i).second;43DistDict::iterator j = dict.find(id);44if (j == dict.end()) {45myDict[type][id] = d;46return true;47}48return false;49}505152Distribution*53DistributionCont::dictionary(const std::string& type,54const std::string& id) {55TypedDistDict::iterator i = myDict.find(type);56if (i == myDict.end()) {57return nullptr;58}59DistDict& dict = (*i).second;60DistDict::iterator j = dict.find(id);61if (j == dict.end()) {62return nullptr;63}64return (*j).second;65}666768void69DistributionCont::clear() {70for (TypedDistDict::iterator i = myDict.begin(); i != myDict.end(); i++) {71DistDict& dict = (*i).second;72for (DistDict::iterator j = dict.begin(); j != dict.end(); j++) {73delete (*j).second;74}75}76}777879/****************************************************************************/808182