LCOV - code coverage report
Current view: top level - sc/inc - formulagroup.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 3 0.0 %
Date: 2014-11-03 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 "address.hxx"
      14             : #include "types.hxx"
      15             : #include "platforminfo.hxx"
      16             : #include "stlalgorithm.hxx"
      17             : 
      18             : #include <svl/sharedstringpool.hxx>
      19             : 
      20             : #include <vector>
      21             : #include <boost/noncopyable.hpp>
      22             : #include <boost/ptr_container/ptr_vector.hpp>
      23             : #include <boost/unordered_set.hpp>
      24             : 
      25             : class ScDocument;
      26             : class ScTokenArray;
      27             : class ScFormulaCell;
      28             : 
      29             : namespace sc {
      30             : 
      31             : struct FormulaGroupEntry
      32             : {
      33             :     union
      34             :     {
      35             :         ScFormulaCell* mpCell;   // non-shared formula cell
      36             :         ScFormulaCell** mpCells; // pointer to the top formula cell in a shared group.
      37             :     };
      38             : 
      39             :     size_t mnRow;
      40             :     size_t mnLength;
      41             :     bool mbShared;
      42             : 
      43             :     FormulaGroupEntry( ScFormulaCell** pCells, size_t nRow, size_t nLength );
      44             : 
      45             :     FormulaGroupEntry( ScFormulaCell* pCell, size_t nRow );
      46             : };
      47             : 
      48             : struct FormulaGroupContext : boost::noncopyable
      49             : {
      50             :     typedef AlignedAllocator<double,256> DoubleAllocType;
      51             :     typedef std::vector<double, DoubleAllocType> NumArrayType;
      52             :     typedef std::vector<rtl_uString*> StrArrayType;
      53             :     typedef boost::ptr_vector<NumArrayType> NumArrayStoreType;
      54             :     typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
      55             : 
      56             :     struct ColKey
      57             :     {
      58             :         SCTAB mnTab;
      59             :         SCCOL mnCol;
      60             : 
      61             :         struct Hash
      62             :         {
      63             :             size_t operator() ( const ColKey& rKey ) const;
      64             :         };
      65             : 
      66             :         ColKey( SCTAB nTab, SCCOL nCol );
      67             : 
      68             :         bool operator== ( const ColKey& r ) const;
      69             :         bool operator!= ( const ColKey& r ) const;
      70             :     };
      71             : 
      72             :     struct ColArray
      73             :     {
      74             :         NumArrayType* mpNumArray;
      75             :         StrArrayType* mpStrArray;
      76             :         size_t mnSize;
      77             : 
      78             :         ColArray( NumArrayType* pNumArray, StrArrayType* pStrArray );
      79             :     };
      80             : 
      81             :     typedef boost::unordered_map<ColKey, ColArray, ColKey::Hash> ColArraysType;
      82             : 
      83             :     NumArrayStoreType maNumArrays; /// manage life cycle of numeric arrays.
      84             :     StrArrayStoreType maStrArrays; /// manage life cycle of string arrays.
      85             : 
      86             :     ColArraysType maColArrays; /// keep track of longest array for each column.
      87             : 
      88             :     ColArray* getCachedColArray( SCTAB nTab, SCCOL nCol, size_t nSize );
      89             : 
      90             :     ColArray* setCachedColArray(
      91             :         SCTAB nTab, SCCOL nCol, NumArrayType* pNumArray, StrArrayType* pStrArray );
      92             : 
      93             :     void ensureStrArray( ColArray& rColArray, size_t nArrayLen );
      94             :     void ensureNumArray( ColArray& rColArray, size_t nArrayLen );
      95             : 
      96             :     FormulaGroupContext();
      97             :     ~FormulaGroupContext();
      98             : };
      99             : 
     100             : /**
     101             :  * Abstract base class for a "compiled" formula
     102             :  */
     103             : class SC_DLLPUBLIC CompiledFormula
     104             : {
     105             : public:
     106             :     CompiledFormula();
     107             :     virtual ~CompiledFormula();
     108             : };
     109             : 
     110             : /**
     111             :  * Abstract base class for vectorised formula group interpreters,
     112             :  * plus a global instance factory.
     113             :  */
     114             : class SC_DLLPUBLIC FormulaGroupInterpreter
     115             : {
     116             :     static FormulaGroupInterpreter *msInstance;
     117             :  protected:
     118           0 :     FormulaGroupInterpreter() {}
     119           0 :     virtual ~FormulaGroupInterpreter() {}
     120             : 
     121             :  public:
     122             :     static FormulaGroupInterpreter *getStatic();
     123             :     static void fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms);
     124             :     static bool switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation = false);
     125             :     static void enableOpenCL(bool bEnable);
     126             :     static void getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId);
     127             : 
     128             :     virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0;
     129             :     virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc,
     130             :                                                    const ScAddress& rTopPos,
     131             :                                                    ScFormulaCellGroup& rGroup,
     132             :                                                    ScTokenArray& rCode) = 0;
     133             :     virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0;
     134             : };
     135             : 
     136             : /// Inherit from this for alternate formula group calculation approaches.
     137             : class SC_DLLPUBLIC FormulaGroupInterpreterSoftware : public FormulaGroupInterpreter
     138             : {
     139             : public:
     140             :     FormulaGroupInterpreterSoftware();
     141           0 :     virtual ~FormulaGroupInterpreterSoftware() {}
     142             : 
     143             :     virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) SAL_OVERRIDE;
     144             :     virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc,
     145             :                                                    const ScAddress& rTopPos,
     146             :                                                    ScFormulaCellGroup& rGroup,
     147             :                                                    ScTokenArray& rCode) SAL_OVERRIDE;
     148             :     virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) SAL_OVERRIDE;
     149             : };
     150             : 
     151             : }
     152             : 
     153             : #endif
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10