Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
FileBucket.h
Go to the documentation of this file.
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/****************************************************************************/
18// class used for link Elements with their filenames
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <string>
24#include <vector>
25
26// ===========================================================================
27// class definitions
28// ===========================================================================
29
31
32public:
34 enum class Type : int {
35 SUMO_CONFIG = 1 << 0, // Bucket for sumo configs (usually only one)
36 NETEDIT_CONFIG = 1 << 1, // Bucket for netedit configs (usually only one)
37 NETCONVERT_CONFIG = 1 << 2, // Bucket for netconvert configs (usually only one)
38 NETWORK = 1 << 3, // Bucket for network elements (usually only one)
39 EDGETYPE = 1 << 4, // Bucket for edge type (usually only one)
40 TLS = 1 << 5, // Bucket for traffic lights (usually only one)
41 DEMAND = 1 << 6, // Bucket for demand elements
42 MEANDATA = 1 << 7, // Bucket for meanData elements
43 ADDITIONAL = 1 << 8, // Bucket for additional elements (always after demand and meanData)
44 DATA = 1 << 9, // Bucket for data elements
45 // prefixes
46 NETEDIT_PREFIX = 1 << 10, // Bucket for netedit prefix
47 SUMO_PREFIX = 1 << 11, // Bucket for sumo prefix
48 NETCONVERT_PREFIX = 1 << 12, // Bucket for netconvert prefix
49 // other
50 NOTHING = 1 << 13, // Element is not saved in bucket
51 };
52
55
57 FileBucket(FileBucket::Type type, const std::string filename);
58
61
64
66 const std::string& getFilename() const;
67
69 void setFilename(const std::string& filename);
70
72 bool isDefaultBucket() const;
73
76
78 void addElement(const bool isTemplate);
79
81 void removeElement(const bool isTemplate);
82
84 int getNumElements() const;
85
87 bool isEmpty() const;
88
90
92 static const std::vector<FileBucket::Type> types;
93
95 static const std::vector<FileBucket::Type> prefixes;
96
97private:
100
102 std::string myFilename;
103
106
109
111 const bool myDefaultBucket;
112
114 FileBucket() = delete;
115
117 FileBucket(const FileBucket&) = delete;
118
120 FileBucket& operator=(const FileBucket& src) = delete;
121};
122
125 return static_cast<FileBucket::Type>(static_cast<int>(a) | static_cast<int>(b));
126}
127
130 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
131}
constexpr FileBucket::Type operator|(FileBucket::Type a, FileBucket::Type b)
override type bit operator
Definition FileBucket.h:124
constexpr bool operator&(FileBucket::Type a, FileBucket::Type b)
override type bit operator
Definition FileBucket.h:129
void removeElement(const bool isTemplate)
remove element
void addElement(const bool isTemplate)
function related with Elements
const bool myDefaultBucket
flag to indicate if this is a default bucket (it cannot be removed)
Definition FileBucket.h:111
int myNumElements
number of elements vinculated with this file bucket
Definition FileBucket.h:105
FileBucket(const FileBucket &)=delete
Invalidated copy constructor.
int myNumTemplates
number of templates vinculated with this file bucket
Definition FileBucket.h:108
Type
Files that this bucket can save.
Definition FileBucket.h:34
static const std::vector< FileBucket::Type > types
vector with all types managed in this get bucket handler
Definition FileBucket.h:28
const std::string & getFilename() const
get filename
bool isEmpty() const
check if this bucket is empty
const FileBucket::Type myFileType
type
Definition FileBucket.h:99
static const std::vector< FileBucket::Type > prefixes
vector with all types and prefixes managed in this get bucket handler
Definition FileBucket.h:41
FileBucket::Type getType() const
get file type
FileBucket & operator=(const FileBucket &src)=delete
Invalidated assignment operator.
bool isDefaultBucket() const
check if this is a default bucket
void setFilename(const std::string &filename)
set filename
~FileBucket()
destructor
FileBucket()=delete
Invalidated default constructor.
std::string myFilename
filename
Definition FileBucket.h:102
int getNumElements() const
check number of elements (no templates)