Kaydet (Commit) b81d1306 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Kohei Yoshida

Dummy formula group interpreter for testing.

üst 1eb0aac3
...@@ -30,9 +30,8 @@ struct FormulaGroupContext : boost::noncopyable ...@@ -30,9 +30,8 @@ struct FormulaGroupContext : boost::noncopyable
}; };
/** /**
* All the vectorized formula calculation code should be collected here. * Abstract base class for vectorised formula group interpreters,
* * plus a global instance factory.
* Abstract base class for formula group interpreters, and a factory.
*/ */
class SC_DLLPUBLIC FormulaGroupInterpreter class SC_DLLPUBLIC FormulaGroupInterpreter
{ {
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <vector> #include <vector>
#define USE_DUMMY_INTERPRETER 1
namespace sc { namespace sc {
ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& /*rMat*/) ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& /*rMat*/)
...@@ -108,14 +110,61 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres ...@@ -108,14 +110,61 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
namespace opencl { namespace opencl {
extern sc::FormulaGroupInterpreter *createFormulaGroupInterpreter(); extern sc::FormulaGroupInterpreter *createFormulaGroupInterpreter();
} }
FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL; FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL;
#if USE_DUMMY_INTERPRETER
class FormulaGroupInterpreterDummy : public FormulaGroupInterpreter
{
enum Mode {
WRITE_OUTPUT = 0
};
Mode meMode;
public:
FormulaGroupInterpreterDummy()
{
const char *pValue = getenv("FORMULA_GROUP_DUMMY");
meMode = static_cast<Mode>(OString(pValue, strlen(pValue)).toInt32());
fprintf(stderr, "Using Dummy Formula Group interpreter mode %d\n", (int)meMode);
}
virtual ScMatrixRef inverseMatrix(const ScMatrix& /*rMat*/)
{
return ScMatrixRef();
}
virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos,
const ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode)
{
(void)rCode;
// Write simple data back into the sheet
if (meMode == WRITE_OUTPUT)
{
double *pDoubles = new double[xGroup->mnLength];
for (sal_Int32 i = 0; i < xGroup->mnLength; i++)
pDoubles[i] = 42.0 + i;
rDoc.SetFormulaResults(rTopPos, pDoubles, xGroup->mnLength);
delete [] pDoubles;
}
return true;
}
};
#endif
/// load and/or configure the correct formula group interpreter /// load and/or configure the correct formula group interpreter
FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic() FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
{ {
static bool bOpenCLEnabled = false; static bool bOpenCLEnabled = false;
#if USE_DUMMY_INTERPRETER
if (getenv("FORMULA_GROUP_DUMMY"))
{
delete msInstance;
return msInstance = new sc::FormulaGroupInterpreterDummy();
}
#endif
if ( msInstance && if ( msInstance &&
bOpenCLEnabled != ScInterpreter::GetGlobalConfig().mbOpenCLEnabled ) bOpenCLEnabled != ScInterpreter::GetGlobalConfig().mbOpenCLEnabled )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment