Ulrich Van Den Hekke 12 years ago
parent
commit
01e84679d9
  1. 35
      framework/core/exceptions.cpp
  2. 16
      framework/core/exceptions.h
  3. 20
      framework/core/xinxconfig.cpp
  4. 6
      framework/core/xinxconfig.h
  5. 25
      framework/core/xinxsingleton.h
  6. 18
      framework/core/xinxthread.cpp
  7. 9
      framework/core/xinxthread.h
  8. 16
      framework/plugins/xinxpluginsloader.cpp
  9. 9
      framework/plugins/xinxpluginsloader.h
  10. 17
      framework/scripts/scriptmanager.cpp
  11. 8
      framework/scripts/scriptmanager.h
  12. 16
      framework/snipets/snipetmanager.cpp
  13. 7
      framework/snipets/snipetmanager.h
  14. 15
      plugins/core/config/selfwebpluginsettings.cpp
  15. 8
      plugins/core/config/selfwebpluginsettings.h
  16. 16
      plugins/core/editors/models/xq/xquery_keyword.cpp
  17. 9
      plugins/core/editors/models/xq/xquery_keyword.h
  18. 15
      plugins/generix/config/selfgcesettings.cpp
  19. 8
      plugins/generix/config/selfgcesettings.h
  20. 18
      plugins/generix/configuration/configurationmanager.cpp
  21. 7
      plugins/generix/configuration/configurationmanager.h

35
framework/core/exceptions.cpp

@ -44,11 +44,6 @@
# include <cxxabi.h>
#endif
/* Static member */
ExceptionManager * ExceptionManager::s_self = 0;
ErrorManager * ErrorManager::s_self = 0;
/* Message Handler */
static void xinxMessageHandler(QtMsgType t, const char * m)
@ -103,8 +98,7 @@ ExceptionManager::ExceptionManager()
ExceptionManager::~ExceptionManager()
{
if (s_self == this)
s_self = 0;
}
/*!
@ -200,20 +194,6 @@ void ExceptionManager::notifyError(QString error, QtMsgType t, bool showMessage)
}
}
/*!
* \brief Return the exception manager of the application and created it if needed.
*/
ExceptionManager * ExceptionManager::self()
{
if (! s_self)
{
s_self = new ExceptionManager();
XINXStaticDeleter::self()->addObject(s_self);
}
return s_self;
}
/* XinxException */
/*!
@ -311,20 +291,7 @@ ErrorManager::ErrorManager()
ErrorManager::~ErrorManager()
{
if (this == s_self)
{
s_self = 0;
}
}
ErrorManager * ErrorManager::self()
{
if (! s_self)
{
s_self = new ErrorManager();
XINXStaticDeleter::self()->addObject(s_self);
}
return s_self;
}
void ErrorManager::addContextTranslation(const QString & context, const QString & translation)

16
framework/core/exceptions.h

@ -24,6 +24,7 @@
// Xinx header
#include <core/lib-config.h>
#include <core/xinxcore.h>
#include <core/xinxsingleton.h>
// Qt header
#include <QStringList>
@ -63,7 +64,7 @@ private:
#define EXCEPT_ELSE(assertion, Exception, method, ...) \
(assertion ? qt_noop() : throw Exception(#assertion, __FILE__,__LINE__, method, __VA_ARGS__));
class LIBEXPORT ExceptionManager : public QObject
class LIBEXPORT ExceptionManager : public XinxLibSingleton<ExceptionManager>
{
Q_OBJECT
public:
@ -71,10 +72,7 @@ public:
QStringList stackTrace() const;
static ExceptionManager * self();
static void installExceptionHandler();
public slots:
void notifyError(QString error, QtMsgType t = QtWarningMsg, bool showMessage = true);
signals:
@ -82,13 +80,12 @@ signals:
private:
ExceptionManager();
static ExceptionManager * s_self;
QHash<unsigned long,QStringList> m_stackTrace;
QStringList m_exceptionFilter;
friend class XinxLibSingleton<ExceptionManager>;
};
class LIBEXPORT ErrorManager : public QObject
class LIBEXPORT ErrorManager : public XinxLibSingleton<ErrorManager>
{
Q_OBJECT
public:
@ -107,8 +104,6 @@ public:
virtual ~ErrorManager();
static ErrorManager * self();
const QMap<QString, QList<Error> > & errors() const;
public slots:
void addContextTranslation(const QString & context, const QString & translation);
@ -122,11 +117,10 @@ signals:
private:
ErrorManager();
static ErrorManager * s_self;
QHash<QString,QString> m_contextTranslation;
QMap<QString, QList<Error> > m_errors;
QTimer m_timer;
friend class XinxLibSingleton<ErrorManager>;
};
#endif /* __EXCEPTIONS_H__ */

20
framework/core/xinxconfig.cpp

@ -37,26 +37,20 @@ ToolsNotDefinedException::ToolsNotDefinedException(const QString & tool) : XinxE
}
/* Static member */
XINXConfig * XINXConfig::s_self = 0;
/* XINXConfig */
XINXConfig::XINXConfig(const XINXConfig & origine) : QObject(), AppSettings(origine)
XINXConfig::XINXConfig(const XINXConfig & origine) : AppSettings(origine)
{
}
XINXConfig::XINXConfig() : QObject(), AppSettings()
XINXConfig::XINXConfig() : AppSettings()
{
}
XINXConfig::~XINXConfig()
{
if (this == s_self)
s_self = NULL;
}
@ -157,16 +151,6 @@ void XINXConfig::addDefaultTool(const QString & tool, const QString & defaultVal
}
}
XINXConfig * XINXConfig::self()
{
if (s_self == 0)
{
s_self = new XINXConfig();
XINXStaticDeleter::self()->addObject(s_self);
}
return s_self;
}
AppSettings::struct_globals XINXConfig::getDefaultGlobals()
{
struct_globals value = AppSettings::getDefaultGlobals();

6
framework/core/xinxconfig.h

@ -45,7 +45,7 @@ public:
* Represente the configuration of XINX. The configuration of unique for a
* unique process.
*/
class LIBEXPORT XINXConfig : public QObject, public AppSettings
class LIBEXPORT XINXConfig : public XinxLibSingleton<XINXConfig>, public AppSettings
{
Q_OBJECT
public:
@ -56,9 +56,6 @@ public:
/*! Destroy the configuration object */
virtual ~XINXConfig();
/*! Self create a XINX configuration file if necessary */
static XINXConfig * self();
//! Get a created format scheme
XinxFormatScheme * scheme(const QString & highlighter);
@ -108,7 +105,6 @@ protected:
virtual struct_globals getDefaultGlobals();
virtual struct_editor getDefaultEditor();
private:
static XINXConfig * s_self;
QPointer<XinxLanguageFactory> m_languages;
QHash<QString,XinxFormatScheme*> m_formatScheme;
};

25
framework/core/xinxsingleton.h

@ -22,6 +22,7 @@
// Qt header
#include <QObject>
#include <QMutexLocker>
// Xinx header
#include "xinxcore.h"
@ -31,15 +32,19 @@ template<class T> class LIBEXPORT XinxLibSingleton : public QObject
public:
~XinxLibSingleton()
{
_self = 0;
}
static T * self()
{
if (_self == NULL)
{
_self = new T;
_self->initialisation();
QMutexLocker locker(&_self_mutex);
if (_self == NULL)
{
_self = new T;
_self->initialisation();
}
}
return _self;
@ -58,24 +63,30 @@ protected:
private:
static T * _self;
static QMutex _self_mutex;
};
template <typename T> T * XinxLibSingleton<T>::_self = NULL;
template <typename T> QMutex XinxLibSingleton<T>::_self_mutex;
template<class T> class XinxSingleton : public QObject
{
public:
~XinxSingleton()
{
_self = 0;
}
static T * self()
{
if (_self == NULL)
{
_self = new T;
_self->initialisation();
QMutexLocker locker(&_self_mutex);
if (_self == NULL)
{
_self = new T;
_self->initialisation();
}
}
return _self;
@ -94,8 +105,10 @@ protected:
private:
static T * _self;
static QMutex _self_mutex;
};
template <typename T> T * XinxSingleton<T>::_self = NULL;
template <typename T> QMutex XinxSingleton<T>::_self_mutex;
#endif // XINXSINGLETON_H

18
framework/core/xinxthread.cpp

@ -22,10 +22,6 @@
#include "core/exceptions.h"
#include "core/xinxcore.h"
/* Static member */
XinxThreadManager * XinxThreadManager::s_self = NULL;
/* XinxThreadManager */
XinxThreadManager::XinxThreadManager() : m_threadCount(0), m_threadClassCount(0)
@ -35,8 +31,7 @@ XinxThreadManager::XinxThreadManager() : m_threadCount(0), m_threadClassCount(0)
XinxThreadManager::~XinxThreadManager()
{
if (this == s_self)
s_self = NULL;
}
int XinxThreadManager::getThreadCount() const
@ -49,17 +44,6 @@ int XinxThreadManager::getThreadClassCount() const
return m_threadClassCount;
}
XinxThreadManager * XinxThreadManager::self()
{
if (! s_self)
{
s_self = new XinxThreadManager();
XINXStaticDeleter::self()->add(s_self);
}
return s_self;
}
/* XinxThread */
XinxThread::XinxThread(QObject * parent) : QThread(parent)

9
framework/core/xinxthread.h

@ -24,6 +24,7 @@
// Xinx header
#include <core/lib-config.h>
#include <core/xinxcore.h>
#include <core/xinxsingleton.h>
// Qt header
#include <QThread>
@ -37,7 +38,7 @@ class XinxThread;
*
* To be used, each created thread must be a XinxThread (derivated from a QThread).
*/
class LIBEXPORT XinxThreadManager : public QObject
class LIBEXPORT XinxThreadManager : public XinxLibSingleton<XinxThreadManager>
{
Q_OBJECT
public:
@ -48,21 +49,17 @@ public:
int getThreadCount() const;
/// Get the number of thread class object created
int getThreadClassCount() const;
/// Get the static member and create it if needed.
static XinxThreadManager * self();
signals:
/// Signal emited when the number of running thread, or object change.
void threadCountChange();
private:
XinxThreadManager();
static XinxThreadManager * s_self;
int m_threadCount, m_threadClassCount;
QMutex m_mutex;
friend class XinxThread;
friend class XinxLibSingleton<XinxThreadManager>;
};
/*!

16
framework/plugins/xinxpluginsloader.cpp

@ -36,10 +36,6 @@
#include <qlanguagefactory.h>
#include <qnfadefinition.h>
/* Static member */
XinxPluginsLoader * XinxPluginsLoader::s_self = 0;
/* Static function */
static bool pluginsLessThan(XinxPluginElement * s1, XinxPluginElement * s2)
@ -59,18 +55,6 @@ XinxPluginsLoader::XinxPluginsLoader()
XinxPluginsLoader::~XinxPluginsLoader()
{
qDeleteAll(plugins());
if (s_self == this)
s_self = NULL;
}
XinxPluginsLoader * XinxPluginsLoader::self()
{
if (s_self == 0)
{
s_self = new XinxPluginsLoader();
XINXStaticDeleter::self()->addObject(s_self);
}
return s_self;
}
QList<XinxPluginElement*> XinxPluginsLoader::plugins() const

9
framework/plugins/xinxpluginsloader.h

@ -24,6 +24,7 @@
// Xinx header
#include <core/lib-config.h>
#include <core/xinxcore.h>
#include <core/xinxsingleton.h>
// Qt header
#include <QHash>
@ -41,7 +42,7 @@ class XinxFormatScheme;
class XINXConfig;
/*! The class XINX Plugins Loader is used to load all plugins and proposed some facilities method. */
class LIBEXPORT XinxPluginsLoader : public QObject
class LIBEXPORT XinxPluginsLoader : public XinxLibSingleton<XinxPluginsLoader>
{
Q_OBJECT
public:
@ -71,9 +72,6 @@ public:
QString exampleOfHighlighter(const QString & name) const;
//! Create a format scheme for the given highlighter
XinxFormatScheme * scheme(const QString & highlighter, XINXConfig * config);
/*! Create a plugin loader object */
static XinxPluginsLoader * self();
private:
XinxPluginsLoader();
@ -81,8 +79,7 @@ private:
QString allManagedFileFilter() const;
QMap<QString, XinxPluginElement*> m_plugins;
static XinxPluginsLoader * s_self;
friend class XinxLibSingleton<XinxPluginsLoader>;
};
#endif /*XINXPLUGINSLOADER_H_*/

17
framework/scripts/scriptmanager.cpp

@ -45,10 +45,6 @@
#endif
/* Static member */
ScriptManager * ScriptManager::s_self = 0;
/* Global script function */
static QScriptValue alert(QScriptContext * context, QScriptEngine *)
@ -366,17 +362,4 @@ void ScriptManager::setCurrentEditeur(AbstractEditor * editor)
m_editor = editor;
}
ScriptManager * ScriptManager::self()
{
static QMutex selfMutex;
QMutexLocker locker(&selfMutex);
if (s_self == 0)
{
s_self = new ScriptManager();
XINXStaticDeleter::self()->addObject(s_self);
}
return s_self;
}

8
framework/scripts/scriptmanager.h

@ -23,6 +23,7 @@
// Xinx header
#include <core/lib-config.h>
#include <core/xinxsingleton.h>
// Qt header
#include <QObject>
@ -76,7 +77,7 @@ private:
};
class LIBEXPORT ScriptManager : public QObject
class LIBEXPORT ScriptManager : public XinxLibSingleton<ScriptManager>
{
Q_OBJECT
public:
@ -87,8 +88,6 @@ public:
void setCurrentEditeur(AbstractEditor * editor);
static ScriptManager * self();
void callScriptsBeforeSave(AbstractEditor * editor);
void callScriptsAfterSave(AbstractEditor * editor);
void callScriptsBeforeLoad(AbstractEditor * editor);
@ -106,8 +105,7 @@ private:
QList<ScriptValue> m_objects;
QPointer<XinxProject::Parameters> m_project;
AbstractEditor * m_editor;
static ScriptManager * s_self;
friend class XinxLibSingleton<ScriptManager>;
};
Q_DECLARE_METATYPE(QScriptValue)

16
framework/snipets/snipetmanager.cpp

@ -41,10 +41,6 @@
#include <QDebug>
#include <QDir>
/* Static member */
SnipetManager * SnipetManager::s_self = 0;
/* SnipetManager */
SnipetManager::SnipetManager()
@ -56,18 +52,6 @@ SnipetManager::~SnipetManager()
{
m_handler.clear();
closeDatabase();
if (s_self == this)
s_self = NULL;
}
SnipetManager * SnipetManager::self()
{
if (s_self == 0)
{
s_self = new SnipetManager();
XINXStaticDeleter::self()->addObject(s_self);
}
return s_self;
}
QSqlDatabase SnipetManager::database()

7
framework/snipets/snipetmanager.h

@ -24,6 +24,7 @@
// Xinx header
#include <core/lib-config.h>
#include <snipets/snipetlist.h>
#include <core/xinxsingleton.h>
// Qt header
#include <QObject>
@ -39,14 +40,12 @@ class QSqlDatabase;
* The goal of SnipetDataBaseManager is too manage the new snipet interface
* of XINX. This interface create table if necessary in the SQL database.
*/
class LIBEXPORT SnipetManager : public QObject
class LIBEXPORT SnipetManager : public XinxLibSingleton<SnipetManager>
{
Q_OBJECT
public:
~SnipetManager();
static SnipetManager * self();
QSqlDatabase database();
CategoryItemModel * createCategoryItemModel(QObject * parent = 0);
@ -87,7 +86,7 @@ private:
void closeDatabase();
QObjectCleanupHandler m_handler;
static SnipetManager * s_self;
friend class XinxLibSingleton<SnipetManager>;
};
#endif /* _SNIPETMANAGER_H_ */

15
plugins/core/config/selfwebpluginsettings.cpp

@ -25,8 +25,6 @@
// Qt header
#include <QDir>
SelfWebPluginSettings * SelfWebPluginSettings::s_self = 0;
SelfWebPluginSettings::SelfWebPluginSettings() : WebPluginSettings()
{
load();
@ -34,20 +32,7 @@ SelfWebPluginSettings::SelfWebPluginSettings() : WebPluginSettings()
SelfWebPluginSettings::~SelfWebPluginSettings()
{
if (s_self == this)
{
s_self = 0;
}
}
SelfWebPluginSettings * SelfWebPluginSettings::self()
{
if (! s_self)
{
s_self = new SelfWebPluginSettings();
XINXStaticDeleter::self()->add(s_self);
}
return s_self;
}
void SelfWebPluginSettings::save()

8
plugins/core/config/selfwebpluginsettings.h

@ -23,22 +23,20 @@
// Xinx header
#include "webpluginsettings.h"
#include <core/xinxsingleton.h>
class SelfWebPluginSettings : public QObject, public WebPluginSettings
class SelfWebPluginSettings : public XinxSingleton<SelfWebPluginSettings>, public WebPluginSettings
{
Q_OBJECT
public:
virtual ~SelfWebPluginSettings();
static SelfWebPluginSettings * self();
virtual void save();
signals:
void changed();
private:
SelfWebPluginSettings();
static SelfWebPluginSettings * s_self;
friend class XinxSingleton<SelfWebPluginSettings>;
};
#endif /*SELFWEBPLUGINSETTINGS_H_*/

16
plugins/core/editors/models/xq/xquery_keyword.cpp

@ -21,13 +21,10 @@
#include "xquery_keyword.h"
#include <core/xinxcore.h>
/* Static */
XQueryKeyword * XQueryKeyword::s_self = 0;
/* XQueryKeyword */
XQueryKeyword::XQueryKeyword() : QObject()
XQueryKeyword::XQueryKeyword()
{
/* Accessors */
m_keywords.insert("node-name", "accessors");
@ -138,18 +135,7 @@ XQueryKeyword::XQueryKeyword() : QObject()
XQueryKeyword::~XQueryKeyword()
{
if (this == s_self)
s_self = 0;
}
XQueryKeyword * XQueryKeyword::self()
{
if (s_self == 0)
{
s_self = new XQueryKeyword();
XINXStaticDeleter::self()->addObject(s_self);
}
return s_self;
}
const QHash<QString,QString> & XQueryKeyword::keywords() const

9
plugins/core/editors/models/xq/xquery_keyword.h

@ -21,26 +21,27 @@
#define XQUERY_KEYWORD_H_
#pragma once
// Xinx header
#include <core/xinxsingleton.h>
// Qt header
#include <QHash>
#include <QString>
/* XQueryKeyword */
class XQueryKeyword : public QObject
class XQueryKeyword : public XinxSingleton<XQueryKeyword>
{
Q_OBJECT
public:
~XQueryKeyword();
static XQueryKeyword * self();
const QHash<QString,QString> & keywords() const;
private:
XQueryKeyword();
QHash<QString,QString> m_keywords;
static XQueryKeyword * s_self;
friend class XinxSingleton<XQueryKeyword>;
};
#endif /* XQUERY_KEYWORD_H_ */

15
plugins/generix/config/selfgcesettings.cpp

@ -25,8 +25,6 @@
// Qt header
#include <QDir>
SelfGceSettings * SelfGceSettings::s_self = 0;
SelfGceSettings::SelfGceSettings() : GceSettings()
{
load();
@ -34,20 +32,7 @@ SelfGceSettings::SelfGceSettings() : GceSettings()
SelfGceSettings::~SelfGceSettings()
{
if (s_self == this)
{
s_self = 0;
}
}
SelfGceSettings * SelfGceSettings::self()
{
if (! s_self)
{
s_self = new SelfGceSettings();
XINXStaticDeleter::self()->add(s_self);
}
return s_self;
}
void SelfGceSettings::save()

8
plugins/generix/config/selfgcesettings.h

@ -23,22 +23,20 @@
// Xinx header
#include "gcesettings.h"
#include <core/xinxsingleton.h>
class SelfGceSettings : public QObject, public GceSettings
class SelfGceSettings : public XinxSingleton<SelfGceSettings>, public GceSettings
{
Q_OBJECT
public:
virtual ~SelfGceSettings();
static SelfGceSettings * self();
virtual void save();
signals:
void changed();
private:
SelfGceSettings();
static SelfGceSettings * s_self;
friend class XinxSingleton<SelfGceSettings>;
};
#endif /* SELFGENERIXSETTINGS_H_ */

18
plugins/generix/configuration/configurationmanager.cpp

@ -25,10 +25,6 @@
#include "projectproperty/generixproject.h"
#include "docks/dictionary/dictionary_parser.h"
/* Global */
ConfigurationManager * ConfigurationManager::s_self = 0;
/* ConfigurationManager */
ConfigurationManager::ConfigurationManager()
@ -39,26 +35,12 @@ ConfigurationManager::ConfigurationManager()
ConfigurationManager::~ConfigurationManager()
{
if (s_self == this)
{
s_self = 0;
}
foreach(GceInterface * interface, m_interface.values())
{
delete interface;
}
}
ConfigurationManager * ConfigurationManager::self()
{
if (! s_self)
{
s_self = new ConfigurationManager();
XINXStaticDeleter::self()->add(s_self);
}
return s_self;
}
void ConfigurationManager::cleanCache()
{
foreach(GceInterface * interface, m_interface.values())

7
plugins/generix/configuration/configurationmanager.h

@ -29,7 +29,7 @@
#include "configuration/gceinterface.h"
#include <project/xinxprojectproject.h>
class ConfigurationManager : public QObject
class ConfigurationManager : public XinxSingleton<ConfigurationManager>
{
Q_OBJECT
public:
@ -41,12 +41,9 @@ public:
void loadDictionary(XinxProject::Project * project);
void cleanCache();
static ConfigurationManager * self();
private slots:
void clearCache(const QString & filename);
private:
ConfigurationManager();
QFileSystemWatcher * m_watcher;
@ -55,7 +52,7 @@ private:
QHash<QString,GceInterface*> m_interface;
static ConfigurationManager * s_self;
friend class XinxSingleton<ConfigurationManager>;
};
#endif // CONFIGURATIONMANAGER_H

Loading…
Cancel
Save