1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef SC_FORMULAGROUP_HXX
#define SC_FORMULAGROUP_HXX
#include "address.hxx"
#include "types.hxx"
#include "platforminfo.hxx"
#include "svl/sharedstringpool.hxx"
#include <vector>
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/unordered_set.hpp>
class ScDocument;
class ScTokenArray;
namespace sc {
struct FormulaGroupContext : boost::noncopyable
{
typedef std::vector<double> NumArrayType;
typedef std::vector<rtl_uString*> StrArrayType;
typedef boost::ptr_vector<NumArrayType> NumArrayStoreType;
typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
struct ColKey
{
SCTAB mnTab;
SCCOL mnCol;
struct Hash
{
size_t operator() ( const ColKey& rKey ) const;
};
ColKey( SCTAB nTab, SCCOL nCol );
bool operator== ( const ColKey& r ) const;
bool operator!= ( const ColKey& r ) const;
};
struct ColArray
{
NumArrayType* mpNumArray;
StrArrayType* mpStrArray;
size_t mnSize;
ColArray( NumArrayType* pNumArray, StrArrayType* pStrArray );
};
typedef boost::unordered_map<ColKey, ColArray, ColKey::Hash> ColArraysType;
NumArrayStoreType maNumArrays; /// manage life cycle of numeric arrays.
StrArrayStoreType maStrArrays; /// manage life cycle of string arrays.
ColArraysType maColArrays; /// keep track of longest array for each column.
ColArray* getCachedColArray( SCTAB nTab, SCCOL nCol, size_t nSize );
ColArray* setCachedColArray(
SCTAB nTab, SCCOL nCol, NumArrayType* pNumArray, StrArrayType* pStrArray );
void ensureStrArray( ColArray& rColArray, size_t nArrayLen );
void ensureNumArray( ColArray& rColArray, size_t nArrayLen );
};
/**
* Abstract base class for a "compiled" formula
*/
class SC_DLLPUBLIC CompiledFormula
{
};
/**
* Abstract base class for vectorised formula group interpreters,
* plus a global instance factory.
*/
class SC_DLLPUBLIC FormulaGroupInterpreter
{
static FormulaGroupInterpreter *msInstance;
protected:
FormulaGroupInterpreter() {}
virtual ~FormulaGroupInterpreter() {}
public:
static FormulaGroupInterpreter *getStatic();
static void fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rPlatforms);
static bool switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation = false);
static void enableOpenCL(bool bEnable);
static void getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId);
virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0;
virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc,
const ScAddress& rTopPos,
ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode) = 0;
virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0;
};
/// Inherit from this for alternate formula group calculation approaches.
class SC_DLLPUBLIC FormulaGroupInterpreterSoftware : public FormulaGroupInterpreter
{
public:
FormulaGroupInterpreterSoftware();
virtual ~FormulaGroupInterpreterSoftware() {}
virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat);
virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc,
const ScAddress& rTopPos,
ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode) SAL_OVERRIDE;
virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) SAL_OVERRIDE;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|