File indexing completed on 2024-05-12 15:26:38

0001 /***************************************************************************
0002     File                 : AbstractFilter.h
0003     Project              : SciDAVis
0004     --------------------------------------------------------------------
0005     Copyright            : (C) 2007,2008 by Knut Franke, Tilman Benkert
0006     Email (use @ for *)  : knut.franke*gmx.de, thzs*gmx.net
0007     Description          : Base class for all analysis operations.
0008 
0009  ***************************************************************************/
0010 
0011 /***************************************************************************
0012  *                                                                         *
0013  *  This program is free software; you can redistribute it and/or modify   *
0014  *  it under the terms of the GNU General Public License as published by   *
0015  *  the Free Software Foundation; either version 2 of the License, or      *
0016  *  (at your option) any later version.                                    *
0017  *                                                                         *
0018  *  This program is distributed in the hope that it will be useful,        *
0019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0021  *  GNU General Public License for more details.                           *
0022  *                                                                         *
0023  *   You should have received a copy of the GNU General Public License     *
0024  *   along with this program; if not, write to the Free Software           *
0025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0026  *   Boston, MA  02110-1301  USA                                           *
0027  *                                                                         *
0028  ***************************************************************************/
0029 #ifndef ABSTRACT_FILTER_H
0030 #define ABSTRACT_FILTER_H
0031 
0032 #include "AbstractAspect.h"
0033 #include <QVector>
0034 
0035 class AbstractColumn;
0036 
0037 class AbstractFilter : public AbstractAspect {
0038     Q_OBJECT
0039 
0040 public:
0041     explicit AbstractFilter(const QString& name) : AbstractAspect(name, AspectType::AbstractFilter) {}
0042     ~AbstractFilter() override = default;
0043 
0044     virtual int inputCount() const = 0;
0045     virtual int outputCount() const = 0;
0046     int highestConnectedInput() const;
0047     bool input(int port, const AbstractColumn* source);
0048     bool input(const AbstractFilter* sources);
0049     const AbstractColumn* input(int port) const;
0050     virtual QString inputLabel(int port) const;
0051     virtual AbstractColumn* output(int port = 0) = 0;
0052     virtual const AbstractColumn* output(int port = 0) const = 0;
0053 
0054     int portIndexOf(const AbstractColumn* column);
0055 
0056 protected:
0057     virtual bool inputAcceptable(int port, const AbstractColumn* source);
0058     virtual void inputAboutToBeDisconnected(const AbstractColumn* source);
0059 
0060 protected slots:
0061     virtual void inputDescriptionAboutToChange(const AbstractColumn* source);
0062     void inputDescriptionAboutToChange(const AbstractAspect* aspect);
0063     virtual void inputDescriptionChanged(const AbstractColumn* source);
0064     void inputDescriptionChanged(const AbstractAspect* aspect);
0065     virtual void inputPlotDesignationAboutToChange(const AbstractColumn* source);
0066 
0067     virtual void inputPlotDesignationChanged(const AbstractColumn* source);
0068     virtual void inputModeAboutToChange(const AbstractColumn* source);
0069     virtual void inputModeChanged(const AbstractColumn* source);
0070     virtual void inputDataAboutToChange(const AbstractColumn* source);
0071     virtual void inputDataChanged(const AbstractColumn* source);
0072 
0073     virtual void inputRowsAboutToBeInserted(const AbstractColumn* source, int before, int count) {
0074         Q_UNUSED(source); Q_UNUSED(before); Q_UNUSED(count);
0075     }
0076     virtual void inputRowsInserted(const AbstractColumn* source, int before, int count) {
0077         Q_UNUSED(source); Q_UNUSED(before); Q_UNUSED(count);
0078     }
0079     virtual void inputRowsAboutToBeRemoved(const AbstractColumn* source, int first, int count) {
0080         Q_UNUSED(source); Q_UNUSED(first); Q_UNUSED(count);
0081     }
0082     virtual void inputRowsRemoved(const AbstractColumn* source, int first, int count) {
0083         Q_UNUSED(source); Q_UNUSED(first); Q_UNUSED(count);
0084     }
0085     virtual void inputMaskingAboutToChange(const AbstractColumn* source) {
0086         Q_UNUSED(source);
0087     }
0088     virtual void inputMaskingChanged(const AbstractColumn* source) {
0089         Q_UNUSED(source);
0090     }
0091     void inputAboutToBeDestroyed(const AbstractColumn* source) {
0092         input(portIndexOf(source), nullptr);
0093     }
0094 
0095 protected:
0096     QVector<const AbstractColumn*> m_inputs;
0097 };
0098 
0099 #endif // ifndef ABSTRACT_FILTER_H
0100