2013-08-21 18:16:26 +00:00
|
|
|
#ifndef _ANALYSER_H_
|
|
|
|
#define _ANALYSER_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QString>
|
|
|
|
#include "backend.h"
|
2014-04-07 09:28:04 +00:00
|
|
|
#include "regtab.h"
|
2013-08-21 18:16:26 +00:00
|
|
|
|
2014-04-07 09:28:04 +00:00
|
|
|
class Analyser : public RegTabPanel
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-02-09 01:13:53 +00:00
|
|
|
Analyser(const SocRef& soc, IoBackend *backend);
|
2013-08-21 18:16:26 +00:00
|
|
|
virtual ~Analyser();
|
2014-04-07 09:28:04 +00:00
|
|
|
virtual void AllowWrite(bool en) { Q_UNUSED(en); }
|
2013-08-21 18:16:26 +00:00
|
|
|
virtual QWidget *GetWidget() = 0;
|
|
|
|
|
|
|
|
protected:
|
2014-02-09 01:13:53 +00:00
|
|
|
const SocRef& m_soc;
|
2013-08-21 18:16:26 +00:00
|
|
|
IoBackend *m_io_backend;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AnalyserFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AnalyserFactory(bool _register);
|
|
|
|
virtual ~AnalyserFactory();
|
|
|
|
|
|
|
|
virtual QString GetName() = 0;
|
|
|
|
virtual bool SupportSoc(const QString& soc_name) = 0;
|
|
|
|
// return NULL of soc is not handled by the analyser
|
2014-02-09 01:13:53 +00:00
|
|
|
virtual Analyser *Create(const SocRef& soc, IoBackend *backend) = 0;
|
2013-08-21 18:16:26 +00:00
|
|
|
private:
|
|
|
|
QString m_name;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static QStringList GetAnalysersForSoc(const QString& soc_name);
|
|
|
|
static AnalyserFactory *GetAnalyserByName(const QString& name);
|
|
|
|
static void RegisterAnalyser(AnalyserFactory *factory);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static QVector< AnalyserFactory * > m_factories;
|
|
|
|
};
|
|
|
|
|
|
|
|
template< typename T >
|
|
|
|
class TmplAnalyserFactory : public AnalyserFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TmplAnalyserFactory(bool _register, const QString& name) :AnalyserFactory(_register) { m_name = name; }
|
|
|
|
virtual ~TmplAnalyserFactory() {}
|
|
|
|
|
|
|
|
virtual QString GetName() { return m_name; }
|
|
|
|
virtual bool SupportSoc(const QString& soc_name) { return T::SupportSoc(soc_name); }
|
|
|
|
// return NULL of soc is not handled by the analyser
|
2014-02-09 01:13:53 +00:00
|
|
|
virtual T *Create(const SocRef& soc, IoBackend *backend)
|
2013-08-21 18:16:26 +00:00
|
|
|
{
|
2014-02-09 01:13:53 +00:00
|
|
|
if(!T::SupportSoc(soc.GetSoc().name.c_str()))
|
2013-08-21 18:16:26 +00:00
|
|
|
return 0;
|
|
|
|
return new T(soc, backend);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
QString m_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _ANALYSER_H_ */
|