|
From: <dhu...@us...> - 2007-01-05 20:28:54
|
Revision: 103
http://svn.sourceforge.net/qcell/?rev=103&view=rev
Author: dhubleizh
Date: 2007-01-05 12:28:52 -0800 (Fri, 05 Jan 2007)
Log Message:
-----------
- added a bunch of get functions to LocalFucntion for getting out info needed when saving
- written some almost complete saving function for FQTParserPlugin
Modified Paths:
--------------
trunk/qcell/baseheaders/LocalFunction.h
trunk/qcell/basesources/LocalFunction.cpp
trunk/qcell/parsers/FQT/FQTParserPlugin.cpp
trunk/qcell/parsers/FQT/FQTParserPlugin.h
Modified: trunk/qcell/baseheaders/LocalFunction.h
===================================================================
--- trunk/qcell/baseheaders/LocalFunction.h 2007-01-05 16:06:41 UTC (rev 102)
+++ trunk/qcell/baseheaders/LocalFunction.h 2007-01-05 20:28:52 UTC (rev 103)
@@ -29,7 +29,7 @@
QVector< QVector<int> > sumArguments;
QVector<int> freeArguments;
FUNCTION_TYPE functionMode;
- int numArg, maxArgVal, numElements;
+ int numArg, maxArgVal, numElements, maxRetVal;
QString script;
protected:
@@ -53,7 +53,7 @@
LocalFunction();
~LocalFunction();
- void init(int numberOfArguments, int alphabetSize);
+ void init(int numberOfArguments, int alphabetSize, int returnValues);
// args is vector contein index of arguments to sum
void addSumArguments(QVector<int> args);
@@ -69,6 +69,10 @@
// method set type of function (normally function type is set automatically when setSumArguments, setProductArguments, setSwitchFunction or setScript methosd ar used)
void setFunctonType(LocalFunction::FUNCTION_TYPE type);
LocalFunction::FUNCTION_TYPE getFunctonType(void);
+ int getNumberOfArgs();
+ int getAlphabetSize();
+ int getMaxReturnValues();
+ QVector<int> getSummedArguments();
int addFunctionValueArgumentsNumberRequest(void);
Modified: trunk/qcell/basesources/LocalFunction.cpp
===================================================================
--- trunk/qcell/basesources/LocalFunction.cpp 2007-01-05 16:06:41 UTC (rev 102)
+++ trunk/qcell/basesources/LocalFunction.cpp 2007-01-05 20:28:52 UTC (rev 103)
@@ -138,10 +138,11 @@
functionMode = LocalFunction::SWITCH;
}
-void LocalFunction::init(int numberOfArguments, int alphabetSize)
+void LocalFunction::init(int numberOfArguments, int alphabetSize, int returnValues)
{
numArg = numberOfArguments;
maxArgVal = alphabetSize;
+ maxRetVal = returnValues;
valueTable.clear();
sumArguments.clear();
freeArguments.clear();
@@ -217,6 +218,26 @@
return functionMode;
}
+int LocalFunction::getNumberOfArgs()
+{
+ return maxArgVal;
+}
+
+int LocalFunction::getAlphabetSize()
+{
+ return maxArgVal;
+}
+
+int LocalFunction::getMaxReturnValues()
+{
+ return maxRetVal;
+}
+
+QVector<int> LocalFunction::getSummedArguments()
+{
+ return sumArguments.first();
+}
+
int LocalFunction::addFunctionValueArgumentsNumberRequest(void)
{
switch(functionMode)
Modified: trunk/qcell/parsers/FQT/FQTParserPlugin.cpp
===================================================================
--- trunk/qcell/parsers/FQT/FQTParserPlugin.cpp 2007-01-05 16:06:41 UTC (rev 102)
+++ trunk/qcell/parsers/FQT/FQTParserPlugin.cpp 2007-01-05 20:28:52 UTC (rev 103)
@@ -30,6 +30,9 @@
QMap<int, QVector<int> > results;
// The maximum achivable sum of arguments
int max_sum;
+ // After parsing the header one can determin how many possibilities does the
+ // free arguments post
+ int free_args_columns;
// Generic class for generating XML
LocalFunction lf;
@@ -72,7 +75,6 @@
values_nr = tmp_split[1].toLong();
return_values_nr = tmp_split[2].toLong();
- max_sum = arguments_nr * (values_nr - 1);
if((arguments_nr == 0) || (values_nr == 0) || (return_values_nr == 0))
{
@@ -110,7 +112,7 @@
// Index of arguments gettins summed up
lines[0] = lines[0].trimmed();
- format = QRegExp("^((\\d)+,){" + QString::number(arguments_nr-1) + "}(\\d)+$");
+ format = QRegExp("^((\\d)+,){1-" + QString::number(arguments_nr-2) + "}(\\d)+$");
if(format.exactMatch(lines[0]))
{
int arg_index, arg_nr;
@@ -137,6 +139,9 @@
arg_nr++;
}
+ // Now we can calculate the maximal sum value
+ max_sum = arg_nr * (values_nr - 1);
+ free_args_columns = values_nr^arg_nr;
lines.removeFirst();
line_nr++;
@@ -154,7 +159,7 @@
// Main function parsing
lines[0] = lines[0].trimmed();
- format = QRegExp("^(\\d)+:([0-9a-Z]){" + QString::number(arguments_nr-1) + "}[0-9a-Z]$");
+ format = QRegExp("^(\\d)+:([0-9a-Z]){" + QString::number(free_args_columns-1) + "}[0-9a-Z]$");
QStringList tmp;
int tmp_sum,value_index;
QVector<int> tmp_values;
@@ -228,15 +233,71 @@
line_nr++;
}
+ // All possible permutations of values of free arguments in lexographical order
+ QVector<QVector<int> > permutations;
+
// setting the type of function
lf.setFunctonType(LocalFunction::SUM);
// setting the number of arguments the function will take
// and the alphabet size
- lf.init(arguments_nr, values_nr);
+ lf.init(arguments_nr, values_nr, return_values_nr);
+
+ // Set the arguments numbers tu sum
+ lf.setSumArguments(arguments);
+
/// @todo How the fuck set FQT function parameters eh?
+ foreach(int sum, results.keys())
+ {
+
+ }
return lf.toXmlString();
}
+
+QByteArray FQTParserPlugin::parseOut(QString content, const QString type, const QString subtype)
+{
+ // The resulting array to write to file by the backend
+ QByteArray result;
+ // Generic type to parse XML request
+ LocalFunction lf;
+
+ // Check if we can use the generic type from the XML string
+ if(!lf.fromXmlString(&content));
+ {
+ qDebug(tr("Unable to parse out internal data!").toAscii());
+ }
+
+ // Header
+ result.append("FQT");
+ result.append('\n');
+
+ // Second line
+ // Num of args
+ result.append(lf.getNumberOfArgs());
+ result.append(' ');
+ // Num of arg values
+ result.append(lf.getAlphabetSize());
+ result.append(' ');
+ // Num of return values
+ result.append(lf.getMaxReturnValues());
+ result.append(' ');
+ result.append('\n');
+
+ // Third line - summed args
+ foreach(int arg, lf.getSummedArguments())
+ {
+ result.append(QString::number(arg)[0].toAscii());
+ result.append(',');
+ }
+ // Get rid of the penging `,'
+ result.chop(1);
+ result.append('\n');
+
+ /// @todo Main function writing
+
+ return result;
+}
+
Q_EXPORT_PLUGIN2(FQTFileParser, FQTParserPlugin)
Modified: trunk/qcell/parsers/FQT/FQTParserPlugin.h
===================================================================
--- trunk/qcell/parsers/FQT/FQTParserPlugin.h 2007-01-05 16:06:41 UTC (rev 102)
+++ trunk/qcell/parsers/FQT/FQTParserPlugin.h 2007-01-05 20:28:52 UTC (rev 103)
@@ -21,7 +21,7 @@
{
protected:
QString realParser(const QByteArray content, const QString type, const QString subtype);
-
+ QByteArray parseOut(QString content, const QString type, const QString subtype="");
public:
FQTParserPlugin();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|