File: LogicFeature.h

package info (click to toggle)
fact%2B%2B 1.6.5~dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 4,496 kB
  • sloc: cpp: 28,000; java: 22,674; xml: 3,268; makefile: 102; ansic: 61; sh: 3
file content (126 lines) | stat: -rw-r--r-- 4,253 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* This file is part of the FaCT++ DL reasoner
Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester
Copyright (C) 2015-2016 Dmitry Tsarkov

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef LOGICFEATURE_H
#define LOGICFEATURE_H

class TConcept;
class TRole;
class DLVertex;

// contains class for currently used logic's features
class LogicFeatures
{
protected:	// types
	enum lfEnum {
		lfInvalid = 0,
		// role description
		lfTransitiveRoles	= (1 << 0),
		lfRolesSubsumption	= (1 << 1),
		lfDirectRoles		= (1 << 2),
		lfInverseRoles		= (1 << 3),
		lfRangeAndDomain	= (1 << 4),
		lfFunctionalRoles	= (1 << 5),

		// concept description
		lfSomeConstructor	= (1 << 6),
		lfFConstructor		= (1 << 7),
		lfNConstructor		= (1 << 8),
		lfQConstructor		= (1 << 9),
		lfSingleton			= (1 << 10),

		// global description
		lfGeneralAxioms		= (1 << 11),
		lfBothRoles			= (1 << 12),

		// new constructions
		lfSelfRef			= (1 << 13),
		lfTopRole			= (1 << 14),
	};

protected:	// members
		/// all flags in one long
	unsigned long flags;

protected:	// methods
		/// set any flag
	void setX ( lfEnum val ) { flags |= val; }
		/// get value of any flag
	bool getX ( lfEnum val ) const { return !!(flags&val); }

public:		// interface
		/// default c'tor
	LogicFeatures ( void )
		: flags(0)
		{}
		/// copy c'tor
	LogicFeatures ( const LogicFeatures& lf ) : flags(lf.flags) {}
		/// assignment
	LogicFeatures& operator = ( const LogicFeatures& lf ) { flags = lf.flags; return *this; }
		/// operator add
	LogicFeatures& operator |= ( const LogicFeatures& lf ) { flags |= lf.flags; return *this; }
		/// d'tor
	~LogicFeatures ( void ) {}

//	bool hasInverseRole ( void ) const { return getX(lfDirectRoles) && getX(lfInverseRoles); }
	bool hasInverseRole ( void ) const { return getX(lfBothRoles); }
	bool hasRoleHierarchy ( void ) const { return getX(lfRolesSubsumption); }
	bool hasTransitiveRole ( void ) const  { return getX(lfTransitiveRoles); }
	bool hasSomeAll ( void ) const  { return getX(lfSomeConstructor); }
	bool hasFunctionalRestriction ( void ) const { return getX(lfFConstructor) || getX(lfFunctionalRoles); }
	bool hasNumberRestriction ( void ) const { return getX(lfNConstructor); }
	bool hasQNumberRestriction ( void ) const { return getX(lfQConstructor); }
	bool hasSingletons ( void ) const { return getX(lfSingleton); }
	bool hasSelfRef ( void ) const { return getX(lfSelfRef); }
	bool hasTopRole ( void ) const { return getX(lfTopRole); }

	// overall state

		/// check whether no flags are set
	bool empty ( void ) const { return flags == 0; }
		/// get all the flags at once
	unsigned long getAllFlags ( void ) const { return flags; }
		/// set all flags to a given value; @return old value of the flags
	unsigned long setAllFlags ( unsigned long value ) { unsigned long old = flags; flags = value; return old; }
		/// clear all the flags
	void clear ( void ) { setAllFlags(0); }

	// collect statistic from different things

		/// get features from given TConcept
	void fillConceptData ( const TConcept* p );
		/// get features from given TRole
	void fillRoleData ( const TRole* p, bool both );
		/// get features from given DAG entry with given sign
	void fillDAGData ( const DLVertex& v, bool pos );

		/// build bothRoles from single Roles flags
	void mergeRoles ( void )
	{
		if ( getX(lfDirectRoles) && getX(lfInverseRoles) )
			setX(lfBothRoles);
	}
		/// allow user to set presence of inverse roles
	void setInverseRoles ( void ) { setX(lfBothRoles); }

		/// write gathered features
	void writeState ( void ) const;
}; // LogicFeatures

#endif