LCOV - code coverage report
Current view: top level - slideshow/source/engine - expressionnodefactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 75 0.0 %
Date: 2012-08-25 Functions: 0 46 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : // must be first
      22                 :            : #include <canvas/debug.hxx>
      23                 :            : #include <expressionnodefactory.hxx>
      24                 :            : 
      25                 :            : #include <canvas/verbosetrace.hxx>
      26                 :            : 
      27                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      28                 :            : #include <basegfx/point/b2dpoint.hxx>
      29                 :            : 
      30                 :            : #include <functional>
      31                 :            : #include <algorithm>
      32                 :            : 
      33                 :            : 
      34                 :            : /* Implementation of ExpressionNodeFactory class */
      35                 :            : 
      36                 :            : namespace slideshow
      37                 :            : {
      38                 :            :     namespace internal
      39                 :            :     {
      40                 :            :         namespace
      41                 :            :         {
      42                 :          0 :             class ConstantValueExpression : public ExpressionNode
      43                 :            :             {
      44                 :            :             public:
      45                 :          0 :                 ConstantValueExpression( double rValue ) :
      46                 :          0 :                     maValue( rValue )
      47                 :            :                 {
      48                 :          0 :                 }
      49                 :            : 
      50                 :          0 :                 virtual double operator()( double /*t*/ ) const
      51                 :            :                 {
      52                 :          0 :                     return maValue;
      53                 :            :                 }
      54                 :            : 
      55                 :          0 :                 virtual bool isConstant() const
      56                 :            :                 {
      57                 :          0 :                     return true;
      58                 :            :                 }
      59                 :            : 
      60                 :            :             private:
      61                 :            :                 double  maValue;
      62                 :            :             };
      63                 :            : 
      64                 :          0 :             class TValueExpression : public ExpressionNode
      65                 :            :             {
      66                 :            :             public:
      67                 :          0 :                 TValueExpression()
      68                 :          0 :                 {
      69                 :          0 :                 }
      70                 :            : 
      71                 :          0 :                 virtual double operator()( double t ) const
      72                 :            :                 {
      73                 :          0 :                     return t;
      74                 :            :                 }
      75                 :            : 
      76                 :          0 :                 virtual bool isConstant() const
      77                 :            :                 {
      78                 :          0 :                     return false;
      79                 :            :                 }
      80                 :            :             };
      81                 :            : 
      82                 :            :             /** Base class for following binary functions (*+-/)
      83                 :            : 
      84                 :            :                 Does not pay off to have all this as a template, since
      85                 :            :                 we'd have to hold the functor as a member (+33% object
      86                 :            :                 size).
      87                 :            :              */
      88                 :          0 :             class BinaryExpressionBase : public ExpressionNode
      89                 :            :             {
      90                 :            :             public:
      91                 :          0 :                 BinaryExpressionBase( const ExpressionNodeSharedPtr&    rFirstArg,
      92                 :            :                                       const ExpressionNodeSharedPtr&    rSecondArg ) :
      93                 :            :                     mpFirstArg( rFirstArg ),
      94                 :          0 :                     mpSecondArg( rSecondArg )
      95                 :            :                 {
      96                 :          0 :                 }
      97                 :            : 
      98                 :          0 :                 virtual bool isConstant() const
      99                 :            :                 {
     100                 :            :                     return
     101                 :          0 :                         mpFirstArg->isConstant() &&
     102                 :          0 :                         mpSecondArg->isConstant();
     103                 :            :                 }
     104                 :            : 
     105                 :            :             protected:
     106                 :            :                 ExpressionNodeSharedPtr mpFirstArg;
     107                 :            :                 ExpressionNodeSharedPtr mpSecondArg;
     108                 :            :             };
     109                 :            : 
     110                 :          0 :             class PlusExpression : public BinaryExpressionBase
     111                 :            :             {
     112                 :            :             public:
     113                 :          0 :                 PlusExpression( const ExpressionNodeSharedPtr&  rFirstArg,
     114                 :            :                                 const ExpressionNodeSharedPtr&  rSecondArg ) :
     115                 :          0 :                     BinaryExpressionBase( rFirstArg, rSecondArg )
     116                 :            :                 {
     117                 :          0 :                 }
     118                 :            : 
     119                 :          0 :                 virtual double operator()( double t ) const
     120                 :            :                 {
     121                 :          0 :                     return (*mpFirstArg)(t) + (*mpSecondArg)(t);
     122                 :            :                 }
     123                 :            :             };
     124                 :            : 
     125                 :          0 :             class MinusExpression : public BinaryExpressionBase
     126                 :            :             {
     127                 :            :             public:
     128                 :          0 :                 MinusExpression( const ExpressionNodeSharedPtr& rFirstArg,
     129                 :            :                                  const ExpressionNodeSharedPtr& rSecondArg ) :
     130                 :          0 :                     BinaryExpressionBase( rFirstArg, rSecondArg )
     131                 :            :                 {
     132                 :          0 :                 }
     133                 :            : 
     134                 :          0 :                 virtual double operator()( double t ) const
     135                 :            :                 {
     136                 :          0 :                     return (*mpFirstArg)(t) - (*mpSecondArg)(t);
     137                 :            :                 }
     138                 :            :             };
     139                 :            : 
     140                 :          0 :             class MultipliesExpression : public BinaryExpressionBase
     141                 :            :             {
     142                 :            :             public:
     143                 :          0 :                 MultipliesExpression( const ExpressionNodeSharedPtr&    rFirstArg,
     144                 :            :                                       const ExpressionNodeSharedPtr&    rSecondArg ) :
     145                 :          0 :                     BinaryExpressionBase( rFirstArg, rSecondArg )
     146                 :            :                 {
     147                 :          0 :                 }
     148                 :            : 
     149                 :          0 :                 virtual double operator()( double t ) const
     150                 :            :                 {
     151                 :          0 :                     return (*mpFirstArg)(t) * (*mpSecondArg)(t);
     152                 :            :                 }
     153                 :            :             };
     154                 :            : 
     155                 :          0 :             class DividesExpression : public BinaryExpressionBase
     156                 :            :             {
     157                 :            :             public:
     158                 :          0 :                 DividesExpression( const ExpressionNodeSharedPtr&   rFirstArg,
     159                 :            :                                    const ExpressionNodeSharedPtr&   rSecondArg ) :
     160                 :          0 :                     BinaryExpressionBase( rFirstArg, rSecondArg )
     161                 :            :                 {
     162                 :          0 :                 }
     163                 :            : 
     164                 :          0 :                 virtual double operator()( double t ) const
     165                 :            :                 {
     166                 :          0 :                     return (*mpFirstArg)(t) / (*mpSecondArg)(t);
     167                 :            :                 }
     168                 :            :             };
     169                 :            : 
     170                 :            :             class ComposedExpression : public BinaryExpressionBase
     171                 :            :             {
     172                 :            :             public:
     173                 :            :                 ComposedExpression( const ExpressionNodeSharedPtr&  rFirstArg,
     174                 :            :                                     const ExpressionNodeSharedPtr&  rSecondArg ) :
     175                 :            :                     BinaryExpressionBase( rFirstArg, rSecondArg )
     176                 :            :                 {
     177                 :            :                 }
     178                 :            : 
     179                 :            :                 virtual double operator()( double t ) const
     180                 :            :                 {
     181                 :            :                     return (*mpFirstArg)( (*mpSecondArg)(t) );
     182                 :            :                 }
     183                 :            :             };
     184                 :            : 
     185                 :          0 :             class MinExpression : public BinaryExpressionBase
     186                 :            :             {
     187                 :            :             public:
     188                 :          0 :                 MinExpression( const ExpressionNodeSharedPtr&   rFirstArg,
     189                 :            :                                const ExpressionNodeSharedPtr&   rSecondArg ) :
     190                 :          0 :                     BinaryExpressionBase( rFirstArg, rSecondArg )
     191                 :            :                 {
     192                 :          0 :                 }
     193                 :            : 
     194                 :          0 :                 virtual double operator()( double t ) const
     195                 :            :                 {
     196                 :          0 :                     return ::std::min( (*mpFirstArg)(t), (*mpSecondArg)(t) );
     197                 :            :                 }
     198                 :            :             };
     199                 :            : 
     200                 :          0 :             class MaxExpression : public BinaryExpressionBase
     201                 :            :             {
     202                 :            :             public:
     203                 :          0 :                 MaxExpression( const ExpressionNodeSharedPtr&   rFirstArg,
     204                 :            :                                const ExpressionNodeSharedPtr&   rSecondArg ) :
     205                 :          0 :                     BinaryExpressionBase( rFirstArg, rSecondArg )
     206                 :            :                 {
     207                 :          0 :                 }
     208                 :            : 
     209                 :          0 :                 virtual double operator()( double t ) const
     210                 :            :                 {
     211                 :          0 :                     return ::std::max( (*mpFirstArg)(t), (*mpSecondArg)(t) );
     212                 :            :                 }
     213                 :            :             };
     214                 :            :         }
     215                 :            : 
     216                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createConstantValueExpression( double rConstantValue )
     217                 :            :         {
     218                 :          0 :             return ExpressionNodeSharedPtr( new ConstantValueExpression(rConstantValue) );
     219                 :            :         }
     220                 :            : 
     221                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createValueTExpression()
     222                 :            :         {
     223                 :          0 :             return ExpressionNodeSharedPtr( new TValueExpression() );
     224                 :            :         }
     225                 :            : 
     226                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createPlusExpression( const ExpressionNodeSharedPtr& rLHS,
     227                 :            :                                                                              const ExpressionNodeSharedPtr& rRHS )
     228                 :            :         {
     229                 :          0 :             return ExpressionNodeSharedPtr( new PlusExpression(rLHS, rRHS) );
     230                 :            :         }
     231                 :            : 
     232                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createMinusExpression( const ExpressionNodeSharedPtr&    rLHS,
     233                 :            :                                                                               const ExpressionNodeSharedPtr&    rRHS )
     234                 :            :         {
     235                 :          0 :             return ExpressionNodeSharedPtr( new MinusExpression(rLHS, rRHS) );
     236                 :            :         }
     237                 :            : 
     238                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createMultipliesExpression( const ExpressionNodeSharedPtr&   rLHS,
     239                 :            :                                                                                    const ExpressionNodeSharedPtr&   rRHS )
     240                 :            :         {
     241                 :          0 :             return ExpressionNodeSharedPtr( new MultipliesExpression(rLHS, rRHS) );
     242                 :            :         }
     243                 :            : 
     244                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createDividesExpression( const ExpressionNodeSharedPtr&  rLHS,
     245                 :            :                                                                                 const ExpressionNodeSharedPtr&  rRHS )
     246                 :            :         {
     247                 :          0 :             return ExpressionNodeSharedPtr( new DividesExpression(rLHS, rRHS) );
     248                 :            :         }
     249                 :            : 
     250                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createMinExpression   ( const ExpressionNodeSharedPtr&   rOuterFunction,
     251                 :            :                                                                                const ExpressionNodeSharedPtr&   rInnerFunction )
     252                 :            :         {
     253                 :          0 :             return ExpressionNodeSharedPtr( new MinExpression(rOuterFunction, rInnerFunction) );
     254                 :            :         }
     255                 :            : 
     256                 :          0 :         ExpressionNodeSharedPtr ExpressionNodeFactory::createMaxExpression   ( const ExpressionNodeSharedPtr&   rOuterFunction,
     257                 :            :                                                                                const ExpressionNodeSharedPtr&   rInnerFunction )
     258                 :            :         {
     259                 :          0 :             return ExpressionNodeSharedPtr( new MaxExpression(rOuterFunction, rInnerFunction) );
     260                 :            :         }
     261                 :            : 
     262                 :            :     }
     263                 :            : }
     264                 :            : 
     265                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10