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 void addDefaultVType();
85
87 void removeDefaultVType();
88
90 int getNumElements() const;
91
93 bool isEmpty() const;
94
96
98 static const std::vector<FileBucket::Type> types;
99
101 static const std::vector<FileBucket::Type> prefixes;
102
103private:
106
108 std::string myFilename;
109
112
115
118
120 const bool myDefaultBucket;
121
123 FileBucket() = delete;
124
126 FileBucket(const FileBucket&) = delete;
127
129 FileBucket& operator=(const FileBucket& src) = delete;
130};
131
134 return static_cast<FileBucket::Type>(static_cast<int>(a) | static_cast<int>(b));
135}
136
139 return (static_cast<int>(a) & static_cast<int>(b)) != 0;
140}
constexpr FileBucket::Type operator|(FileBucket::Type a, FileBucket::Type b)
override type bit operator
Definition FileBucket.h:133
constexpr bool operator&(FileBucket::Type a, FileBucket::Type b)
override type bit operator
Definition FileBucket.h:138
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:120
int myNumElements
number of elements vinculated with this file bucket
Definition FileBucket.h:111
void removeDefaultVType()
remove default vClass
FileBucket(const FileBucket &)=delete
Invalidated copy constructor.
int myNumTemplates
number of templates vinculated with this file bucket
Definition FileBucket.h:114
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
int myNumDefaultVTypes
number of default vTypes vinculated with this file bucket
Definition FileBucket.h:117
const FileBucket::Type myFileType
type
Definition FileBucket.h:105
static const std::vector< FileBucket::Type > prefixes
vector with all types and prefixes managed in this get bucket handler
Definition FileBucket.h:41
void addDefaultVType()
add default vClass
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:108
int getNumElements() const
check number of elements (no templates)