29 #include <klocalizedstring.h>
30 #include <kconfiggroup.h>
34 class Resource::ResourcePrivate
37 #ifdef QT_THREAD_SUPPORT
73 :
QObject( 0 ), d( new ResourcePrivate )
79 d->mName = i18n(
"resource" );
82 d->mIdentifier = KRandom::randomString( 10 );
86 :
QObject( 0 ), d( new ResourcePrivate )
91 d->mType = group.readEntry(
"ResourceType" );
92 d->mName = group.readEntry(
"ResourceName" );
93 d->mReadOnly = group.readEntry(
"ResourceIsReadOnly",
false );
94 d->mActive = group.readEntry(
"ResourceIsActive",
true );
95 d->mIdentifier = group.readEntry(
"ResourceIdentifier" );
107 group.writeEntry(
"ResourceType", d->mType );
108 group.writeEntry(
"ResourceName", d->mName );
109 group.writeEntry(
"ResourceIsReadOnly", d->mReadOnly );
110 group.writeEntry(
"ResourceIsActive", d->mActive );
111 group.writeEntry(
"ResourceIdentifier", d->mIdentifier );
117 #ifdef QT_THREAD_SUPPORT
120 if ( !d->mOpenCount ) {
130 #ifdef QT_THREAD_SUPPORT
133 if ( !d->mOpenCount ) {
135 <<
" closed more times than previously opened";
139 if ( !d->mOpenCount ) {
144 kDebug() <<
"Not yet closing resource" <<
resourceName()
145 <<
", open count =" << d->mOpenCount;
161 return d->mIdentifier;
176 d->mReadOnly = value;
206 kDebug() <<
"Resource:";
207 kDebug() <<
" Name:" << d->mName;
208 kDebug() <<
" Identifier:" << d->mIdentifier;
209 kDebug() <<
" Type:" << d->mType;
210 kDebug() <<
" OpenCount:" << d->mOpenCount;
211 kDebug() <<
" ReadOnly:" << ( d->mReadOnly ?
"yes" :
"no" );
212 kDebug() <<
" Active:" << ( d->mActive ?
"yes" :
"no" );
213 kDebug() <<
" IsOpen:" << ( d->mIsOpen ?
"yes" :
"no" );
226 const char *className,
230 Q_UNUSED( className );
virtual void writeConfig(KConfigGroup &group)
Write configuration information for this resource to a configuration file.
virtual void doClose()
Close this resource.
bool open()
Open this resource, if it not already open.
virtual void dump() const
Print resource information as debug output.
void setType(const QString &type)
Sets the resource type.
virtual ~Resource()
Destructor.
const char * name() const
void setIdentifier(const QString &identifier)
Sets the resource unique identifier.
QString identifier() const
Returns a unique identifier.
bool isActive() const
Return true, if the resource is active.
QString type() const
Returns the type of this resource.
virtual bool readOnly() const
Returns, if the resource is read-only.
virtual void setResourceName(const QString &name)
Set the name of resource.
virtual QString resourceName() const
Returns the name of resource.
void setActive(bool active)
Sets, if the resource is active.
bool isOpen() const
Returns whether the resource is open or not.
virtual bool doOpen()
Open this resource.
virtual void setReadOnly(bool value)
Mark the resource as read-only.
void close()
Decrease the open count of this object, and if the count reaches zero, close this resource by calling...