testresources.cpp
#include <kdebug.h>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include "resource.h"
#include "manager.h"
using namespace KRES;
class TestResource : public Resource
{
public:
TestResource() : Resource( 0 ) {}
};
class TestSubResource : public TestResource
{
public:
TestSubResource() : TestResource() {}
void dump() const
{
kdDebug() << "TestSubResource" << endl;
TestResource::dump();
}
};
int main( int argc, char **argv )
{
KAboutData aboutData( "testresources", "Kresource Test", "0" );
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication app;
Manager<TestResource> manager( "test" );
TestResource *resource1 = new TestResource;
resource1->setResourceName( "One" );
manager.add( resource1 );
TestResource *resource2 = new TestSubResource;
resource2->setResourceName( "Two" );
manager.add( resource2 );
TestResource *resource3 = new TestSubResource;
resource3->setResourceName( "Three" );
manager.add( resource3 );
kdDebug() << "LIST ALL:" << endl;
Manager<TestResource>::Iterator it;
for( it = manager.begin(); it != manager.end(); ++it ) {
(*it)->dump();
}
resource2->setActive( false );
resource3->setActive( true );
kdDebug() << "LIST ACTIVE" << endl;
Manager<TestResource>::ActiveIterator it2;
for( it2 = manager.activeBegin(); it2 != manager.activeEnd(); ++it2 ) {
(*it2)->dump();
}
resource1->setActive( false );
resource2->setActive( true );
resource3->setActive( true );
kdDebug() << "LIST ACTIVE" << endl;
for( it2 = manager.activeBegin(); it2 != manager.activeEnd(); ++it2 ) {
(*it2)->dump();
}
kdDebug() << "LIST ALL" << endl;
for( it = manager.begin(); it != manager.end(); ++it ) {
(*it)->dump();
}
}
KRES::Resource::dump
virtual void dump() const
Print resource information as debug output.
Definition: resource.cpp:173
KRES::Manager::Iterator
Iterator for iterations over all resources managed by a manager.
Definition: manager.h:85
KRES::Manager::ActiveIterator
Iterator for iterations over only active resources managed by a manager.
Definition: manager.h:127
KRES::Resource
This class provides a resource which is managed in a general way.
Definition: resource.h:255
KRES::Manager
This class provides a manager for resources of a specified family.
Definition: manager.h:79

KDE Home | KDE Accessibility Home | Description of Access Keys