1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2005-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    PCTypeMap.h
11 /// @author  Daniel Krajzewicz
12 /// @author  Michael Behrisch
13 /// @author  Jakob Erdmann
14 /// @date    Mon, 05 Dec 2005
15 /// @version $Id$
16 ///
17 // A storage for type mappings
18 /****************************************************************************/
19 #ifndef PCTypeMap_h
20 #define PCTypeMap_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include "utils/common/RGBColor.h"
29 #include <string>
30 #include <map>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class OptionsCont;
37 
38 /**
39  * @class PCTypeMap
40  * @brief A storage for type mappings
41  *
42  * This class holds the mappings between names of read polygon/poi types and the
43  *  values (color, new type name etc.) that shall be assigned to them.
44  */
45 class PCTypeMap {
46 public:
47     /// @brief Constructor. The default type is constructed based on the given options
48     PCTypeMap(const OptionsCont& oc);
49 
50 
51     /// @brief Destructor
52     ~PCTypeMap();
53 
54 
55     /**
56      * @struct TypeDef
57      * @brief A single definition of values that shall be used for a given type
58      */
59     struct TypeDef {
60         /// @brief The new type id to use
61         std::string id;
62         /// @brief The color to use
63         RGBColor color;
64         /// @brief The prefix to use
65         std::string prefix;
66         /// @brief The layer to use
67         double layer;
68         /// @brief Information whether polygons of this type shall be discarded
69         bool discard;
70         /// @brief Information whether polygons of this type can be filled
71         bool allowFill;
72 
73     };
74 
75 
76     /** @brief Adds a type definition
77      *
78      * @param[in] id The original id of the type
79      * @param[in] newid The new id (name) of the type
80      * @param[in] color The color to set for imported objects of this type
81      * @param[in] prefix The prefix to prepend to the read names of this type's objects
82      * @param[in] layer The layer number to set for this type's objects
83      * @param[in] discard Whether objects of this type shall be discarded
84      * @param[in] allowFill Whether objects of this type may be filled
85      * @return Whether the type could been added (was not known before)
86      */
87     bool add(const std::string& id, const std::string& newid, const std::string& color,
88              const std::string& prefix, double layer, bool discard, bool allowFill);
89 
90 
91     /** @brief Returns a type definition
92      *
93      * This type definition MUST have been added otherwise the further process
94      *  is undefined.
95      * @param[in] id The id of the type to get the definitions of
96      * @return Definition of the named type
97      */
98     const TypeDef& get(const std::string& id);
99 
100 
101     /** @brief Returns the information whether the named type is known
102      * @param[in] id The id of the type
103      * @return Whether a definition of the named type was added before
104      */
105     bool has(const std::string& id);
106 
107     /// @brief get the default type according to the given options
getDefault()108     const TypeDef& getDefault() {
109         return myDefaultType;
110     }
111 
112 protected:
113     /// @brief A map of type names to type definitions
114     std::map<std::string, TypeDef> myTypes;
115 
116     TypeDef myDefaultType;
117 
118 };
119 
120 
121 #endif
122 
123 /****************************************************************************/
124 
125