Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
FileBucket.cpp
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
21#include "FileBucket.h"
22#include "UtilExceptions.h"
23
24// ===========================================================================
25// static members
26// ===========================================================================
27
28const std::vector<FileBucket::Type> FileBucket::types = {
39};
40
41const std::vector<FileBucket::Type> FileBucket::prefixes = {
45};
46
47// ===========================================================================
48// member method definitions
49// ===========================================================================
50
52 myFileType(type),
53 myDefaultBucket(true) {
54}
55
56
57FileBucket::FileBucket(FileBucket::Type type, const std::string filename) :
58 myFileType(type),
59 myFilename(filename),
60 myDefaultBucket(false) {
61}
62
63
65
66
69 return myFileType;
70}
71
72
73const std::string&
75 return myFilename;
76}
77
78
79void
80FileBucket::setFilename(const std::string& filename) {
81 myFilename = filename;
82}
83
84
85bool
89
90
91void
92FileBucket::addElement(const bool isTemplate) {
93 if (isTemplate) {
95 } else {
97 }
98}
99
100
101void
102FileBucket::removeElement(const bool isTemplate) {
103 if (isTemplate) {
105 // check that number of elementes are not negative
106 if (myNumTemplates < 0) {
107 throw ProcessError("Number of element negative");
108 }
109 } else {
111 // check that number of elementes are not negative
112 if (myNumElements < 0) {
113 throw ProcessError("Number of templates negative");
114 }
115 }
116}
117
118
119int
121 return myNumElements;
122}
123
124
125bool
127 return (myNumElements + myNumTemplates) == 0;
128}
129
130/****************************************************************************/
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
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
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)