2
* This file is part of Soprano Project.
4
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
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
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public License
17
* along with this library; see the file COPYING.LIB. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
24
#include "inferenceruleset.h"
25
#include "inferencerule.h"
26
#include "inferenceruleparser.h"
28
#include <QtCore/QHash>
29
#include <QtCore/QList>
32
class Soprano::Inference::RuleSet::Private : public QSharedData
35
QHash<QString, Rule> ruleMap;
36
mutable QList<Rule> rules;
40
Soprano::Inference::RuleSet::RuleSet()
46
Soprano::Inference::RuleSet::RuleSet( const RuleSet& other )
51
Soprano::Inference::RuleSet::~RuleSet()
56
Soprano::Inference::RuleSet& Soprano::Inference::RuleSet::operator=( const RuleSet& other )
63
void Soprano::Inference::RuleSet::insert( const QString& name, const Rule& rule )
65
d->ruleMap[name] = rule;
70
int Soprano::Inference::RuleSet::count() const
72
return d->ruleMap.count();
76
Soprano::Inference::Rule Soprano::Inference::RuleSet::at( int index ) const
78
if ( d->rules.isEmpty() ) {
79
d->rules = d->ruleMap.values();
81
return d->rules.at( index );
85
Soprano::Inference::Rule Soprano::Inference::RuleSet::operator[]( int index ) const
91
Soprano::Inference::Rule Soprano::Inference::RuleSet::rule( const QString& name ) const
93
return d->ruleMap[name];
97
Soprano::Inference::Rule Soprano::Inference::RuleSet::operator[]( const QString& name ) const
103
QList<Soprano::Inference::Rule> Soprano::Inference::RuleSet::allRules() const
105
if ( d->rules.isEmpty() ) {
106
d->rules = d->ruleMap.values();
112
void Soprano::Inference::RuleSet::clear()
119
QStringList Soprano::Inference::RuleSet::ruleNames() const
121
return d->ruleMap.keys();
125
Soprano::Inference::RuleSet Soprano::Inference::RuleSet::standardRuleSet( StandardRuleSet set )
127
QString path( SOPRANO_PREFIX );
128
path += "/share/soprano/rules/";
132
path += "rdfs.rules";
140
parser.parseFile( path );
141
return parser.rules();