varconf 1.0.3
Configuration library for the Worldforge system.
dyncmp.h
1/*
2 * dyncmp.h - interface for dynamically derived value container class compare
3 * Copyright (C) 2001, Ron Steinke
4 * (C) 2003-2004 Alistair Riddoch
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Contact: Joseph Zupko
21 * jaz147@psu.edu
22 *
23 * 189 Reese St.
24 * Old Forge, PA 18518
25 */
26
27#ifndef VARCONF_DYNCMP_H
28#define VARCONF_DYNCMP_H
29
30#include "variable.h"
31#include "dynbase.h"
32
33#include <string>
34
35namespace varconf {
36namespace dynvar {
37
38class Compare : public Base {
39public:
40 Compare() : Base(), m_v1(0), m_v2(0) {}
41 Compare(const Variable& v1, const Variable& v2) : Base(), m_v1(v1), m_v2(v2) {}
42 Compare(const Compare& c) : sigc::trackable(c), Base(c), m_v1(c.m_v1), m_v2(c.m_v2) {}
43
44 ~Compare() override;
45
46 Compare& operator=(const Compare& c);
47
48protected:
49
50 void set_val() override;
51
52 virtual bool bool_cmp(bool b1, bool b2) = 0;
53 virtual bool int_cmp(int i1, int i2) = 0;
54 virtual bool double_cmp(double d1, double d2) = 0;
55 virtual bool string_cmp(const std::string& s1, const std::string& s2) = 0;
56
57private:
58
59 Variable m_v1, m_v2;
60};
61
62class Equal : public Compare {
63public:
64 Equal() : Compare() {}
65 Equal(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
66 Equal(const Equal& e) : sigc::trackable(e), Compare(e) {}
67
68 ~Equal() override;
69
70protected:
71
72 bool bool_cmp(bool b1, bool b2) override;
73 bool int_cmp(int i1, int i2) override;
74 bool double_cmp(double d1, double d2) override;
75 bool string_cmp(const std::string& s1, const std::string& s2) override;
76};
77
78class NotEq : public Compare {
79public:
80 NotEq() : Compare() {}
81 NotEq(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
82 NotEq(const NotEq& e) : sigc::trackable(e), Compare(e) {}
83
84 ~NotEq() override;
85
86protected:
87
88 bool bool_cmp(bool b1, bool b2) override;
89 bool int_cmp(int i1, int i2) override;
90 bool double_cmp(double d1, double d2) override;
91 bool string_cmp(const std::string & s1, const std::string & s2) override;
92};
93
94class Greater : public Compare {
95public:
96 Greater() : Compare() {}
97 Greater(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
98 Greater(const Greater& e) : sigc::trackable(e), Compare(e) {}
99
100 ~Greater() override;
101
102protected:
103
104 bool bool_cmp(bool b1, bool b2) override;
105 bool int_cmp(int i1, int i2) override;
106 bool double_cmp(double d1, double d2) override;
107 bool string_cmp(const std::string& s1, const std::string& s2) override;
108};
109
110class GreaterEq : public Compare {
111public:
112 GreaterEq() : Compare() {}
113 GreaterEq(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
114 GreaterEq(const GreaterEq& e) : sigc::trackable(e), Compare(e) {}
115
116 ~GreaterEq() override;
117
118protected:
119
120 bool bool_cmp(bool b1, bool b2) override;
121 bool int_cmp(int i1, int i2) override;
122 bool double_cmp(double d1, double d2) override;
123 bool string_cmp(const std::string& s1, const std::string& s2) override;
124};
125
126class Less : public Compare {
127public:
128 Less() : Compare() {}
129 Less(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
130 Less(const Less& e) : sigc::trackable(e), Compare(e) {}
131
132 ~Less() override;
133
134protected:
135
136 bool bool_cmp(bool b1, bool b2) override;
137 bool int_cmp(int i1, int i2) override;
138 bool double_cmp(double d1, double d2) override;
139 bool string_cmp(const std::string& s1, const std::string& s2) override;
140};
141
142class LessEq : public Compare {
143public:
144 LessEq() : Compare() {}
145 LessEq(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
146 LessEq(const LessEq& e) : sigc::trackable(e), Compare(e) {}
147
148 ~LessEq() override;
149
150protected:
151
152 bool bool_cmp(bool b1, bool b2) override;
153 bool int_cmp(int i1, int i2) override;
154 bool double_cmp(double d1, double d2) override;
155 bool string_cmp(const std::string& s1, const std::string& s2) override;
156};
157
158}} // namespace varconf::dynvar
159
160#endif