varconf  1.0.2
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 <varconf/variable.h>
31 #include <varconf/dynbase.h>
32 
33 #include <string>
34 
35 namespace varconf {
36 namespace dynvar {
37 
38 class Compare : public Base {
39 public:
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) : Base(c), m_v1(c.m_v1), m_v2(c.m_v2) {}
43 
44  virtual ~Compare();
45 
46  Compare& operator=(const Compare& c);
47 
48 protected:
49 
50  virtual void set_val();
51 
52  virtual bool bool_cmp(const bool b1, const bool b2) = 0;
53  virtual bool int_cmp(const int i1, const int i2) = 0;
54  virtual bool double_cmp(const double d1, const double d2) = 0;
55  virtual bool string_cmp(const std::string& s1, const std::string& s2) = 0;
56 
57 private:
58 
59  Variable m_v1, m_v2;
60 };
61 
62 class Equal : public Compare {
63 public:
64  Equal() : Compare() {}
65  Equal(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
66  Equal(const Equal& e) : Compare(e) {}
67 
68  virtual ~Equal();
69 
70 protected:
71 
72  virtual bool bool_cmp(const bool b1, const bool b2);
73  virtual bool int_cmp(const int i1, const int i2);
74  virtual bool double_cmp(const double d1, const double d2);
75  virtual bool string_cmp(const std::string& s1, const std::string& s2);
76 };
77 
78 class NotEq : public Compare {
79 public:
80  NotEq() : Compare() {}
81  NotEq(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
82  NotEq(const NotEq& e) : Compare(e) {}
83 
84  virtual ~NotEq();
85 
86 protected:
87 
88  virtual bool bool_cmp(const bool b1, const bool b2);
89  virtual bool int_cmp(const int i1, const int i2);
90  virtual bool double_cmp(const double d1, const double d2);
91  virtual bool string_cmp(const std::string & s1, const std::string & s2);
92 };
93 
94 class Greater : public Compare {
95 public:
96  Greater() : Compare() {}
97  Greater(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
98  Greater(const Greater& e) : Compare(e) {}
99 
100  virtual ~Greater();
101 
102 protected:
103 
104  virtual bool bool_cmp(const bool b1, const bool b2);
105  virtual bool int_cmp(const int i1, const int i2);
106  virtual bool double_cmp(const double d1, const double d2);
107  virtual bool string_cmp(const std::string& s1, const std::string& s2);
108 };
109 
110 class GreaterEq : public Compare {
111 public:
112  GreaterEq() : Compare() {}
113  GreaterEq(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
114  GreaterEq(const GreaterEq& e) : Compare(e) {}
115 
116  virtual ~GreaterEq();
117 
118 protected:
119 
120  virtual bool bool_cmp(const bool b1, const bool b2);
121  virtual bool int_cmp(const int i1, const int i2);
122  virtual bool double_cmp(const double d1, const double d2);
123  virtual bool string_cmp(const std::string& s1, const std::string& s2);
124 };
125 
126 class Less : public Compare {
127 public:
128  Less() : Compare() {}
129  Less(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
130  Less(const Less& e) : Compare(e) {}
131 
132  virtual ~Less();
133 
134 protected:
135 
136  virtual bool bool_cmp(const bool b1, const bool b2);
137  virtual bool int_cmp(const int i1, const int i2);
138  virtual bool double_cmp(const double d1, const double d2);
139  virtual bool string_cmp(const std::string& s1, const std::string& s2);
140 };
141 
142 class LessEq : public Compare {
143 public:
144  LessEq() : Compare() {}
145  LessEq(const Variable& v1, const Variable& v2) : Compare(v1, v2) {}
146  LessEq(const LessEq& e) : Compare(e) {}
147 
148  virtual ~LessEq();
149 
150 protected:
151 
152  virtual bool bool_cmp(const bool b1, const bool b2);
153  virtual bool int_cmp(const int i1, const int i2);
154  virtual bool double_cmp(const double d1, const double d2);
155  virtual bool string_cmp(const std::string& s1, const std::string& s2);
156 };
157 
158 }} // namespace varconf::dynvar
159 
160 #endif
Definition: dyncmp.h:38
Definition: dyncmp.h:78
Definition: dyncmp.h:94
Definition: dyncmp.h:110
Definition: dyncmp.h:62
Definition: variable.h:149
Definition: dynbase.h:37
Definition: config.cpp:96
Definition: dyncmp.h:142
Definition: dyncmp.h:126