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 
98  virtual SUMOReal getFloat() const;
99 
100 
109  virtual int getInt() const;
110 
111 
120  virtual std::string getString() const;
121 
122 
131  virtual bool getBool() const;
132 
133 
142  virtual const IntVector& getIntVector() const;
143 
144 
164  virtual bool set(const std::string& v) = 0;
165 
166 
173  virtual std::string getValueString() const = 0;
174 
175 
182  virtual bool isBool() const;
183 
184 
189  virtual bool isDefault() const;
190 
191 
198  virtual bool isFileName() const;
199 
200 
208  bool isWriteable() const;
209 
210 
216  void resetWritable();
217 
218 
225  const std::string& getDescription() const;
226 
227 
234  void setDescription(const std::string& desc);
235 
236 
243  virtual const std::string& getTypeName() const;
244 
245 
246 protected:
253  bool markSet();
254 
255 
256 protected:
264  Option(bool set = false);
265 
266 
268  Option(const Option& s);
269 
270 
272  virtual Option& operator=(const Option& s);
273 
274 
275 protected:
277  std::string myTypeName;
278 
279 
280 private:
282  bool myAmSet;
283 
286 
289 
291  std::string myDescription;
292 
293 };
294 
295 
296 /* -------------------------------------------------------------------------
297  * Option_Integer
298  * ----------------------------------------------------------------------- */
303 class Option_Integer : public Option {
304 public:
309  Option_Integer();
310 
311 
318  Option_Integer(int value);
319 
320 
322  Option_Integer(const Option_Integer& s);
323 
324 
326  ~Option_Integer();
327 
328 
331 
332 
337  int getInt() const;
338 
339 
355  bool set(const std::string& v);
356 
357 
365  std::string getValueString() const;
366 
367 
368 private:
370  int myValue;
371 
372 };
373 
374 
375 /* -------------------------------------------------------------------------
376  * Option_String
377  * ----------------------------------------------------------------------- */
378 class Option_String : public Option {
379 public:
384  Option_String();
385 
386 
393  Option_String(const std::string& value, std::string typeName = "STR");
394 
395 
397  Option_String(const Option_String& s);
398 
399 
401  virtual ~Option_String();
402 
403 
406 
407 
412  std::string getString() const;
413 
414 
426  bool set(const std::string& v);
427 
428 
436  std::string getValueString() const;
437 
438 
439 protected:
441  std::string myValue;
442 
443 };
444 
445 
446 /* -------------------------------------------------------------------------
447  * Option_Float
448  * ----------------------------------------------------------------------- */
449 class Option_Float : public Option {
450 public:
455  Option_Float();
456 
457 
464  Option_Float(SUMOReal value);
465 
466 
468  Option_Float(const Option_Float& s);
469 
470 
472  ~Option_Float();
473 
474 
477 
478 
483  SUMOReal getFloat() const;
484 
485 
501  bool set(const std::string& v);
502 
503 
511  std::string getValueString() const;
512 
513 
514 private:
517 
518 };
519 
520 
521 /* -------------------------------------------------------------------------
522  * Option_Bool
523  * ----------------------------------------------------------------------- */
524 class Option_Bool : public Option {
525 public:
530  Option_Bool();
531 
532 
539  Option_Bool(bool value);
540 
541 
543  Option_Bool(const Option_Bool& s);
544 
545 
547  ~Option_Bool();
548 
549 
551  Option_Bool& operator=(const Option_Bool& s);
552 
553 
558  bool getBool() const;
559 
561  bool set(const std::string& v);
562 
563 
571  std::string getValueString() const;
572 
573 
581  bool isBool() const;
582 
583 
584 private:
586  bool myValue;
587 
588 };
589 
590 
591 /* -------------------------------------------------------------------------
592  * Option_FileName
593  * ----------------------------------------------------------------------- */
595 public:
598  Option_FileName();
599 
600 
605  Option_FileName(const std::string& value);
606 
607 
609  Option_FileName(const Option_String& s);
610 
611 
613  virtual ~Option_FileName();
614 
617 
618 
625  bool isFileName() const;
626 
627 };
628 
629 
630 /* -------------------------------------------------------------------------
631  * Option_IntVector
632  * ----------------------------------------------------------------------- */
633 class Option_IntVector : public Option {
634 public:
638 
639 
644  Option_IntVector(const IntVector& value);
645 
646 
649 
650 
652  virtual ~Option_IntVector();
653 
654 
657 
658 
663  const IntVector& getIntVector() const;
664 
665 
681  bool set(const std::string& v);
682 
683 
691  std::string getValueString() const;
692 
693 
694 private:
697 };
698 
699 
700 #endif
701 
702 /****************************************************************************/
703