Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

Options.h
Go to the documentation of this file.
1 /***************************************************************************************[Options.h]
2 Copyright (c) 2008-2010, Niklas Sorensson
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5 associated documentation files (the "Software"), to deal in the Software without restriction,
6 including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 furnished to do so, subject to the following conditions:
9 
10 The above copyright notice and this permission notice shall be included in all copies or
11 substantial portions of the Software.
12 
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14 NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
17 OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 **************************************************************************************************/
19 
20 #pragma once
21 
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <math.h>
25 #include <string.h>
26 
30 
31 namespace Minisat {
32 namespace Internal {
33 
34 //==================================================================================================
35 // Range classes with specialization for floating types:
36 
37 
38 struct IntRange {
39  int begin;
40  int end;
41  IntRange(int b, int e) : begin(b), end(e) {}
42 };
43 
44 struct DoubleRange {
45  double begin;
46  double end;
49  DoubleRange(double b, bool binc, double e, bool einc) : begin(b), end(e), begin_inclusive(binc), end_inclusive(einc) {}
50 };
51 
52 
53 //==================================================================================================
54 // Double options:
55 
56 
58 {
59  protected:
61  double value;
62 
63  public:
64  DoubleOption(const char* d, double def = double(), DoubleRange r = DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
65  : range(r), value(def) {
66  }
67 
68  operator double (void) const { return value; }
69  operator double& (void) { return value; }
70  DoubleOption& operator=(double x) { value = x; return *this; }
71 };
72 
73 
74 //==================================================================================================
75 // Int options:
76 
77 
78 class IntOption
79 {
80  protected:
82  int32_t value;
83 
84  public:
85  IntOption(const char* d, int32_t def = int32_t(), IntRange r = IntRange(INT32_MIN, INT32_MAX))
86  : range(r), value(def) {}
87 
88  operator int32_t (void) const { return value; }
89  operator int32_t& (void) { return value; }
90  IntOption& operator= (int32_t x) { value = x; return *this; }
91 };
92 
93 
94 
95 //==================================================================================================
96 // Bool option:
97 
98 
100 {
101  bool value;
102 
103  public:
104  BoolOption(const char* d, bool v)
105  : value(v) {}
106 
107  operator bool (void) const { return value; }
108  operator bool& (void) { return value; }
109  BoolOption& operator=(bool b) { value = b; return *this; }
110 };
111 
112 //=================================================================================================
113 } // namespace Internal
114 } // namespace Minisat
#define INT32_MIN
Definition: IntTypes.h:45
BoolOption & operator=(bool b)
Definition: Options.h:109
IntOption(const char *d, int32_t def=int32_t(), IntRange r=IntRange(INT32_MIN, INT32_MAX))
Definition: Options.h:85
Mathematical Helpers.
#define INT32_MAX
Definition: IntTypes.h:48
BoolOption(const char *d, bool v)
Definition: Options.h:104
DoubleOption & operator=(double x)
Definition: Options.h:70
IntRange(int b, int e)
Definition: Options.h:41
DoubleOption(const char *d, double def=double(), DoubleRange r=DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
Definition: Options.h:64
DoubleRange(double b, bool binc, double e, bool einc)
Definition: Options.h:49