• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • rcgen
resourceclass.cpp
Go to the documentation of this file.
1 /*
2  *
3  * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
4  *
5  * This file is part of the Nepomuk KDE project.
6  * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
7  *
8  * This library is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * See the file "COPYING.LIB" for the exact licensing terms.
13  */
14 
15 #include "resourceclass.h"
16 
17 #include <QtCore/QRegExp>
18 
19 #include <Soprano/Vocabulary/RDFS>
20 
21 ResourceClass::ResourceClass()
22  : m_parentClass( 0 ),
23  m_generateClass( false )
24 {
25 }
26 
27 ResourceClass::ResourceClass( const QUrl& uri )
28  : m_uri( uri ),
29  m_parentClass( 0 ),
30  m_generateClass( false )
31 {
32 }
33 
34 ResourceClass::~ResourceClass()
35 {
36 }
37 
38 void ResourceClass::setUri( const QUrl &uri )
39 {
40  m_uri = uri;
41 }
42 
43 QUrl ResourceClass::uri() const
44 {
45  return m_uri;
46 }
47 
48 void ResourceClass::setComment( const QString &comment )
49 {
50  m_comment = comment;
51 }
52 
53 QString ResourceClass::comment() const
54 {
55  return m_comment;
56 }
57 
58 void ResourceClass::setParentResource( ResourceClass* parent )
59 {
60  m_parentClass = parent;
61 }
62 
63 ResourceClass* ResourceClass::parentClass( bool considerGenerateClass ) const
64 {
65  ResourceClass* parent = m_parentClass;
66  if( considerGenerateClass && !parent->generateClass() ) {
67  // first check for another "top-level" parent class to be generated
68  foreach( ResourceClass* rc, m_allParentResources ) {
69  if( rc->generateClass() &&
70  rc->uri() != Soprano::Vocabulary::RDFS::Resource() ) {
71  return rc;
72  }
73  }
74  // nothing found -> just use the first
75  while( !parent->generateClass() &&
76  parent->uri() != Soprano::Vocabulary::RDFS::Resource() )
77  parent = parent->parentClass();
78  }
79  return parent;
80 }
81 
82 void ResourceClass::addParentResource( ResourceClass* parent )
83 {
84  m_allParentResources.append( parent );
85 }
86 
87 QList<ResourceClass*> ResourceClass::allParentResources() const
88 {
89  return m_allParentResources;
90 }
91 
92 void ResourceClass::addProperty( Property* property )
93 {
94  m_properties.append( property );
95 }
96 
97 Property::ConstPtrList ResourceClass::allProperties() const
98 {
99  return m_properties;
100 }
101 
102 void ResourceClass::addReverseProperty( Property* property )
103 {
104  m_reverseProperties.append( property );
105 }
106 
107 Property::ConstPtrList ResourceClass::allReverseProperties() const
108 {
109  return m_reverseProperties;
110 }
111 
112 void ResourceClass::setGenerateClass( bool generate )
113 {
114  m_generateClass = generate;
115 }
116 
117 bool ResourceClass::generateClass() const
118 {
119  return m_generateClass;
120 }
121 
122 QString ResourceClass::name( const QString &nameSpace ) const
123 {
124  QString s = m_uri.toString().section( QRegExp( "[#/:]" ), -1 );
125  if( !nameSpace.isEmpty() )
126  s.prepend( nameSpace + "::" );
127  return s;
128 }
129 
130 QString ResourceClass::headerName() const
131 {
132  return name().toLower() + ".h";
133 }
134 
135 QString ResourceClass::sourceName() const
136 {
137  return name().toLower() + ".cpp";
138 }
resourceclass.h
ResourceClass::addProperty
void addProperty(Property *property)
Adds a new property to the resource.
Definition: resourceclass.cpp:92
ResourceClass::setUri
void setUri(const QUrl &uri)
Sets the uri of the resource.
Definition: resourceclass.cpp:38
ResourceClass::ResourceClass
ResourceClass()
Definition: resourceclass.cpp:21
ResourceClass::~ResourceClass
~ResourceClass()
Definition: resourceclass.cpp:34
ResourceClass::uri
QUrl uri() const
Returns the uri of the resource.
Definition: resourceclass.cpp:43
ResourceClass::generateClass
bool generateClass() const
Returns true if this class should be generated.
Definition: resourceclass.cpp:117
ResourceClass::parentClass
ResourceClass * parentClass(bool considerGenerateClass=true) const
Returns the parent resource of the resource.
Definition: resourceclass.cpp:63
ResourceClass::allProperties
Property::ConstPtrList allProperties() const
Returns the list of all properties of the resource.
Definition: resourceclass.cpp:97
Property::ConstPtrList
QList< const Property * > ConstPtrList
Definition: rcgen/property.h:32
ResourceClass
Represents a resource.
Definition: resourceclass.h:30
ResourceClass::comment
QString comment() const
Returns the comment of the resource.
Definition: resourceclass.cpp:53
ResourceClass::allReverseProperties
Property::ConstPtrList allReverseProperties() const
Returns the list of all reverse properties of the resource.
Definition: resourceclass.cpp:107
ResourceClass::setGenerateClass
void setGenerateClass(bool generate)
Sets whether code for this class shall be generated.
Definition: resourceclass.cpp:112
ResourceClass::sourceName
QString sourceName() const
Returns the name of the source file for this resource.
Definition: resourceclass.cpp:135
ResourceClass::setComment
void setComment(const QString &comment)
Sets the comment of the resource.
Definition: resourceclass.cpp:48
ResourceClass::addReverseProperty
void addReverseProperty(Property *property)
Adds a reverse property to the resource.
Definition: resourceclass.cpp:102
Property
Represents the property of a resource.
Definition: rcgen/property.h:29
ResourceClass::setParentResource
void setParentResource(ResourceClass *parent)
Sets the parent resource of the resource.
Definition: resourceclass.cpp:58
ResourceClass::name
QString name(const QString &nameSpace=QString()) const
Returns the name of the resource.
Definition: resourceclass.cpp:122
ResourceClass::headerName
QString headerName() const
Returns the name of the header file for this resource.
Definition: resourceclass.cpp:130
ResourceClass::addParentResource
void addParentResource(ResourceClass *parent)
Adds a parent resource to the resource.
Definition: resourceclass.cpp:82
ResourceClass::allParentResources
QList< ResourceClass * > allParentResources() const
Returns all parent resource of the resource.
Definition: resourceclass.cpp:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal