|
From: <dhu...@us...> - 2007-01-25 20:04:12
|
Revision: 259
http://svn.sourceforge.net/qcell/?rev=259&view=rev
Author: dhubleizh
Date: 2007-01-25 12:04:10 -0800 (Thu, 25 Jan 2007)
Log Message:
-----------
- proper REAK file parsing
- now passing data to LocalFunction
- fix bug in LocalFunction
Modified Paths:
--------------
trunk/qcell/basesources/LocalFunction.cpp
trunk/qcell/parsers/REAK/REAKParserPlugin.cpp
trunk/qcell/parsers/REAK/REAKParserPlugin.h
Modified: trunk/qcell/basesources/LocalFunction.cpp
===================================================================
--- trunk/qcell/basesources/LocalFunction.cpp 2007-01-25 16:27:30 UTC (rev 258)
+++ trunk/qcell/basesources/LocalFunction.cpp 2007-01-25 20:04:10 UTC (rev 259)
@@ -516,7 +516,10 @@
switch(functionMode)
{
case LocalFunction::SWITCH:
- valueTable[calculateSwitchIndex(args)];
+ /// @todo I've changed this from line:
+ /// valueTable[calculateSwitchIndex()];
+ /// Does the above line do anything?
+ valueTable[calculateSwitchIndex(args)] = value;
break;
default:
Modified: trunk/qcell/parsers/REAK/REAKParserPlugin.cpp
===================================================================
--- trunk/qcell/parsers/REAK/REAKParserPlugin.cpp 2007-01-25 16:27:30 UTC (rev 258)
+++ trunk/qcell/parsers/REAK/REAKParserPlugin.cpp 2007-01-25 20:04:10 UTC (rev 259)
@@ -20,7 +20,7 @@
// Used to double check the format of a line in file
QRegExp format;
// Stores function values of given neighbourhood
- QMap<QVector<int>, int> function;
+ QMultiHash<int, QVector<int> > function;
// To be able to print the line in which some error occured
int line_nr = 1;
// To be able to identify which argument went wrong
@@ -52,17 +52,20 @@
if(format.exactMatch(result[0]))
{
splitted = result[0].section('K',1);
- dimensions = splitted.toInt();
-
- // dimensions sanity check
- if ((dimensions < 1) || (dimensions > 3))
+ if(result[0].size() > 4)
{
- qDebug(tr("You should specify dimensions number from 1-3 in line %1")
- .arg(line_nr)
- .toAscii()
- );
+ dimensions = splitted.toInt();
- return QString();
+ // dimensions sanity check
+ if ((dimensions < 1) || (dimensions > 3))
+ {
+ qDebug(tr("You should specify dimensions number from 1-3 in line %1")
+ .arg(line_nr)
+ .toAscii()
+ );
+
+ return QString();
+ }
}
result.removeFirst();
@@ -118,6 +121,7 @@
QVector<int> tmp_arguments;
foreach(QString line, result)
{
+ line = line.trimmed();
x = 0;
if(!format.exactMatch(line))
@@ -132,7 +136,7 @@
}
// Breaking into arguments and return value
- splitted_list = result[0].split(' ');
+ splitted_list = line.split(' ');
// Return value parsing
tmp_result = splitted_list.last()[0].toAscii();
@@ -157,7 +161,7 @@
}
// Adding to a map is so much cool, as we can get the values sorted
- // instatly
+ // instantly
tmp_arguments.clear();
foreach(QChar sign, splitted_list.first())
{
@@ -206,19 +210,42 @@
x++;
}
+// if (function.values().contains(tmp_arguments))
+// {
+// qDebug(tr("Error adding new Elemental Rule in line %1. The rule added earlier.")
+// .arg(line_nr)
+// .toAscii()
+// );
+// return QString();
+// }
+ function.insert(tmp_result, tmp_arguments);
+
// Tracking line number
line_nr++;
}
/// @todo input the retrieved data into LF
+ // Init the function
+ lf.init(arguments, alphabet_size, alphabet_size);
+ lf.setFunctonType(LocalFunction::SWITCH);
+// lf.setSumArguments(QVector<int>(1,0));
-// return lf.toXmlString();
- return QString();
+ // Finally pass the function to the engine
+ QHashIterator<int, QVector<int> > i(function);
+ while (i.hasNext())
+ {
+ i.next();
+ lf.setFunctionValue(i.key(), i.value());
+ qDebug() << i.key() << " : " << i.value();
+ }
+
+ qDebug(lf.toXmlString().toAscii());
+ return lf.toXmlString();
}
QByteArray REAKParserPlugin::parseOut(QString content, const QString type, const QString subtype)
{
- /// @todo Write paring out of REAK - this WILL be hard
+ /// @todo Write parsing out of REAK - this WILL be hard
// // The resulting array to write to file by the end backend
// QByteArray result;
// // Generic class for parsing out XMLString
Modified: trunk/qcell/parsers/REAK/REAKParserPlugin.h
===================================================================
--- trunk/qcell/parsers/REAK/REAKParserPlugin.h 2007-01-25 16:27:30 UTC (rev 258)
+++ trunk/qcell/parsers/REAK/REAKParserPlugin.h 2007-01-25 20:04:10 UTC (rev 259)
@@ -11,6 +11,7 @@
#include <QVector>
#include <QMap>
+#include <QMultiHash>
#include "GenericParserPlugin.h"
#include "LocalFunction.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|