Debian Codegraph @

Kernel/tLabeller.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 TLABELLER_H
21 #define TLABELLER_H
22
23 #include "fpp_assert.h"
24 #include "tCounter.h"
25
26 /** define class that implements support for labelling entries with
27 * cheap 'unselect' operation. An external entity is 'marked' iff
28 * it's value equal to the internal counter.
29 */
30 class TLabeller
31 {
32 private: // internal type definition
33 /// type of a counter
34 typedef TCounter<unsigned int> LabelCounter;
35
36 public: // type interface
37 /// define integral type of a label
38 typedef LabelCounter::IntType LabelType;
39
40 protected: // members
41 /// counter
42 LabelCounter counter{1};
43
44 public: // interface
45
46 // operations with Labeller
47
48 /// create a new label value
49 void newLabel ( void )
50 {
51 counter.inc();
52 fpp_assert ( counter.val() != 0 );
53 }
54
55 // operations with Labels
56
57 /// set given label's value to the counter's one
58 void set ( LabelType& lab ) const { lab = counter.val(); }
59 /// clear given label's value (independent of a labeller)
60 static void clear ( LabelType& lab ) { lab = 0; }
61 /// check if given label is labelled
62 bool isLabelled ( const LabelType& lab ) const { return (lab == counter.val()); }
63 }; // TLabeller
64
65 #endif