Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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