Debian Codegraph @

src/internal/dependency.cpp

raw symbols SCIP
1 /*
2 * %injeqt copyright begin%
3 * Copyright 2014 Rafał Malinowski ([email protected])
4 * %injeqt copyright end%
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
21 #include "dependency.h"
22
23 #include <cassert>
24
25 namespace injeqt { namespace internal {
26
27 dependency::dependency(setter_method setter) :
28 _setter{std::move(setter)}
29 {
30 assert(!_setter.is_empty());
31 }
32
33 const type & dependency::required_type() const
34 {
35 return _setter.parameter_type();
36 }
37
38 const setter_method & dependency::setter() const
39 {
40 return _setter;
41 }
42
43 bool operator == (const dependency &x, const dependency &y)
44 {
45 if (x.setter() != y.setter())
46 return false;
47
48 return true;
49 }
50
51 bool operator != (const dependency &x, const dependency &y)
52 {
53 return !(x == y);
54 }
55
56 bool operator < (const dependency &x, const dependency &y)
57 {
58 if (x.required_type() < y.required_type())
59 return true;
60
61 if (x.required_type() > y.required_type())
62 return false;
63
64 return x.setter() < y.setter();
65 }
66
67 bool operator > (const dependency &x, const dependency &y)
68 {
69 return y < x;
70 }
71
72 bool operator <= (const dependency &x, const dependency &y)
73 {
74 return !(y < x);
75 }
76
77 bool operator >= (const dependency &x, const dependency &y)
78 {
79 return !(x < y);
80 }
81
82 }}