SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Option.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // Classes representing a single program option (with different types)
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef Option_h
22 #define Option_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <vector>
36 #include <exception>
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
47 typedef std::vector<int> IntVector;
48 
49 
50 /* -------------------------------------------------------------------------
51  * Option
52  * ----------------------------------------------------------------------- */
78 class Option {
79 public:
81  virtual ~Option();
82 
83 
87  bool isSet() const;
88 
89 
92  void unSet();
93 
94 
103  virtual SUMOReal getFloat() const;
104 
105 
114  virtual int getInt() const;
115 
116 
125  virtual std::string getString() const;
126 
127 
136  virtual bool getBool() const;
137 
138 
147  virtual const IntVector& getIntVector() const;
148 
149 
169  virtual bool set(const std::string& v) = 0;
170 
171 
178  virtual std::string getValueString() const = 0;
179 
180 
187  virtual bool isBool() const;
188 
189 
194  virtual bool isDefault() const;
195 
196 
203  virtual bool isFileName() const;
204 
205 
213  bool isWriteable() const;
214 
215 
221  void resetWritable();
222 
223 
230  const std::string& getDescription() const;
231 
232 
239  void setDescription(const std::string& desc);
240 
241 
248  virtual const std::string& getTypeName() const;
249 
250 
251 protected:
258  bool markSet();
259 
260 
261 protected:
269  Option(bool set = false);
270 
271 
273  Option(const Option& s);
274 
275 
277  virtual Option& operator=(const Option& s);
278 
279 
280 protected:
282  std::string myTypeName;
283 
284 
285 private:
287  bool myAmSet;
288 
291 
294 
296  std::string myDescription;
297 
298 };
299 
300 
301 /* -------------------------------------------------------------------------
302  * Option_Integer
303  * ----------------------------------------------------------------------- */
308 class Option_Integer : public Option {
309 public:
314  Option_Integer();
315 
316 
323  Option_Integer(int value);
324 
325 
327  Option_Integer(const Option_Integer& s);
328 
329 
331  ~Option_Integer();
332 
333 
336 
337 
342  int getInt() const;
343 
344 
360  bool set(const std::string& v);
361 
362 
370  std::string getValueString() const;
371 
372 
373 private:
375  int myValue;
376 
377 };
378 
379 
380 /* -------------------------------------------------------------------------
381  * Option_String
382  * ----------------------------------------------------------------------- */
383 class Option_String : public Option {
384 public:
389  Option_String();
390 
391 
398  Option_String(const std::string& value, std::string typeName = "STR");
399 
400 
402  Option_String(const Option_String& s);
403 
404 
406  virtual ~Option_String();
407 
408 
411 
412 
417  std::string getString() const;
418 
419 
431  bool set(const std::string& v);
432 
433 
441  std::string getValueString() const;
442 
443 
444 protected:
446  std::string myValue;
447 
448 };
449 
450 
451 /* -------------------------------------------------------------------------
452  * Option_Float
453  * ----------------------------------------------------------------------- */
454 class Option_Float : public Option {
455 public:
460  Option_Float();
461 
462 
469  Option_Float(SUMOReal value);
470 
471 
473  Option_Float(const Option_Float& s);
474 
475 
477  ~Option_Float();
478 
479 
482 
483 
488  SUMOReal getFloat() const;
489 
490 
506  bool set(const std::string& v);
507 
508 
516  std::string getValueString() const;
517 
518 
519 private:
522 
523 };
524 
525 
526 /* -------------------------------------------------------------------------
527  * Option_Bool
528  * ----------------------------------------------------------------------- */
529 class Option_Bool : public Option {
530 public:
535  Option_Bool();
536 
537 
544  Option_Bool(bool value);
545 
546 
548  Option_Bool(const Option_Bool& s);
549 
550 
552  ~Option_Bool();
553 
554 
556  Option_Bool& operator=(const Option_Bool& s);
557 
558 
563  bool getBool() const;
564 
566  bool set(const std::string& v);
567 
568 
576  std::string getValueString() const;
577 
578 
586  bool isBool() const;
587 
588 
589 private:
591  bool myValue;
592 
593 };
594 
595 
596 /* -------------------------------------------------------------------------
597  * Option_FileName
598  * ----------------------------------------------------------------------- */
600 public:
603  Option_FileName();
604 
605 
610  Option_FileName(const std::string& value);
611 
612 
614  Option_FileName(const Option_String& s);
615 
616 
618  virtual ~Option_FileName();
619 
622 
623 
630  bool isFileName() const;
631 
632 };
633 
634 
635 /* -------------------------------------------------------------------------
636  * Option_IntVector
637  * ----------------------------------------------------------------------- */
638 class Option_IntVector : public Option {
639 public:
643 
644 
649  Option_IntVector(const IntVector& value);
650 
651 
654 
655 
657  virtual ~Option_IntVector();
658 
659 
662 
663 
668  const IntVector& getIntVector() const;
669 
670 
686  bool set(const std::string& v);
687 
688 
696  std::string getValueString() const;
697 
698 
699 private:
702 };
703 
704 
705 #endif
706 
707 /****************************************************************************/
708