LCOV - code coverage report
Current view: top level - sc/inc - formulagroup.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 3 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef INCLUDED_SC_INC_FORMULAGROUP_HXX
      11             : #define INCLUDED_SC_INC_FORMULAGROUP_HXX
      12             : 
      13             : #include <config_features.h>
      14             : 
      15             : #include "address.hxx"
      16             : #include "calcconfig.hxx"
      17             : #include "types.hxx"
      18             : #include "stlalgorithm.hxx"
      19             : 
      20             : #include <formula/opcode.hxx>
      21             : #if HAVE_FEATURE_OPENCL
      22             : #include <opencl/platforminfo.hxx>
      23             : #endif
      24             : #include <svl/sharedstringpool.hxx>
      25             : 
      26             : #include <set>
      27             : #include <unordered_map>
      28             : #include <vector>
      29             : #include <boost/noncopyable.hpp>
      30             : #include <boost/ptr_container/ptr_vector.hpp>
      31             : 
      32             : class ScDocument;
      33             : class ScTokenArray;
      34             : class ScFormulaCell;
      35             : 
      36             : namespace sc {
      37             : 
      38             : struct FormulaGroupEntry
      39             : {
      40             :     union
      41             :     {
      42             :         ScFormulaCell* mpCell;   // non-shared formula cell
      43             :         ScFormulaCell** mpCells; // pointer to the top formula cell in a shared group.
      44             :     };
      45             : 
      46             :     size_t mnRow;
      47             :     size_t mnLength;
      48             :     bool mbShared;
      49             : 
      50             :     FormulaGroupEntry( ScFormulaCell** pCells, size_t nRow, size_t nLength );
      51             : 
      52             :     FormulaGroupEntry( ScFormulaCell* pCell, size_t nRow );
      53             : };
      54             : 
      55             : struct FormulaGroupContext : boost::noncopyable
      56             : {
      57             :     typedef AlignedAllocator<double,256> DoubleAllocType;
      58             :     typedef std::vector<double, DoubleAllocType> NumArrayType;
      59             :     typedef std::vector<rtl_uString*> StrArrayType;
      60             :     typedef boost::ptr_vector<NumArrayType> NumArrayStoreType;
      61             :     typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
      62             : 
      63             :     struct ColKey
      64             :     {
      65             :         SCTAB mnTab;
      66             :         SCCOL mnCol;
      67             : 
      68             :         struct Hash
      69             :         {
      70             :             size_t operator() ( const ColKey& rKey ) const;
      71             :         };
      72             : 
      73             :         ColKey( SCTAB nTab, SCCOL nCol );
      74             : 
      75             :         bool operator== ( const ColKey& r ) const;
      76             :         bool operator!= ( const ColKey& r ) const;
      77             :     };
      78             : 
      79             :     struct ColArray
      80             :     {
      81             :         NumArrayType* mpNumArray;
      82             :         StrArrayType* mpStrArray;
      83             :         size_t mnSize;
      84             : 
      85             :         ColArray( NumArrayType* pNumArray, StrArrayType* pStrArray );
      86             :     };
      87             : 
      88             :     typedef std::unordered_map<ColKey, ColArray, ColKey::Hash> ColArraysType;
      89             : 
      90             :     NumArrayStoreType maNumArrays; /// manage life cycle of numeric arrays.
      91             :     StrArrayStoreType maStrArrays; /// manage life cycle of string arrays.
      92             : 
      93             :     ColArraysType maColArrays; /// keep track of longest array for each column.
      94             : 
      95             :     ColArray* getCachedColArray( SCTAB nTab, SCCOL nCol, size_t nSize );
      96             : 
      97             :     ColArray* setCachedColArray(
      98             :         SCTAB nTab, SCCOL nCol, NumArrayType* pNumArray, StrArrayType* pStrArray );
      99             : 
     100             :     void ensureStrArray( ColArray& rColArray, size_t nArrayLen );
     101             :     void ensureNumArray( ColArray& rColArray, size_t nArrayLen );
     102             : 
     103             :     FormulaGroupContext();
     104             :     ~FormulaGroupContext();
     105             : };
     106             : 
     107             : /**
     108             :  * Abstract base class for a "compiled" formula
     109             :  */
     110             : class SC_DLLPUBLIC CompiledFormula
     111             : {
     112             : public:
     113             :     CompiledFormula();
     114             :     virtual ~CompiledFormula();
     115             : };
     116             : 
     117             : /**
     118             :  * Abstract base class for vectorised formula group interpreters,
     119             :  * plus a global instance factory.
     120             :  */
     121             : class SC_DLLPUBLIC FormulaGroupInterpreter
     122             : {
     123             :     static FormulaGroupInterpreter *msInstance;
     124             : 
     125             : protected:
     126             :     ScCalcConfig maCalcConfig;
     127             : 
     128           0 :     FormulaGroupInterpreter() {}
     129           0 :     virtual ~FormulaGroupInterpreter() {}
     130             : 
     131             :     /// Merge global and document specific settings.
     132             :     void MergeCalcConfig(const ScDocument& rDoc);
     133             : 
     134             : public:
     135             :     static FormulaGroupInterpreter *getStatic();
     136             : #if HAVE_FEATURE_OPENCL
     137             :     static void fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms);
     138             :     static bool switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation = false);
     139             :     // This is intended to be called from opencl-test.cxx only
     140             :     static void enableOpenCL_UnitTestsOnly();
     141             :     static void getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId);
     142             : #endif
     143             :     virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0;
     144             :     virtual CompiledFormula* createCompiledFormula( ScFormulaCellGroup& rGroup, ScTokenArray& rCode ) = 0;
     145             :     virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0;
     146             : };
     147             : 
     148             : /// Inherit from this for alternate formula group calculation approaches.
     149             : class SC_DLLPUBLIC FormulaGroupInterpreterSoftware : public FormulaGroupInterpreter
     150             : {
     151             : public:
     152             :     FormulaGroupInterpreterSoftware();
     153           0 :     virtual ~FormulaGroupInterpreterSoftware() {}
     154             : 
     155             :     virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) SAL_OVERRIDE;
     156             :     virtual CompiledFormula* createCompiledFormula( ScFormulaCellGroup& rGroup, ScTokenArray& rCode ) SAL_OVERRIDE;
     157             :     virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) SAL_OVERRIDE;
     158             : };
     159             : 
     160             : }
     161             : 
     162             : #endif
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11