|
From: <dhu...@us...> - 2006-12-01 13:11:57
|
Revision: 45
http://svn.sourceforge.net/qcell/?rev=45&view=rev
Author: dhubleizh
Date: 2006-12-01 05:11:52 -0800 (Fri, 01 Dec 2006)
Log Message:
-----------
- an ide to use GenericParserPlugin which partially implements the ParserInterface
- eases the writting of plugins
- KIParserPlugin as an example of how to use the 'new' way
- this implies of partially rewritting two other plugins (NParserPlugin and FQTParserPlugin)
Modified Paths:
--------------
trunk/qcell/baseheaders/interfaces.h
trunk/qcell/parsers/KI/KIParserPlugin.cpp
trunk/qcell/parsers/KI/KIParserPlugin.h
Added Paths:
-----------
trunk/qcell/baseheaders/GenericParserPlugin.h
Added: trunk/qcell/baseheaders/GenericParserPlugin.h
===================================================================
--- trunk/qcell/baseheaders/GenericParserPlugin.h (rev 0)
+++ trunk/qcell/baseheaders/GenericParserPlugin.h 2006-12-01 13:11:52 UTC (rev 45)
@@ -0,0 +1,38 @@
+/**@file GenericParserPlugin.h
+ * @author czarny
+ * @version 0.1
+ * @date
+ * Created: pi? 01 gru 2006 13:33:00 CET \n
+ * Last Update: pi? 01 gru 2006 13:33:00 CET
+ */
+
+#ifndef __GENERICPARSERPLUGIN_H__
+#define __GENERICPARSERPLUGIN_H__
+
+#include "interfaces.h"
+
+class GenericParserPlugin : public QObject, public ParserInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(ParserInterface)
+
+protected:
+ /// A list defined by each plugin of supported plugin types
+ QStringList supported_parser_types;
+ /// A list defined by each plugin of supported file types
+ QStringList supported_file_types;
+
+public:
+ inline QStringList parserTypes() const
+ {
+ return supported_parser_types;
+ };
+// inline QStringList fileTypes(const QString type) const
+// {
+// return supported_file_types;
+// }
+
+};
+
+#endif
+
Modified: trunk/qcell/baseheaders/interfaces.h
===================================================================
--- trunk/qcell/baseheaders/interfaces.h 2006-12-01 12:29:35 UTC (rev 44)
+++ trunk/qcell/baseheaders/interfaces.h 2006-12-01 13:11:52 UTC (rev 45)
@@ -10,6 +10,7 @@
#ifndef __INTERFACES_H__
#define __INTERFACES_H__
+#include <QtPlugin>
#include <QByteArray>
#include <QString>
#include <QStringList>
Modified: trunk/qcell/parsers/KI/KIParserPlugin.cpp
===================================================================
--- trunk/qcell/parsers/KI/KIParserPlugin.cpp 2006-12-01 12:29:35 UTC (rev 44)
+++ trunk/qcell/parsers/KI/KIParserPlugin.cpp 2006-12-01 13:11:52 UTC (rev 45)
@@ -1,33 +1,18 @@
-/**@file KIParserPlugin.c
+/**@file KIParserPlugin.cpp
* @author czarny
* @version 0.1
* @date
* Created: pi\xB1 gru 1 13:23:27 CET 2006 \n
* Last Update: pi\xB1 gru 1 13:23:39 CET 2006
*/
+
#include "KIParserPlugin.h"
-
-QStringList KIParserPlugin::parserTypes() const
+KIParserPlugin::KIParserPlugin()
{
- return QStringList(FQT_PARSER_TYPE);
-}
+ supported_parser_types << "World";
+ supported_file_types << "KI";
-QStringList KIParserPlugin::fileTypes(const QString type) const
-{
- if(type == FQT_PARSER_TYPE)
- {
- return QStringList(FQT_PARSER_TYPE);
- }
- else {
-
- qDebug(tr("This plugin doesn't support type %1.")
- .arg(type)
- .toAscii()
- );
-
- return QStringList();
- }
}
/// @todo Incorporate genreal Function file to output resulting XML
@@ -41,17 +26,18 @@
// Parameters from the file header
// If we're asked by accident to parse a file not supported by the plugin
- if(type != FQT_PARSER_TYPE)
- {
- qDebug(tr("The pluginn has been asked to parse a file type (%1) different from declared one (%2).")
- .arg(type)
- .arg(FQT_PARSER_TYPE)
- .toAscii()
- );
+ /// @todo redefine it the 'new' way
+// if(type != FQT_PARSER_TYPE)
+// {
+// qDebug(tr("The pluginn has been asked to parse a file type (%1) different from declared one (%2).")
+// .arg(type)
+// .arg(FQT_PARSER_TYPE)
+// .toAscii()
+// );
+//
+// return QString();
+// }
- return QString();
- }
-
// Basic sanity check
lines = QString(content).split('\n');
if(lines.count() < 1)
Modified: trunk/qcell/parsers/KI/KIParserPlugin.h
===================================================================
--- trunk/qcell/parsers/KI/KIParserPlugin.h 2006-12-01 12:29:35 UTC (rev 44)
+++ trunk/qcell/parsers/KI/KIParserPlugin.h 2006-12-01 13:11:52 UTC (rev 45)
@@ -9,25 +9,17 @@
#ifndef __KIPARSERPLUGIN_H__
#define __KIPARSERPLUGIN_H__
-#include <QObject>
-#include <QtPlugin>
-#include <QStringList>
-#include <QString>
-#include <QByteArray>
#include <QVector>
#include <QMap>
-#include "interfaces.h"
+#include "GenericParserPlugin.h"
//#include "Neighbourhood.h"
-#define FQT_PARSER_TYPE "World"
-
-class KIParserPlugin : public QObject, public ParserInterface
+class KIParserPlugin : public GenericParserPlugin
{
- Q_OBJECT
- Q_INTERFACES(ParserInterface)
-
public:
+ KIParserPlugin();
+
QStringList parserTypes() const;
QStringList fileTypes(const QString type) const;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|