Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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
Vec.h
Minisat::Internal::BoolOption
Definition: Options.h:99
Minisat::Internal::BoolOption::BoolOption
BoolOption(const char *d, bool v)
Definition: Options.h:104
Minisat::Internal::DoubleRange::begin
double begin
Definition: Options.h:45
Minisat::Internal::IntOption::operator=
IntOption & operator=(int32_t x)
Definition: Options.h:90
Minisat::Internal::DoubleRange::end_inclusive
bool end_inclusive
Definition: Options.h:48
INT32_MAX
#define INT32_MAX
Definition: IntTypes.h:48
INT32_MIN
#define INT32_MIN
Definition: IntTypes.h:45
Minisat::Internal::IntRange
Definition: Options.h:38
Minisat::Internal::IntOption::value
int32_t value
Definition: Options.h:82
Minisat::Internal::DoubleOption::DoubleOption
DoubleOption(const char *d, double def=double(), DoubleRange r=DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
Definition: Options.h:64
Minisat::Internal::IntOption::IntOption
IntOption(const char *d, int32_t def=int32_t(), IntRange r=IntRange(INT32_MIN, INT32_MAX))
Definition: Options.h:85
IntTypes.h
ParseUtils.h
r
int r[]
Definition: hierarchical-ranking.cpp:8
Minisat::Internal::DoubleOption::operator=
DoubleOption & operator=(double x)
Definition: Options.h:70
Minisat::Internal::DoubleRange::end
double end
Definition: Options.h:46
Minisat
Definition: Minisat.h:48
Minisat::Internal::DoubleOption::range
DoubleRange range
Definition: Options.h:60
Minisat::Internal::DoubleRange::DoubleRange
DoubleRange(double b, bool binc, double e, bool einc)
Definition: Options.h:49
Minisat::Internal::IntRange::begin
int begin
Definition: Options.h:39
Minisat::Internal::BoolOption::value
bool value
Definition: Options.h:101
Minisat::Internal::IntRange::IntRange
IntRange(int b, int e)
Definition: Options.h:41
Minisat::Internal::DoubleRange::begin_inclusive
bool begin_inclusive
Definition: Options.h:47
Minisat::Internal::IntOption
Definition: Options.h:78
Minisat::Internal::BoolOption::operator=
BoolOption & operator=(bool b)
Definition: Options.h:109
Minisat::Internal::IntRange::end
int end
Definition: Options.h:40
Minisat::Internal::DoubleOption
Definition: Options.h:57
Minisat::Internal::DoubleRange
Definition: Options.h:44
Minisat::Internal::DoubleOption::value
double value
Definition: Options.h:61
Minisat::Internal::IntOption::range
IntRange range
Definition: Options.h:81