kresources Library API Documentation

KRES::Resource Class Reference

This class provides a resource which is managed in a general way. More...

#include <resource.h>

Inheritance diagram for KRES::Resource:

QObject List of all members.

Public Types

typedef QValueList< Resource * > List

Public Member Functions

 Resource (const KConfig *config)
virtual ~Resource ()
virtual void writeConfig (KConfig *config)
bool open ()
void close ()
bool isOpen () const
QString identifier () const
QString type () const
virtual void setReadOnly (bool value)
virtual bool readOnly () const
virtual void setResourceName (const QString &name)
virtual QString resourceName () const
void setActive (bool active)
bool isActive () const
virtual void dump () const

Protected Member Functions

virtual bool doOpen ()
virtual void doClose ()
void setIdentifier (const QString &identifier)
void setType (const QString &type)

Detailed Description

This class provides a resource which is managed in a general way.

A Resource represents the concept of an object with the following attributes:

The Resource base class provides the management functionality. Classes inheriting from Resource automatically appear in the general kresources kcontrol module.

Concrete functionality of Resources is specified per family by a subclass of Resource. This classes in turn have subclasses which implement the different flavours of the functionality represented by the family.

A subclass should reimplement at least the constructor and the writeConfig method.

An example for a Resource subclass hierarchy would be the "calendar" family. The ResourceCalendar subclass would specify an API for accessing calendar data. Subclasses of ResourceCalendar would implement this API for local files, remote files, specific calendar servers etc.

Definition at line 255 of file resource.h.


Constructor & Destructor Documentation

KRES::Resource::Resource const KConfig *  config  ) 
 

Constructor.

Construct resource from config.

Parameters:
config Configuration to read persistence information from. If config is 0, create object using default settings.

virtual KRES::Resource::~Resource  )  [virtual]
 

Destructor.


Member Function Documentation

virtual void KRES::Resource::writeConfig KConfig *  config  )  [virtual]
 

Write configuration information for this resource to a configuration file.

If you override this method, remember to call Resource::writeConfig or Terrible Things(TM) will happen.

Parameters:
config Configuration to write persistence information to.

bool KRES::Resource::open  ) 
 

Open this resource, if it not already open.

Increase the open count of this object, and open the resource by calling doOpen(). This method may block while another thread is concurrently opening or closing the resource.

Returns true if the resource was already opened or if it was opened successfully; returns false if the resource was not opened successfully.

void KRES::Resource::close  ) 
 

Decrease the open count of this object, and if the count reaches zero, close this resource by calling doClose().

This method may block while another thread is concurrently closing or opening the resource.

bool KRES::Resource::isOpen  )  const
 

Returns whether the resource is open or not.

QString KRES::Resource::identifier  )  const
 

Returns a unique identifier.

The identifier is unique for this resource. It is created when the resource is first created, and it is retained in the resource family configuration file for this resource.

Returns:
This resource's identifier

QString KRES::Resource::type  )  const
 

Returns the type of this resource.

virtual void KRES::Resource::setReadOnly bool  value  )  [virtual]
 

Mark the resource as read-only.

You can override this method, but also remember to call Resource::setReadOnly().

virtual bool KRES::Resource::readOnly  )  const [virtual]
 

Returns, if the resource is read-only.

Referenced by KRES::SelectDialog::getResource(), and KRES::SelectDialog::SelectDialog().

virtual void KRES::Resource::setResourceName const QString name  )  [virtual]
 

Set the name of resource.

You can override this method, but also remember to call Resource::setResourceName().

virtual QString KRES::Resource::resourceName  )  const [virtual]
 

Returns the name of resource.

Referenced by KRES::SelectDialog::SelectDialog().

void KRES::Resource::setActive bool  active  ) 
 

Sets, if the resource is active.

bool KRES::Resource::isActive  )  const
 

Return true, if the resource is active.

virtual void KRES::Resource::dump  )  const [virtual]
 

Print resource information as debug output.

virtual bool KRES::Resource::doOpen  )  [inline, protected, virtual]
 

Open this resource.

When called, the resource must be in a closed state.

Returns true if the resource was opened successfully; returns false if the resource was not opened successfully.

The result of this call can be accessed later by isOpen()

Definition at line 368 of file resource.h.

virtual void KRES::Resource::doClose  )  [inline, protected, virtual]
 

Close this resource.

Pre-condition: resource is open. Post-condition: resource is closed.

Definition at line 374 of file resource.h.


The documentation for this class was generated from the following file:
KDE Logo
This file is part of the documentation for kresources Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 23 17:12:40 2004 by doxygen 1.3.8-20040913 written by Dimitri van Heesch, © 1997-2003