25 #include <tdeapplication.h>
26 #include <tdeconfig.h>
27 #include <tdelocale.h>
32 class Resource::ResourcePrivate
35 #ifdef TQT_THREAD_SUPPORT
48 : TQObject( 0,
"" ), d( new ResourcePrivate )
54 d->mType = config->readEntry(
"ResourceType" );
55 d->mName = config->readEntry(
"ResourceName" );
56 d->mReadOnly = config->readBoolEntry(
"ResourceIsReadOnly",
false );
57 d->mActive = config->readBoolEntry(
"ResourceIsActive",
true );
58 d->mIdentifier = config->readEntry(
"ResourceIdentifier" );
61 d->mName = i18n(
"resource");
64 d->mIdentifier = TDEApplication::randomString( 10 );
76 kdDebug(5650) <<
"Resource::writeConfig()" << endl;
78 config->writeEntry(
"ResourceType", d->mType );
79 config->writeEntry(
"ResourceName", d->mName );
80 config->writeEntry(
"ResourceIsReadOnly", d->mReadOnly );
81 config->writeEntry(
"ResourceIsActive", d->mActive );
82 config->writeEntry(
"ResourceIdentifier", d->mIdentifier );
88 #ifdef TQT_THREAD_SUPPORT
89 TQMutexLocker guard( &(d->mMutex) );
91 if ( !d->mOpenCount ) {
92 kdDebug(5650) <<
"Opening resource " <<
resourceName() << endl;
101 #ifdef TQT_THREAD_SUPPORT
102 TQMutexLocker guard( &(d->mMutex) );
104 if ( !d->mOpenCount ) {
105 kdDebug(5650) <<
"ERROR: Resource " <<
resourceName() <<
" closed more times than previously opened" << endl;
109 if ( !d->mOpenCount ) {
110 kdDebug(5650) <<
"Closing resource " <<
resourceName() << endl;
114 kdDebug(5650) <<
"Not yet closing resource " <<
resourceName() <<
", open count = " << d->mOpenCount << endl;
123 void Resource::setIdentifier(
const TQString& identifier )
130 return d->mIdentifier;
133 void Resource::setType(
const TQString& type )
145 d->mReadOnly = value;
175 kdDebug(5650) <<
"Resource:" << endl;
176 kdDebug(5650) <<
" Name: " << d->mName << endl;
177 kdDebug(5650) <<
" Identifier: " << d->mIdentifier << endl;
178 kdDebug(5650) <<
" Type: " << d->mType << endl;
179 kdDebug(5650) <<
" OpenCount: " << d->mOpenCount << endl;
180 kdDebug(5650) <<
" ReadOnly: " << ( d->mReadOnly ?
"yes" :
"no" ) << endl;
181 kdDebug(5650) <<
" Active: " << ( d->mActive ?
"yes" :
"no" ) << endl;
182 kdDebug(5650) <<
" IsOpen: " << ( d->mIsOpen ?
"yes" :
"no" ) << endl;
185 #include "resource.moc"
virtual void setReadOnly(bool value)
Mark the resource as read-only.
bool open()
Open this resource, if it not already open.
virtual ~Resource()
Destructor.
bool isOpen() const
Returns whether the resource is open or not.
virtual void doClose()
Close this resource.
virtual void dump() const
Print resource information as debug output.
virtual void setResourceName(const TQString &name)
Set the name of resource.
bool isActive() const
Return true, if the resource is active.
virtual void writeConfig(TDEConfig *config)
Write configuration information for this resource to a configuration file.
TQString type() const
Returns the type of this resource.
virtual bool readOnly() const
Returns, if the resource is read-only.
void close()
Decrease the open count of this object, and if the count reaches zero, close this resource by calling...
virtual bool doOpen()
Open this resource.
Resource(const TDEConfig *config)
Constructor.
void setActive(bool active)
Sets, if the resource is active.
TQString identifier() const
Returns a unique identifier.
virtual TQString resourceName() const
Returns the name of resource.