From 950880e4857db7359aa63c0b15a5440e0bfaa135 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Sat, 31 Dec 2005 18:17:04 +0000 Subject: [PATCH] * Two consts are not protected * Some API-docs * Some empty API-Docs * Add the two debug-lines in Makefile.am so that errors show up on ebn. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=492957 --- libscience/Makefile.am | 2 + libscience/moleculeparser.cpp | 37 ++++--- libscience/moleculeparser.h | 187 +++++++++++++++++++++------------- libscience/parser.h | 26 +++-- 4 files changed, 162 insertions(+), 90 deletions(-) diff --git a/libscience/Makefile.am b/libscience/Makefile.am index f40f135..c0d7f55 100644 --- a/libscience/Makefile.am +++ b/libscience/Makefile.am @@ -22,4 +22,6 @@ libscience_la_LIBADD = $(LIB_KDEUI) METASOURCES = AUTO +DOXYGEN_SET_WARN_IF_UNDOCUMENTED = YES +DOXYGEN_SET_INTERNAL_DOCS = YES diff --git a/libscience/moleculeparser.cpp b/libscience/moleculeparser.cpp index d8ccebe..58a6531 100644 --- a/libscience/moleculeparser.cpp +++ b/libscience/moleculeparser.cpp @@ -42,12 +42,19 @@ ElementCountMap::~ElementCountMap() ElementCount * ElementCountMap::search(Element *_element) { - QList::ConstIterator it = m_map.constBegin(); - const QList::ConstIterator itEnd = m_map.constEnd(); - - for (; it != itEnd; ++it) { - if ((*it)->element() == _element) - return *it; + //not yet tested but the commented code should be the same as + //the foreach... so lets use Qt4 power +//X QList::ConstIterator it = m_map.constBegin(); +//X const QList::ConstIterator itEnd = m_map.constEnd(); +//X +//X for (; it != itEnd; ++it) { +//X if ((*it)->element() == _element) +//X return *it; +//X } + + foreach( ElementCount* c, m_map ){ + if ( c->element() == _element ) + return c; } return 0; @@ -57,12 +64,18 @@ ElementCountMap::search(Element *_element) void ElementCountMap::add(ElementCountMap &_map) { - QList::ConstIterator it = _map.m_map.constBegin(); - const QList::ConstIterator itEnd = _map.m_map.constEnd(); - - // Step throught _map and for each element, add it to the current one. - for (; it != itEnd; ++it) { - add((*it)->m_element, (*it)->m_count); + //not yet tested but the commented code should be the same as + //the foreach... so lets use Qt4 power +//X QList::ConstIterator it = _map.m_map.constBegin(); +//X const QList::ConstIterator itEnd = _map.m_map.constEnd(); +//X +//X // Step throught _map and for each element, add it to the current one. +//X for (; it != itEnd; ++it) { +//X add((*it)->m_element, (*it)->m_count); +//X } + + foreach( ElementCount* c, _map.m_map ){ + add( c->m_element, c->m_count ); } } diff --git a/libscience/moleculeparser.h b/libscience/moleculeparser.h index b9ff8e4..57342ed 100644 --- a/libscience/moleculeparser.h +++ b/libscience/moleculeparser.h @@ -17,89 +17,132 @@ #include "element.h" #include "parser.h" -#include -#include +#include +#include /** * @class ElementCountMap + * @author Inge Wallin */ -class ElementCount { - public: - ElementCount(Element *_element, int _count) - { - m_element = _element; - m_count = _count; - } - ElementCount(Element *_element) - { - m_element = _element; - m_count = 0; - } - - ~ElementCount(); - - Element *element() const { return m_element; } - int count() const { return m_count; } - void add(int _count) { m_count += _count; } - void multiply(int _factor) { m_count *= _factor; } - - Element *m_element; - int m_count; +class ElementCount +{ + public: + /** + * Constructor + */ + ElementCount(Element *_element, int _count) + { + m_element = _element; + m_count = _count; + } + + /** + * Constructor + */ + ElementCount(Element *_element) + { + m_element = _element; + m_count = 0; + } + /** + * Destructor + */ + ~ElementCount(); + + /** + * @return the Element + */ + Element *element() const { return m_element; } + + /** + * @return the number of occurences of the Element + */ + int count() const { return m_count; } + + /** + * Add @p _count occurences of the Element + * @param _count The number of times the Element occurs + */ + void add(int _count) { m_count += _count; } + void multiply(int _factor) { m_count *= _factor; } + + /** + * The Element of the object + */ + Element *m_element; + + /** + * The number of occurences + */ + int m_count; }; /** + * This class is used to count the elements in the molecule + * which is being calculated + * * @class ElementCount + * @author Inge Wallin */ -class ElementCountMap { - public: - ElementCountMap(); - ~ElementCountMap(); - - /** - * - */ - void clear() { m_map.clear(); } - - /** - * @param _element - */ - ElementCount *search(Element *_element); - - /** - * @param _map - */ - void add(ElementCountMap &_map); - - /** - * @param _element - * @param _count - */ - void add(Element *_element, int _count); - - /** - * @param _factor - */ - void multiply(int _factor); - - /** - * typedef - */ - typedef QList::Iterator Iterator; - - /** - * - */ - Iterator begin() { return m_map.begin(); } - - /** - * - */ - Iterator end() { return m_map.end(); } - - private: - QList m_map; +class ElementCountMap +{ + public: + /** + * Constructor + */ + ElementCountMap(); + + /** + * Destructor + */ + ~ElementCountMap(); + + /** + * Clear the map of ElementCount pointers + */ + void clear() { m_map.clear(); } + + /** + * @param _element the searched Element + * @return the Element which is searched + */ + ElementCount *search(Element *_element); + + /** + * @param _map + */ + void add(ElementCountMap &_map); + + /** + * @param _element + * @param _count + */ + void add(Element *_element, int _count); + + /** + * @param _factor + */ + void multiply(int _factor); + + /** + * typedef + */ + typedef QList::Iterator Iterator; + + /** + * + */ + Iterator begin() { return m_map.begin(); } + + /** + * + */ + Iterator end() { return m_map.end(); } + + private: + QList m_map; }; diff --git a/libscience/parser.h b/libscience/parser.h index ee2437b..5fa840a 100644 --- a/libscience/parser.h +++ b/libscience/parser.h @@ -14,7 +14,7 @@ #ifndef PARSER_H #define PARSER_H -#include +#include /** * @class Parser @@ -26,11 +26,6 @@ */ class Parser { public: - // All characters are their own token value per default. - static const int INT_TOKEN = 257; - static const int FLOAT_TOKEN = 258; - // Extend this list in your subclass to make a more advanced parser. - /** * Constructor */ @@ -76,6 +71,17 @@ private: bool parseSimpleFloat(double *_result); protected: + /** + * All characters are their own token value per default. + * Extend this list in your subclass to make a more advanced parser. + */ + static const int INT_TOKEN = 257; + + /** + * All characters are their own token value per default. + * Extend this list in your subclass to make a more advanced parser. + */ + static const int FLOAT_TOKEN = 258; /** * Make the next character the current one. @@ -112,7 +118,15 @@ private: // union, but I don't think it is necessary to bother, since they // are so few and we don't instantiate a lot of copies of the // parser. + + /** + * Valid if m_nextToken == INT_TOKEN + */ int m_intVal; // Valid if m_nextToken == INT_TOKEN + + /** + * Valid if m_nextToken == FLOAT_TOKEN + */ double m_floatVal; // Valid if m_nextToken == FLOAT_TOKEN }; -- 2.47.3