Warning, file /office/calligra/libs/main/KoFilterVertex.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the Calligra libraries
0002    Copyright (C) 2001 Werner Trobin <trobin@kde.org>
0003 
0004 This library is free software; you can redistribute it and/or
0005 modify it under the terms of the GNU Library General Public
0006 License as published by the Free Software Foundation; either
0007 version 2 of the License, or (at your option) any later version.
0008 
0009 This library 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 GNU
0012 Library General Public License for more details.
0013 
0014 You should have received a copy of the GNU Library General Public License
0015 along with this library; see the file COPYING.LIB.  If not, write to
0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017 Boston, MA 02110-1301, USA.
0018 */
0019 #ifndef KOFILTERVERTEX_H
0020 #define KOFILTERVERTEX_H
0021 
0022 #include "KoFilterChain.h"
0023 
0024 namespace CalligraFilter {
0025 template <typename T> class PriorityQueue;
0026 /**
0027  * An internal class representing a mime type (=node, vertex) in the filter graph.
0028  * @internal
0029  */
0030 class Vertex
0031 {
0032 
0033 public:
0034     explicit Vertex(const QByteArray &mimeType);
0035     ~Vertex();
0036 
0037     QByteArray mimeType() const {
0038         return m_mimeType;
0039     }
0040 
0041     // Current "weight" of the vertex - will be "relaxed" when
0042     // running the shortest path algorithm. Returns true if it
0043     // really has been "relaxed"
0044     bool setKey(unsigned int key);
0045 
0046     unsigned int key() const {
0047         return m_weight;
0048     }
0049 
0050     // Can be used to set the key back to "Infinity" (UINT_MAX)
0051     // and reset the predecessor of this vertex
0052     void reset();
0053 
0054     // Position in the heap, needed for a fast keyDecreased operation
0055     void setIndex(int index) {
0056         m_index = index;
0057     }
0058 
0059     int index() const {
0060         return m_index;
0061     }
0062 
0063     // predecessor on the way from the source to the destination,
0064     // needed for the shortest path algorithm
0065     void setPredecessor(const Vertex* predecessor) {
0066         m_predecessor = predecessor;
0067     }
0068 
0069     const Vertex* predecessor() const {
0070         return m_predecessor;
0071     }
0072 
0073     // Adds an outgoing edge to the vertex, transfers ownership
0074     void addEdge(Edge* edge);
0075 
0076     // Finds the lightest(!) edge pointing to the given vertex, if any (0 if not found)
0077     // This means it will always search the whole list of edges
0078     const Edge* findEdge(const Vertex* vertex) const;
0079 
0080     // This method is called when we need to relax all "our" edges.
0081     // We need to pass the queue as we have to notify it about key changes - ugly :(
0082     void relaxVertices(PriorityQueue<Vertex>& queue);
0083 
0084     // debugging
0085     void dump(const QByteArray& indent) const;
0086 
0087 private:
0088 
0089     Vertex(const Vertex& rhs);
0090     Vertex& operator=(const Vertex& rhs);
0091 
0092     QList<Edge*> m_edges;
0093     const Vertex* m_predecessor;
0094     QByteArray m_mimeType;
0095     unsigned int m_weight; // "key" inside the queue
0096     int m_index; // position inside the queue, needed for a fast keyDecreased()
0097 
0098     class Private;
0099     Private * const d;
0100 };
0101 
0102 }
0103 #endif // KOFILTERVERTEX_H