• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

Analitza

  • sources
  • kde-4.14
  • kdeedu
  • analitza
  • analitza
expressiontype.h
Go to the documentation of this file.
1 /*************************************************************************************
2  * Copyright (C) 2010 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 EXPRESSIONTYPE_H
20 #define EXPRESSIONTYPE_H
21 
22 #include "analitzaexport.h"
23 #include <QString>
24 #include <QList>
25 #include <QMap>
26 
27 namespace Analitza
28 {
29 
30 class ANALITZA_EXPORT ExpressionType
31 {
32  public:
34  enum Type { Error=0, Value, Vector, List, Lambda, Any, Many, Object, Char, Bool, Matrix };
35  QString toString() const;
36 
37  ExpressionType(Type t=Error, int any=-1);
38  ExpressionType(Type t, const ExpressionType& contained, int s=0);
39  ExpressionType(Type t, const QList<ExpressionType>& alternatives);
40 
42  ExpressionType(const QString& objectName);
43  ExpressionType(const ExpressionType& t);
44 
45  ~ExpressionType() {/* delete contained; */}
46 
47  bool operator==(const ExpressionType& t) const;
48  bool operator!=(const ExpressionType& t) const { return !operator==(t); }
49  ExpressionType operator=(const ExpressionType& et);
50 
52  bool isError() const;
53 
54  Type type() const { return m_type; }
55  ExpressionType contained() const;
56  QList<ExpressionType> alternatives() const { Q_ASSERT(m_type==Many); return m_contained; }
57 
59  void addAlternative(const ExpressionType& t);
60  int size() const { return m_size; }
61  int anyValue() const { return m_any; }
62 
63  ExpressionType& addParameter(const ExpressionType& t);
64  QList<ExpressionType> parameters() const { Q_ASSERT(m_type==Lambda); return m_contained; }
65  QList<ExpressionType>& parameters() { Q_ASSERT(m_type==Lambda); return m_contained; }
66  ExpressionType returnValue() const;
67 
68  bool addAssumption(const QString& bvar, const ExpressionType& t);
69  QMap<QString, ExpressionType> assumptions() const;
70  QMap<QString, ExpressionType>& assumptions();
71  ExpressionType assumptionFor(const QString& bvar) const { return m_assumptions.value(bvar); }
72  void addAssumptions(const QMap< QString, ExpressionType >& a);
73  void clearAssumptions();
74 
76  ExpressionType starsToType(const QMap<int, ExpressionType>& info) const;
77 
79  bool canReduceTo(const ExpressionType& type) const;
80 
85  bool canCompareTo(const ExpressionType& type) const;
86 
87  int increaseStars(int stars);
88 
89  ExpressionType& simplifyStars();
90 
92  void reduce(const ExpressionType& type);
93 
95  QString objectName() const;
96 
97  static ExpressionType minimumType(const ExpressionType& t1, const ExpressionType& t2);
98  static bool assumptionsMerge(QMap<QString, ExpressionType>& data, const QMap<QString, ExpressionType>& newmap);
99  static void assumptionsUnion(QMap<QString, ExpressionType>& data, const QMap<QString, ExpressionType>& newmap);
100  static QMap<int, ExpressionType> computeStars(const QMap<int, ExpressionType>& initial, const ExpressionType& candidate, const ExpressionType& type);
101  static bool matchAssumptions(QMap<int, ExpressionType>* stars, const QMap<QString, ExpressionType>& assum1, const QMap<QString, ExpressionType>& assum2);
102  static QStringList wrongAssumptions(const QMap<QString, ExpressionType>& assum1, const QMap<QString, ExpressionType>& assum2);
103  void removeAssumptions(const QStringList& bvarStrings);
104  static QList<ExpressionType> lambdaFromArgs(const QList<ExpressionType>& args);
105  static QList<ExpressionType> manyFromArgs(const QList<ExpressionType>& args);
106  private:
107  static void starsSimplification(ExpressionType& t, QMap<int, int>& reductions, int& next);
108 
109  Type m_type;
111  QList<ExpressionType> m_contained;
112  QMap<QString, ExpressionType> m_assumptions;
113  union { int m_size; int m_any; };
114  QString m_objectName;
115 };
116 
117 }
118 
119 Q_DECLARE_TYPEINFO ( Analitza::ExpressionType, Q_MOVABLE_TYPE);
120 
121 #endif // EXPRESSIONTYPE_H
Analitza::ExpressionType::Type
Type
Just use undefined type when returning from a recursion.
Definition: expressiontype.h:34
Analitza::ExpressionType::~ExpressionType
~ExpressionType()
Definition: expressiontype.h:45
QMap
Analitza::ExpressionType::type
Type type() const
Definition: expressiontype.h:54
Analitza::Matrix
Definition: matrix.h:38
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(Analitza::ExpressionType, Q_MOVABLE_TYPE)
Analitza::ExpressionType
Definition: expressiontype.h:30
QString
QList
Analitza::ExpressionType::Vector
Definition: expressiontype.h:34
QStringList
Analitza::ExpressionType::alternatives
QList< ExpressionType > alternatives() const
Definition: expressiontype.h:56
Analitza::ExpressionType::size
int size() const
Definition: expressiontype.h:60
Analitza::ExpressionType::parameters
QList< ExpressionType > & parameters()
Definition: expressiontype.h:65
Analitza::ExpressionType::anyValue
int anyValue() const
Definition: expressiontype.h:61
analitzaexport.h
Analitza::ExpressionType::m_size
int m_size
Definition: expressiontype.h:113
Analitza::Object
Definition: object.h:38
ANALITZA_EXPORT
#define ANALITZA_EXPORT
Definition: analitzaexport.h:31
Analitza::ExpressionType::parameters
QList< ExpressionType > parameters() const
Definition: expressiontype.h:64
Analitza::List
Definition: list.h:34
Analitza::ExpressionType::operator!=
bool operator!=(const ExpressionType &t) const
Definition: expressiontype.h:48
Analitza::ExpressionType::assumptionFor
ExpressionType assumptionFor(const QString &bvar) const
Definition: expressiontype.h:71
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:37 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Analitza

Skip menu "Analitza"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal