1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file IDSupplier.h 11 /// @author Daniel Krajzewicz 12 /// @author Jakob Erdmann 13 /// @date Sept 2002 14 /// @version $Id$ 15 /// 16 // A class that generates enumerated and prefixed string-ids 17 /****************************************************************************/ 18 #ifndef IDSupplier_h 19 #define IDSupplier_h 20 21 22 // =========================================================================== 23 // included modules 24 // =========================================================================== 25 26 #include <string> 27 #include <vector> 28 29 30 // =========================================================================== 31 // class definitions 32 // =========================================================================== 33 /** 34 * @class IDSupplier 35 * This class builds string ids by adding an increasing numerical value to a 36 * previously given string 37 */ 38 class IDSupplier { 39 public: 40 /// Constructor 41 IDSupplier(const std::string& prefix = "", long long int begin = 0); 42 43 /** @brief Constructor 44 * @param[in] prefix The string to use as ID prefix 45 * @param[in] knownIDs List of IDs that should never be returned by this 46 * IDSupplier 47 **/ 48 IDSupplier(const std::string& prefix, const std::vector<std::string>& knownIDs); 49 50 /// Destructor 51 ~IDSupplier(); 52 53 /// Returns the next id 54 std::string getNext(); 55 56 /// make sure that the given id is never supplied 57 void avoid(const std::string& id); 58 59 private: 60 /// The current index 61 long long int myCurrent; 62 63 /// The prefix to use 64 std::string myPrefix; 65 66 }; 67 68 69 #endif 70 71 /****************************************************************************/ 72 73