1 /*************************************************************************************
2  *  Copyright (C) 2007 by Aleix Pol <aleixpol@kde.org>                               *
3  *                                                                                   *
4  *  This program is free software; you can redistribute it and/or                    *
5  *  modify it under the terms of the GNU General Public License                      *
6  *  as published by the Free Software Foundation; either version 2                   *
7  *  of the License, or (at your option) any later version.                           *
8  *                                                                                   *
9  *  This program is distributed in the hope that it will be useful,                  *
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
12  *  GNU General Public License for more details.                                     *
13  *                                                                                   *
14  *  You should have received a copy of the GNU General Public License                *
15  *  along with this program; if not, write to the Free Software                      *
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
17  *************************************************************************************/
18 
19 #ifndef PROVIDEDERIVATIVE_H
20 #define PROVIDEDERIVATIVE_H
21 #include "abstractexpressiontransformer.h"
22 #include <QList>
23 #include <QPair>
24 #include <QStringList>
25 
26 namespace Analitza
27 {
28 
29 class ProvideDerivative : public AbstractExpressionTransformer
30 {
31     public:
32         explicit ProvideDerivative(const QString& var);
33         Object* run(const Object* o);
34 
isCorrect()35         bool isCorrect() const { return m_errors.isEmpty(); }
errors()36         QStringList errors() const { return m_errors; }
37 
38     private:
39         QStringList m_errors;
40         virtual Object* walkApply(const Analitza::Apply* pattern) override;
41 
42         Object* derivateContentVector(const Vector* v);
43         Object* derivateContentList(const List* v);
44         Object* derivativeContainer(const Container *c);
45         Object* derivativeApply(const Apply *c);
46 
47         Apply* makeDiff(Analitza::Object* o) const;
48         void clearDiff(Apply* a);
49         QString var;
50 };
51 
52 }
53 #endif // PROVIDEDERIVATIVE_H
54