[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/libkdeedu/libscience
From: Carsten Niehaus <cniehaus () gmx ! de>
Date: 2005-12-31 18:17:06
Message-ID: 1136053026.374999.10043.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 492957 by cniehaus:
* 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.
M +2 -0 Makefile.am
M +23 -10 moleculeparser.cpp
M +109 -66 moleculeparser.h
M +20 -6 parser.h
--- trunk/KDE/kdeedu/libkdeedu/libscience/Makefile.am #492956:492957
@@ -22,4 +22,6 @@
METASOURCES = AUTO
+DOXYGEN_SET_WARN_IF_UNDOCUMENTED = YES
+DOXYGEN_SET_INTERNAL_DOCS = YES
--- trunk/KDE/kdeedu/libkdeedu/libscience/moleculeparser.cpp #492956:492957
@@ -42,12 +42,19 @@
ElementCount *
ElementCountMap::search(Element *_element)
{
- QList<ElementCount *>::ConstIterator it = m_map.constBegin();
- const QList<ElementCount *>::ConstIterator itEnd = m_map.constEnd();
+ //not yet tested but the commented code should be the same as
+ //the foreach... so lets use Qt4 power
+//X QList<ElementCount *>::ConstIterator it = m_map.constBegin();
+//X const QList<ElementCount *>::ConstIterator itEnd = m_map.constEnd();
+//X
+//X for (; it != itEnd; ++it) {
+//X if ((*it)->element() == _element)
+//X return *it;
+//X }
- for (; it != itEnd; ++it) {
- if ((*it)->element() == _element)
- return *it;
+ foreach( ElementCount* c, m_map ){
+ if ( c->element() == _element )
+ return c;
}
return 0;
@@ -57,12 +64,18 @@
void
ElementCountMap::add(ElementCountMap &_map)
{
- QList<ElementCount *>::ConstIterator it = _map.m_map.constBegin();
- const QList<ElementCount *>::ConstIterator itEnd = _map.m_map.constEnd();
+ //not yet tested but the commented code should be the same as
+ //the foreach... so lets use Qt4 power
+//X QList<ElementCount *>::ConstIterator it = _map.m_map.constBegin();
+//X const QList<ElementCount *>::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 }
- // Step throught _map and for each element, add it to the current one.
- for (; it != itEnd; ++it) {
- add((*it)->m_element, (*it)->m_count);
+ foreach( ElementCount* c, _map.m_map ){
+ add( c->m_element, c->m_count );
}
}
--- trunk/KDE/kdeedu/libkdeedu/libscience/moleculeparser.h #492956:492957
@@ -17,89 +17,132 @@
#include "element.h"
#include "parser.h"
-#include <qmap.h>
-#include <qlist.h>
+#include <QMap>
+#include <QList>
/**
* @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();
+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();
- 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; }
+ /**
+ * @return the Element
+ */
+ Element *element() const { return m_element; }
- Element *m_element;
- int m_count;
+ /**
+ * @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();
+class ElementCountMap
+{
+ public:
+ /**
+ * Constructor
+ */
+ ElementCountMap();
- /**
- *
- */
- void clear() { m_map.clear(); }
+ /**
+ * Destructor
+ */
+ ~ElementCountMap();
- /**
- * @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);
+ /**
+ * Clear the map of ElementCount pointers
+ */
+ void clear() { m_map.clear(); }
- /**
- * typedef
- */
- typedef QList<ElementCount*>::Iterator Iterator;
-
- /**
- *
- */
- Iterator begin() { return m_map.begin(); }
-
- /**
- *
- */
- Iterator end() { return m_map.end(); }
+ /**
+ * @param _element the searched Element
+ * @return the Element which is searched
+ */
+ ElementCount *search(Element *_element);
- private:
- QList<ElementCount*> m_map;
+ /**
+ * @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<ElementCount*>::Iterator Iterator;
+
+ /**
+ *
+ */
+ Iterator begin() { return m_map.begin(); }
+
+ /**
+ *
+ */
+ Iterator end() { return m_map.end(); }
+
+ private:
+ QList<ElementCount*> m_map;
};
--- trunk/KDE/kdeedu/libkdeedu/libscience/parser.h #492956:492957
@@ -14,7 +14,7 @@
#ifndef PARSER_H
#define PARSER_H
-#include <qstring.h>
+#include <QString>
/**
* @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,7 +71,18 @@
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 @@
// 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
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic