Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/common/IDSupplier.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file IDSupplier.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @date Sept 2002
18
///
19
// A class that generates enumerated and prefixed string-ids
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
#include <string>
24
#include <vector>
25
26
27
// ===========================================================================
28
// class definitions
29
// ===========================================================================
30
/**
31
* @class IDSupplier
32
* This class builds string ids by adding an increasing numerical value to a
33
* previously given string
34
*/
35
class IDSupplier {
36
public:
37
/// Constructor
38
IDSupplier(const std::string& prefix = "", long long int begin = 0);
39
40
/** @brief Constructor
41
* @param[in] prefix The string to use as ID prefix
42
* @param[in] knownIDs List of IDs that should never be returned by this
43
* IDSupplier
44
**/
45
IDSupplier(const std::string& prefix, const std::vector<std::string>& knownIDs);
46
47
/// Destructor
48
~IDSupplier();
49
50
/// Returns the next id
51
std::string getNext();
52
53
/// make sure that the given id is never supplied
54
void avoid(const std::string& id);
55
56
private:
57
/// The current index
58
long long int myCurrent;
59
60
/// The prefix to use
61
std::string myPrefix;
62
63
};
64
65