1 | /* This file is part of the Nepomuk-KDE libraries |
2 | Copyright (c) 2007 Sebastian Trueg <trueg@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef _NEPOMUK2_ONTOLOGY_H_ |
21 | #define _NEPOMUK2_ONTOLOGY_H_ |
22 | |
23 | #include <QtCore/QList> |
24 | #include <QtCore/QUrl> |
25 | #include <QtCore/QString> |
26 | #include <QtCore/QSharedData> |
27 | |
28 | #include "entity.h" |
29 | #include "nepomuk_export.h" |
30 | |
31 | |
32 | namespace Nepomuk2 { |
33 | namespace Types { |
34 | |
35 | class Class; |
36 | class Property; |
37 | |
38 | /** |
39 | * \class Ontology ontology.h Nepomuk2/Types/Ontology |
40 | * |
41 | * \brief Represents one ontology. |
42 | * |
43 | * \author Sebastian Trueg <trueg@kde.org> |
44 | */ |
45 | class NEPOMUK_EXPORT Ontology : public Entity |
46 | { |
47 | public: |
48 | /** |
49 | * Default constructor. Creates an empty Ontology. |
50 | */ |
51 | Ontology(); |
52 | |
53 | /** |
54 | * Create the ontology referred to by \p uri. |
55 | * The result is either a valid ontology which could be loaded from the |
56 | * Nepomuk store or a simple class which only contains the uri. |
57 | * |
58 | * Be aware that the data is only loaded once read. |
59 | * |
60 | * Subsequent calls result in a simple hash lookup of cached data. |
61 | */ |
62 | Ontology( const QUrl& uri ); |
63 | |
64 | /** |
65 | * Default copy constructor |
66 | */ |
67 | Ontology( const Ontology& ); |
68 | |
69 | /** |
70 | * Destructor |
71 | */ |
72 | ~Ontology(); |
73 | |
74 | Ontology& operator=( const Ontology& ); |
75 | |
76 | /** |
77 | * All classes defined in this ontology, i.e. its namespace. |
78 | */ |
79 | QList<Class> allClasses(); |
80 | |
81 | /** |
82 | * Search for a class in the ontology by its name. |
83 | * \param name The name of the class. |
84 | * \return the Class object identified by name or an invalid one if the class could not be found. |
85 | */ |
86 | Class findClassByName( const QString& name ); |
87 | |
88 | /** |
89 | * Search for a class in the ontology by its label. |
90 | * \param label The label of the class (i.e. rdfs:label) |
91 | * \param language The language in which the label was specified. If empty the default rdfs:label |
92 | * is returned. |
93 | * \return the Class object identified by label or an invalid one if the class could not be found. |
94 | */ |
95 | Class findClassByLabel( const QString& label, const QString& language = QString() ); |
96 | |
97 | /** |
98 | * A list of all properties defined in this ontology. This does not include properties that use |
99 | * classes of this ontology but are defined in a different one. |
100 | */ |
101 | QList<Property> allProperties(); |
102 | |
103 | /** |
104 | * Search for a property in the ontology by its name. |
105 | * \param name The name of the property. |
106 | * \return the Property object identified by name or an invalid one if the property could not be found. |
107 | */ |
108 | Property findPropertyByName( const QString& name ); |
109 | |
110 | /** |
111 | * Search for a property in the ontology by its label. |
112 | * \param label The label of the property (i.e. rdfs:label) |
113 | * \param language The language in which the label was specified. If empty the default rdfs:label |
114 | * is returned. |
115 | * \return the Property object identified by label or an invalid one if the property could not be found. |
116 | */ |
117 | Property findPropertyByLabel( const QString& label, const QString& language = QString() ); |
118 | }; |
119 | } |
120 | } |
121 | |
122 | #endif |
123 | |