managerimpl.h
00001 /* 00002 This file is part of libkresources. 00003 00004 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 00005 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 00006 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public License 00019 along with this library; see the file COPYING.LIB. If not, write to 00020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 Boston, MA 02110-1301, USA. 00022 */ 00023 #ifndef KRESOURCES_MANAGERIMPL_H 00024 #define KRESOURCES_MANAGERIMPL_H 00025 00026 #include <tqstring.h> 00027 #include <tqptrlist.h> 00028 #include <tqdict.h> 00029 00030 #include "manageriface.h" 00031 #include <kresources/resource.h> 00032 00033 class KConfig; 00034 00035 namespace KRES { 00036 00037 class Resource; 00038 class Factory; 00039 class ManagerNotifier; 00040 00046 class KRESOURCES_EXPORT ManagerImpl : virtual public ManagerIface 00047 { 00048 public: 00049 ManagerImpl( ManagerNotifier *, const TQString &family ); 00050 ~ManagerImpl(); 00051 00052 void readConfig( KConfig * ); 00053 void writeConfig( KConfig * ); 00054 00055 void add( Resource *resource ); 00056 void remove( Resource *resource ); 00057 void change( Resource *resource ); 00058 00059 Resource *standardResource(); 00060 void setStandardResource( Resource *resource ); 00061 00062 void setActive( Resource *resource, bool active ); 00063 00064 Resource::List *resourceList(); 00065 00066 TQPtrList<Resource> resources(); 00067 00068 // Get only active or passive resources 00069 TQPtrList<Resource> resources( bool active ); 00070 00071 TQStringList resourceNames(); 00072 00073 static TQString defaultConfigFile( const TQString &family ); 00074 00075 private: 00076 // dcop calls 00077 void dcopKResourceAdded( TQString managerId, TQString resourceId ); 00078 void dcopKResourceModified( TQString managerId, TQString resourceId ); 00079 void dcopKResourceDeleted( TQString managerId, TQString resourceId ); 00080 00081 private: 00082 void createStandardConfig(); 00083 00084 Resource *readResourceConfig( const TQString& identifier, bool checkActive ); 00085 void writeResourceConfig( Resource *resource, bool checkActive ); 00086 00087 void removeResource( Resource *resource ); 00088 Resource *getResource( Resource *resource ); 00089 Resource *getResource( const TQString& identifier ); 00090 00091 ManagerNotifier *mNotifier; 00092 TQString mFamily; 00093 KConfig *mConfig; 00094 KConfig *mStdConfig; 00095 Resource *mStandard; 00096 Factory *mFactory; 00097 Resource::List mResources; 00098 TQString mId; 00099 bool mConfigRead; 00100 00101 class ManagerImplPrivate; 00102 ManagerImplPrivate *d; 00103 }; 00104 00105 } 00106 00107 #endif