Debian Codegraph @

FaCT++.Python/lib/Kernel/ConceptWithDep.h

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef CONCEPTWITHDEP_H
21 #define CONCEPTWITHDEP_H
22
23 #include "BiPointer.h"
24 #include "DepSet.h"
25
26 /// Concept with dependence: bipolar pointer to concept and a set of dependencies
27 class ConceptWDep
28 {
29 protected: // members
30 /// "pointer" to a concept in DAG
31 BipolarPointer Concept = bpINVALID;
32 /// dep-set for a concept
33 DepSet depSet;
34
35 public: // methods
36 /// empty c'tor
37 ConceptWDep() = default;
38 /// c'tor with empty dep-set
39 explicit ConceptWDep ( BipolarPointer p ) : Concept(p) {}
40 /// usual c'tor
41 ConceptWDep ( BipolarPointer p, const DepSet& dep ) : Concept(p), depSet(dep) {}
42 /// copy c'tor
43 ConceptWDep ( const ConceptWDep& c ) = default;
44 /// copy c'tor with additional dep-set
45 ConceptWDep ( const ConceptWDep& c, const DepSet& dep ) : Concept(c.Concept), depSet(c.depSet) { depSet.add(dep); }
46
47 // comparison
48
49 bool operator == ( const ConceptWDep& ce ) const { return Concept == ce.Concept; }
50 bool operator != ( const ConceptWDep& ce ) const { return Concept != ce.Concept; }
51 bool operator == ( BipolarPointer p ) const { return Concept == p; }
52 bool operator != ( BipolarPointer p ) const { return Concept != p; }
53
54 // access to elements
55
56 /// get bp-part
57 BipolarPointer bp ( void ) const { return Concept; }
58 /// get dep-set part
59 const DepSet& getDep ( void ) const { return depSet; }
60
61 /// create CWD with inverted body and the same dep-set
62 ConceptWDep inverse ( void ) const { return ConceptWDep ( ::inverse(Concept), getDep () ); }
63 /// add dep-set to a CWD
64 void addDep ( const DepSet& d ) { depSet.add(d); }
65
66 /// print concept and a dep-set
67 template <typename O>
68 friend O& operator << ( O& o, const ConceptWDep& c ) { o << c.Concept << c.getDep(); return o; }
69 }; // ConceptWDep
70
71 /// create an inverse of a given CWD with the same dep-set
72 inline ConceptWDep inverse ( const ConceptWDep& C ) { return ConceptWDep ( inverse(C.bp()), C.getDep() ); }
73
74 #endif // CONCEPTWITHDEP_H