home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kinstance.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.3 KB  |  160 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 1999 Torben Weis <weis@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef _KINSTANCE_H
  19. #define _KINSTANCE_H
  20.  
  21. class KStandardDirs;
  22. class KAboutData;
  23. class KConfig;
  24. class KIconLoader;
  25. class KCharsets;
  26. class QFont;
  27. class KInstancePrivate;
  28. class KMimeSourceFactory;
  29. class KSharedConfig;
  30.  
  31. #include <qstring.h>
  32. #include "kdelibs_export.h"
  33.  
  34.  
  35. /**
  36.  * Access to KDE global objects for use in shared libraries.  In
  37.  * practical terms, this class is used in KDE components.  This allows
  38.  * components to store things that normally would be accessed by
  39.  * KGlobal.
  40.  *
  41.  * @author Torben Weis
  42.  */
  43. class KDECORE_EXPORT KInstance
  44. {
  45.     friend class KStandardDirs;
  46.  
  47.  public:
  48.     /**
  49.      *  Constructor.
  50.      *  @param instanceName the name of the instance
  51.      */
  52.     KInstance( const QCString& instanceName) ;
  53.  
  54.     /**
  55.      *  Constructor.
  56.      *  When building a KInstance that is not your KApplication,
  57.      *  make sure that the KAboutData and the KInstance have the same life time.
  58.      *  You have to destroy both, since the instance doesn't own the about data.
  59.      *  Don't build a KAboutData on the stack in this case !
  60.      *  Building a KAboutData on the stack is only ok for usage with
  61.      *  KCmdLineArgs and KApplication (not destroyed until the app exits).
  62.      *  @param aboutData data about this instance (see KAboutData)
  63.      */
  64.     KInstance( const KAboutData * aboutData );
  65.  
  66.     /*
  67.      * @internal
  68.      * Only for K(Unique)Application
  69.      * Initialize from src and delete it.
  70.      */
  71.      
  72.     KInstance( KInstance* src );
  73.  
  74.     /**
  75.      * Destructor.
  76.      */
  77.     virtual ~KInstance();
  78.  
  79.     /**
  80.      * Returns the application standard dirs object.
  81.      * @return The KStandardDirs of the application.
  82.      */
  83.     KStandardDirs    *dirs() const;
  84.  
  85.     /**
  86.      * Returns the general config object ("appnamerc").
  87.      * @return the KConfig object for the instance.
  88.      */
  89.     KConfig            *config() const;
  90.  
  91.     /**
  92.      * Returns the general config object ("appnamerc").
  93.      * @return the KConfig object for the instance.
  94.      */
  95.     KSharedConfig      *sharedConfig() const;
  96.  
  97.     /**
  98.      *  Returns an iconloader object.
  99.      * @return the iconloader object.
  100.      */
  101.     KIconLoader           *iconLoader() const;
  102.  
  103.     /**
  104.      * Re-allocate the global iconloader.
  105.      */
  106.     void newIconLoader() const;
  107.  
  108.     /**
  109.      *  Returns the about data of this instance
  110.      *  Warning, can be 0L
  111.      * @return the about data of the instance, or 0 if it has 
  112.      *         not been set yet
  113.      */
  114.     const KAboutData *aboutData() const;
  115.  
  116.     /**
  117.      * Returns the name of the instance
  118.      * @return the instance name, can be null if the KInstance has been 
  119.      *         created with a null name
  120.      */
  121.     QCString          instanceName() const;
  122.  
  123.     /**
  124.      * Returns the KMimeSourceFactory of the instance.
  125.      * Mainly added for API completeness and future extensibility.
  126.      * @return the KMimeSourceFactory set as default for this application.
  127.      */
  128.     KMimeSourceFactory* mimeSourceFactory () const;
  129.  
  130. protected:
  131.     /**
  132.      *  Copy Constructor is not allowed
  133.      */
  134.     KInstance( const KInstance& );
  135.  
  136.     /**
  137.      * Set name of default config file.
  138.      * @param name the name of the default config file
  139.      * @since 3.1
  140.      */
  141.     void setConfigName(const QString &name);
  142.  
  143. private:
  144.     mutable KStandardDirs       *_dirs;
  145.  
  146.     mutable KConfig             *_config;
  147.     mutable KIconLoader         *_iconLoader;
  148.  
  149.     QCString                     _name;
  150.     const KAboutData            *_aboutData;
  151.  
  152. protected:
  153.     virtual void virtual_hook( int id, void* data );
  154. private:
  155.     KInstancePrivate *d;
  156. };
  157.  
  158. #endif
  159.  
  160.