/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 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 FileBucket.h14/// @author Pablo Alvarez Lopez15/// @date Nov 202516///17// class used for link Elements with their filenames18/****************************************************************************/19#pragma once20#include <config.h>2122#include <string>23#include <vector>2425// ===========================================================================26// class definitions27// ===========================================================================2829class FileBucket {3031public:32/// @brief Files that this bucket can save33enum class Type : int {34SUMO_CONFIG = 1 << 0, // Bucket for sumo configs (usually only one)35NETEDIT_CONFIG = 1 << 1, // Bucket for netedit configs (usually only one)36NETCONVERT_CONFIG = 1 << 2, // Bucket for netconvert configs (usually only one)37NETWORK = 1 << 3, // Bucket for network elements (usually only one)38EDGETYPE = 1 << 4, // Bucket for edge type (usually only one)39TLS = 1 << 5, // Bucket for traffic lights (usually only one)40DEMAND = 1 << 6, // Bucket for demand elements41MEANDATA = 1 << 7, // Bucket for meanData elements42ADDITIONAL = 1 << 8, // Bucket for additional elements (always after demand and meanData)43DATA = 1 << 9, // Bucket for data elements44// prefixes45NETEDIT_PREFIX = 1 << 10, // Bucket for netedit prefix46SUMO_PREFIX = 1 << 11, // Bucket for sumo prefix47NETCONVERT_PREFIX = 1 << 12, // Bucket for netconvert prefix48// other49NOTHING = 1 << 13, // Element is not saved in bucket50};5152/// @brief Constructor for default bucket53FileBucket(FileBucket::Type type);5455/// @brief Constructor56FileBucket(FileBucket::Type type, const std::string filename);5758/// @brief destructor59~FileBucket();6061/// @brief get file type62FileBucket::Type getType() const;6364/// @brief get filename65const std::string& getFilename() const;6667/// @brief set filename68void setFilename(const std::string& filename);6970/// @brief check if this is a default bucket71bool isDefaultBucket() const;7273/// @brief function related with Elements74/// @{7576/// @brief add element in bucket77void addElement(const bool isTemplate);7879/// @brief remove element80void removeElement(const bool isTemplate);8182/// @brief add default vClass83void addDefaultVType();8485/// @brief remove default vClass86void removeDefaultVType();8788/// @brief check number of elements (no templates)89int getNumElements() const;9091/// @brief check if this bucket is empty92bool isEmpty() const;9394/// @}9596/// @brief vector with all types managed in this get bucket handler97static const std::vector<FileBucket::Type> types;9899/// @brief vector with all types and prefixes managed in this get bucket handler100static const std::vector<FileBucket::Type> prefixes;101102private:103/// @brief type104const FileBucket::Type myFileType;105106/// @brief filename107std::string myFilename;108109/// @brief number of elements vinculated with this file bucket110int myNumElements = 0;111112/// @brief number of templates vinculated with this file bucket113int myNumTemplates = 0;114115/// @brief number of default vTypes vinculated with this file bucket116int myNumDefaultVTypes = 0;117118/// @brief flag to indicate if this is a default bucket (it cannot be removed)119const bool myDefaultBucket;120121/// @brief Invalidated default constructor.122FileBucket() = delete;123124/// @brief Invalidated copy constructor.125FileBucket(const FileBucket&) = delete;126127/// @brief Invalidated assignment operator128FileBucket& operator=(const FileBucket& src) = delete;129};130131/// @brief override type bit operator132constexpr FileBucket::Type operator|(FileBucket::Type a, FileBucket::Type b) {133return static_cast<FileBucket::Type>(static_cast<int>(a) | static_cast<int>(b));134}135136/// @brief override type bit operator137constexpr bool operator&(FileBucket::Type a, FileBucket::Type b) {138return (static_cast<int>(a) & static_cast<int>(b)) != 0;139}140141142