File indexing completed on 2024-04-28 03:40:40
0001 /************************************************************************************* 0002 * Copyright (C) 2007-2010 by Aleix Pol <aleixpol@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #ifndef APPLY_H 0020 #define APPLY_H 0021 #include "object.h" 0022 #include "analitzaexport.h" 0023 #include "operator.h" 0024 0025 namespace Analitza 0026 { 0027 class Operator; 0028 class Ci; 0029 0030 /** 0031 * \class Apply 0032 * 0033 * \ingroup AnalitzaModule 0034 * 0035 * \brief This class is the one that will correspond to MathML apply tags. 0036 * 0037 * Stores and helps to retrieve any data it has inside like bvars, 0038 * operators and values. 0039 */ 0040 0041 class ANALITZA_EXPORT Apply : public Object 0042 { 0043 public: 0044 Apply(); 0045 ~Apply() override; 0046 0047 typedef QVector<Object*>::const_iterator const_iterator; 0048 typedef QVector<Object*>::iterator iterator; 0049 0050 virtual Apply* copy() const override; 0051 virtual bool matches(const Analitza::Object* exp, QMap< QString, const Analitza::Object* >* found) const override; 0052 virtual QVariant accept(AbstractExpressionVisitor* exp) const override; 0053 const Operator& firstOperator() const { return m_op; } 0054 int countValues() const { return m_params.size(); } 0055 0056 void prependBranch(Object* o); 0057 void appendBranch(Object* o); 0058 0059 /** Adds @p bvar into the list of bvars */ 0060 void addBVar(Analitza::Ci* bvar); 0061 0062 /** Returns whether that apply has any bvar */ 0063 bool hasBVars() const { return !m_bvars.isEmpty(); } 0064 0065 /** Returns the apply's bvars names */ 0066 QStringList bvarStrings() const; 0067 Object* ulimit() const { return m_ulimit; } 0068 Object* dlimit() const { return m_dlimit; } 0069 Object* domain() const { return m_domain; } 0070 0071 Object*& ulimit() { return m_ulimit; } 0072 Object*& dlimit() { return m_dlimit; } 0073 Object*& domain() { return m_domain; } 0074 0075 /** @deprecated should use begin() now */ 0076 iterator firstValue() { return m_params.begin(); } 0077 iterator begin() { return m_params.begin(); } 0078 iterator end() { return m_params.end(); } 0079 const_iterator firstValue() const { return m_params.constBegin(); } 0080 const_iterator constBegin() const { return m_params.constBegin(); } 0081 const_iterator constEnd() const { return m_params.constEnd(); } 0082 QVector<Ci*> bvarCi() const { return m_bvars; } 0083 bool isUnary() const { return m_params.size()==1; } 0084 bool isEmpty() const { return m_params.isEmpty(); } 0085 bool operator==(const Apply& a) const; 0086 0087 /** Adds a @p o branch right after @p before of the Container. */ 0088 void insertBranch(const Apply::iterator &before, Object* o) { m_params.insert(before, o); } 0089 QVector<Object*> values() const { return m_params; } 0090 Object* at(int p) const; 0091 0092 /** @returns if there's any bounding specified */ 0093 bool hasBoundings() const; 0094 0095 QVector<Object*> m_params; 0096 private: 0097 Apply(const Apply& ); 0098 bool addBranch(Object* o); 0099 0100 Object* m_ulimit, *m_dlimit, *m_domain; 0101 QVector<Ci*> m_bvars; 0102 Operator m_op; 0103 }; 0104 0105 } 0106 #endif // APPLY_H