You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
252 lines
7.3 KiB
252 lines
7.3 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 1999 Sirtaj Singh Kanq <taj@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
#ifndef _KGLOBAL_H
|
||
|
#define _KGLOBAL_H
|
||
|
|
||
13 years ago
|
#include "tdelibs_export.h"
|
||
12 years ago
|
#include <kinstance.h> // KDE4: class TDEInstance is enough here
|
||
15 years ago
|
|
||
|
class KCharsets;
|
||
12 years ago
|
class TDEConfig;
|
||
12 years ago
|
class TDESharedConfig;
|
||
12 years ago
|
class TDEIconLoader;
|
||
13 years ago
|
class TDEHardwareDevices;
|
||
12 years ago
|
class TDEGlobalNetworkManager;
|
||
12 years ago
|
class TDELocale;
|
||
12 years ago
|
class TDEStandardDirs;
|
||
15 years ago
|
class KStaticDeleterBase;
|
||
|
class KStaticDeleterList;
|
||
|
class KStringDict;
|
||
14 years ago
|
class TQString;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Access to the KDE global objects.
|
||
12 years ago
|
* TDEGlobal provides you with pointers of many central
|
||
15 years ago
|
* objects that exist only once in the process. It is also
|
||
|
* responsible for managing instances of KStaticDeleterBase.
|
||
|
*
|
||
|
* @see KStaticDeleterBase
|
||
|
* @author Sirtaj Singh Kang (taj@kde.org)
|
||
|
*/
|
||
12 years ago
|
class TDECORE_EXPORT TDEGlobal
|
||
15 years ago
|
{
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* Returns the global instance. There is always at least
|
||
|
* one instance of a component in one application (in most
|
||
|
* cases the application itself).
|
||
|
* @return the global instance
|
||
|
*/
|
||
12 years ago
|
static TDEInstance *instance();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the application standard dirs object.
|
||
|
* @return the global standard dir object
|
||
|
*/
|
||
12 years ago
|
static TDEStandardDirs *dirs();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the general config object.
|
||
|
* @return the global configuration object.
|
||
|
*/
|
||
12 years ago
|
static TDEConfig *config();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the general config object.
|
||
|
* @return the global configuration object.
|
||
|
*/
|
||
12 years ago
|
static TDESharedConfig *sharedConfig();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns an iconloader object.
|
||
|
* @return the global iconloader object
|
||
|
*/
|
||
12 years ago
|
static TDEIconLoader *iconLoader();
|
||
15 years ago
|
|
||
13 years ago
|
/**
|
||
12 years ago
|
* Returns a TDEHardwareDevices object.
|
||
|
* @return the global hardware devices object
|
||
13 years ago
|
*/
|
||
|
static TDEHardwareDevices *hardwareDevices();
|
||
|
|
||
12 years ago
|
/**
|
||
|
* Returns a TDEGlobalNetworkManager object.
|
||
|
* @return the global network manager object
|
||
|
*/
|
||
|
static TDEGlobalNetworkManager *networkManager();
|
||
|
|
||
15 years ago
|
/**
|
||
|
* Returns the global locale object.
|
||
|
* @return the global locale object
|
||
|
*/
|
||
12 years ago
|
static TDELocale *locale();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* The global charset manager.
|
||
|
* @return the global charset manager
|
||
|
*/
|
||
|
static KCharsets *charsets();
|
||
|
|
||
|
/**
|
||
15 years ago
|
* Creates a static TQString.
|
||
15 years ago
|
*
|
||
|
* To be used inside functions(!) like:
|
||
|
* \code
|
||
12 years ago
|
* static const TQString &myString = TDEGlobal::staticQString("myText");
|
||
15 years ago
|
* \endcode
|
||
|
*
|
||
|
* !!! Do _NOT_ use: !!!
|
||
|
* \code
|
||
12 years ago
|
* static TQString myString = TDEGlobal::staticQString("myText");
|
||
15 years ago
|
* \endcode
|
||
|
* This creates a static object (instead of a static reference)
|
||
|
* and as you know static objects are EVIL.
|
||
|
* @param str the string to create
|
||
|
* @return the static string
|
||
|
*/
|
||
15 years ago
|
static const TQString &staticQString(const char *str);
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Creates a static TQString.
|
||
15 years ago
|
*
|
||
|
* To be used inside functions(!) like:
|
||
|
* \code
|
||
12 years ago
|
* static const TQString &myString = TDEGlobal::staticQString(i18n("My Text"));
|
||
15 years ago
|
* \endcode
|
||
|
*
|
||
|
* !!! Do _NOT_ use: !!!
|
||
|
* \code
|
||
12 years ago
|
* static TQString myString = TDEGlobal::staticQString(i18n("myText"));
|
||
15 years ago
|
* \endcode
|
||
|
* This creates a static object (instead of a static reference)
|
||
|
* and as you know static objects are EVIL.
|
||
|
* @param str the string to create
|
||
|
* @return the static string
|
||
|
*/
|
||
15 years ago
|
static const TQString &staticQString(const TQString &str);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Registers a static deleter.
|
||
|
* @param d the static deleter to register
|
||
|
* @see KStaticDeleterBase
|
||
|
* @see KStaticDeleter
|
||
|
*/
|
||
|
static void registerStaticDeleter(KStaticDeleterBase *d);
|
||
|
|
||
|
/**
|
||
|
* Unregisters a static deleter.
|
||
|
* @param d the static deleter to unregister
|
||
|
* @see KStaticDeleterBase
|
||
|
* @see KStaticDeleter
|
||
|
*/
|
||
|
static void unregisterStaticDeleter(KStaticDeleterBase *d);
|
||
|
|
||
|
/**
|
||
|
* Calls KStaticDeleterBase::destructObject() on all
|
||
|
* registered static deleters and unregisters them all.
|
||
|
* @see KStaticDeleterBase
|
||
|
* @see KStaticDeleter
|
||
|
*/
|
||
|
static void deleteStaticDeleters();
|
||
|
|
||
|
//private:
|
||
|
static KStringDict *_stringDict;
|
||
12 years ago
|
static TDEInstance *_instance;
|
||
12 years ago
|
static TDELocale *_locale;
|
||
15 years ago
|
static KCharsets *_charsets;
|
||
|
static KStaticDeleterList *_staticDeleters;
|
||
|
|
||
|
/**
|
||
|
* The instance currently active (useful in a multi-instance
|
||
|
* application, such as a KParts application).
|
||
12 years ago
|
* Don't use this - it's mainly for TDEAboutDialog and KBugReport.
|
||
15 years ago
|
* @internal
|
||
|
*/
|
||
12 years ago
|
static void setActiveInstance(TDEInstance *d);
|
||
|
static TDEInstance *activeInstance() { return _activeInstance; }
|
||
15 years ago
|
|
||
12 years ago
|
static TDEInstance *_activeInstance;
|
||
15 years ago
|
};
|
||
|
|
||
|
/**
|
||
12 years ago
|
* \relates TDEGlobal
|
||
14 years ago
|
* A typesafe function to find the minimum of the two arguments.
|
||
15 years ago
|
*/
|
||
|
#define KMIN(a,b) kMin(a,b)
|
||
|
/**
|
||
12 years ago
|
* \relates TDEGlobal
|
||
14 years ago
|
* A typesafe function to find the maximum of the two arguments.
|
||
15 years ago
|
*/
|
||
|
#define KMAX(a,b) kMax(a,b)
|
||
|
/**
|
||
12 years ago
|
* \relates TDEGlobal
|
||
15 years ago
|
* A typesafe function to determine the absolute value of the argument.
|
||
|
*/
|
||
|
#define KABS(a) kAbs(a)
|
||
|
/**
|
||
12 years ago
|
* \relates TDEGlobal
|
||
15 years ago
|
* A typesafe function that returns x if it's between low and high values.
|
||
|
* low if x is smaller than then low and high if x is bigger than high.
|
||
|
*/
|
||
|
#define KCLAMP(x,low,high) kClamp(x,low,high)
|
||
|
|
||
|
// XXX KDE4: Make kMin, kMax and kClamp return "T" instead of "const T &"!
|
||
|
template<class T>
|
||
|
inline const T& kMin (const T& a, const T& b) { return a < b ? a : b; }
|
||
|
|
||
|
template<class T>
|
||
|
inline const T& kMax (const T& a, const T& b) { return b < a ? a : b; }
|
||
|
|
||
|
template<class T>
|
||
|
inline T kAbs (const T& a) { return a < 0 ? -a : a; }
|
||
|
|
||
|
template<class T>
|
||
|
inline const T& kClamp( const T& x, const T& low, const T& high )
|
||
|
{
|
||
|
if ( x < low ) return low;
|
||
|
else if ( high < x ) return high;
|
||
|
else return x;
|
||
|
}
|
||
|
|
||
|
/**
|
||
13 years ago
|
* Locale-independent tqstricmp. Use this for comparing ascii keywords
|
||
15 years ago
|
* in a case-insensitive way.
|
||
13 years ago
|
* tqstricmp fails with e.g. the Turkish locale where 'I'.lower() != 'i'
|
||
15 years ago
|
* @since 3.4
|
||
|
*/
|
||
13 years ago
|
int TDECORE_EXPORT kasciistricmp( const char *str1, const char *str2 );
|
||
15 years ago
|
|
||
|
|
||
|
/**
|
||
|
* \mainpage The KDE Core Functionality Library
|
||
|
*
|
||
|
* All KDE programs use this library to provide basic functionality such
|
||
|
* as the configuration system, IPC, internationalization and locale
|
||
|
* support, site-independent access to the filesystem and a large number
|
||
|
* of other (but no less important) things.
|
||
|
*
|
||
13 years ago
|
* All KDE applications should link to the tdecore library. Also, using a
|
||
12 years ago
|
* TDEApplication derived class instead of TQApplication is almost
|
||
15 years ago
|
* mandatory if you expect your application to behave nicely within the
|
||
|
* KDE environment.
|
||
|
*/
|
||
|
|
||
|
#endif // _KGLOBAL_H
|
||
|
|