summaryrefslogtreecommitdiffstats
path: root/tderesources/testresources.cpp
blob: 515563172cbeadff63357539a630c746cc05cd53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#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 )
{
  TDEAboutData aboutData( "testresources", "Kresource Test", "0" );
  TDECmdLineArgs::init( argc, argv, &aboutData );

  TDEApplication 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();
  }


}