This file is indexed.

/usr/include/soprano/inferencerule.h is in libsoprano-dev 2.9.4+dfsg-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
 * This file is part of Soprano Project.
 *
 * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef _SOPRANO_INFERENCE_RULE_H_
#define _SOPRANO_INFERENCE_RULE_H_

#include <QtCore/QSharedDataPointer>
#include <QtCore/QList>

#include "statementpattern.h"
#include "statement.h"
#include "soprano_export.h"


namespace Soprano {

    class BindingSet;

    namespace Inference {

        /**
         * \class Rule inferencerule.h Soprano/Inference/Rule
         *
         * \brief A rule used by the InferenceModel to generate inferenced statements.
         *
         * Rules can be created manually by adding preconditions and the effect via addPrecondition() and
         * setEffect() or from a rules file through the RuleParser.
         *
         * \author Sebastian Trueg <trueg@kde.org>
         */
        class SOPRANO_EXPORT Rule
        {
        public:
            /**
             * Constructs an invalid rule
             */
            Rule();

            /**
             * Copy constructor. Creates a shallow copy of \p other.
             */
            Rule( const Rule& other );

            /**
             * Destructor
             */
            ~Rule();

            /**
             * Assignment operator. Creates a shallow copy of \p other.
             */
            Rule& operator=( const Rule& other );

            /**
             * The list of preconditions for the rule. Each condition
             * is a StatementPattern which can contain variables.
             * These variables are identified by their name and matched
             * accordingly.
             */
            QList<StatementPattern> preconditions() const;

            /**
             * Add a precondition
             */
            void addPrecondition( const StatementPattern& );

            /**
             * The effect of a rule is a pattern that repeats variables from
             * the preconditions and thus, identifies the statements that
             * are to be infered from the preconditions.
             */
            StatementPattern effect() const;

            /**
             * Set the effect of the rule.
             */
            void setEffect( const StatementPattern& );

            /**
             * Check if a statement matches any of the statement patterns
             * in this rule.
             *
             * \return true if statement matches any of the patterns, false otherwise.
             * Be aware that createSparqlQuery() might still return an empty string
             * since it does perform some aditional optimization checks based on the
             * bound statement.
             */
            bool match( const Statement& statement ) const;

            /**
             * Bind this rule to a specific Statement.
             *
             * The purpose of this method is to allow retricting the application of
             * a rule to one statement, i.e. a newly added one.
             *
             * \param statement The Statement to bind this rule to.
             *
             * \sa createSparqlQuery, bindEffect, bindPreconditions
             */
            void bindToStatement( const Statement& statement );

            /**
             * \return The statement set ia bindToStatement() or
             * an invalid one if none was set.
             */
            Statement boundToStatement() const;

            /**
             * Create a SPARQL query that retrieves all resources matching this rule.
             *
             * \param bindVariables If true and a valid binding statement is set the query
             * will be bound to this statement resulting in a UNION query of all possible
             * bindings.
             *
             * \return A full SPARQL query or an empty string if this rule does not apply
             * to the statement set via bindToStatement.
             *
             * \sa bindToStatement
             */
            QString createSparqlQuery( bool bindVariables = false ) const;

            /**
             * Bind the rule's effect to a set of bindings as reveived from a query.
             * If the bindings do not contain all variables the bound statement is used as backup.
             *
             * \param bindings The bindings to apply to this rule.
             *
             * \return The statement infered by this rule under the application of bindings.
             *
             * \sa bindToStatement, bindPreconditions
             */
            Statement bindEffect( const BindingSet& bindings ) const;

            /**
             * Bind the rule's preconditions to a set of bindings as reveived from a query.
             * If the bindings do not contain all variables the bound statement is used as backup.
             *
             * \param bindings The bindings to apply to this rule.
             *
             * \return The statements that have to be valid in order for this rule to infer the statement
             * returned by bindEffect under the same bindings.
             *
             * \sa bindToStatement, bindEffect
             */
            QList<Statement> bindPreconditions( const BindingSet& bindings ) const;

            /**
             * Check if a rule is valid.
             *
             * \return \p true if the rule is valid and can be used with the InferenceModel,
             * \p false otherwise.
             *
             * \since 2.3
             */
            bool isValid() const;

        private:
            /**
             * Merges in binding information from the bindingStatement by matching it to the preconditions.
             * This is necessary for optimized queries.
             */
            BindingSet mergeBindingStatement( const BindingSet& bindings ) const;
            Statement bindStatementPattern( const StatementPattern& pattern, const BindingSet& bindings ) const;

            class Private;
            QSharedDataPointer<Private> d;
        };
    }
}

SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Inference::Rule& );

#endif