[Kst] branches/work/kst/hierarchy/kst/src/libkst

Eli Fidler eli at staikos.net
Wed Dec 13 22:34:16 CET 2006


SVN commit 613329 by fidler:

pass KstObjectTags by const reference.. it's easier to debug and faster


 M  +1 -1      kstdatasource.cpp  
 M  +1 -1      kstdatasource.h  
 M  +1 -1      kstmatrix.cpp  
 M  +1 -1      kstmatrix.h  
 M  +1 -1      kstobject.cpp  
 M  +4 -4      kstobject.h  
 M  +23 -23    kstobjectcollection.h  
 M  +1 -1      kstscalar.cpp  
 M  +1 -1      kstscalar.h  
 M  +1 -1      kststring.cpp  
 M  +1 -1      kststring.h  
 M  +2 -2      kstvector.cpp  
 M  +2 -2      kstvector.h  


--- branches/work/kst/hierarchy/kst/src/libkst/kstdatasource.cpp #613328:613329
@@ -440,7 +440,7 @@
 }
 
 
-void KstDataSource::setTagName(KstObjectTag in_tag) {
+void KstDataSource::setTagName(const KstObjectTag& in_tag) {
   KstObject::setTagName(in_tag);
   _numFramesScalar->setTagName(KstObjectTag("frames", tag()));
 }
--- branches/work/kst/hierarchy/kst/src/libkst/kstdatasource.h #613328:613329
@@ -58,7 +58,7 @@
   public:
     virtual ~KstDataSource();
 
-    void setTagName(KstObjectTag tag);
+    void setTagName(const KstObjectTag& tag);
 
     // These six static methods are not for plugins to use
     /** Returns a list of plugins found on the system. */
--- branches/work/kst/hierarchy/kst/src/libkst/kstmatrix.cpp #613328:613329
@@ -370,7 +370,7 @@
 }
     
     
-void KstMatrix::setTagName(KstObjectTag tag) {
+void KstMatrix::setTagName(const KstObjectTag& tag) {
   KstWriteLocker l(&KST::matrixList.lock());
 
   KST::matrixList.doRename(this, tag);
--- branches/work/kst/hierarchy/kst/src/libkst/kstmatrix.h #613328:613329
@@ -99,7 +99,7 @@
     virtual void save(QTextStream &ts, const QString& indent = QString::null);
 
     // set tag name of the matrix
-    virtual void setTagName(KstObjectTag tag);
+    virtual void setTagName(const KstObjectTag& tag);
 
     // the statistics scalars for this matrix
     const QDict<KstScalar>& scalars() const;
--- branches/work/kst/hierarchy/kst/src/libkst/kstobject.cpp #613328:613329
@@ -74,7 +74,7 @@
 }
 
 
-void KstObject::setTagName(KstObjectTag tag) {
+void KstObject::setTagName(const KstObjectTag& tag) {
   _tag = tag;
   setName(_tag.tagString().local8Bit().data());
 }
--- branches/work/kst/hierarchy/kst/src/libkst/kstobject.h #613328:613329
@@ -62,7 +62,7 @@
 
 
     // construct a tag in a given context
-    KstObjectTag(const QString& tag, QStringList context,
+    KstObjectTag(const QString& tag, const QStringList& context,
         unsigned int minDisplayComponents = 1) : _tag(cleanTag(tag)),
                                                  _context(context),
                                                  _minDisplayComponents(minDisplayComponents),
@@ -105,13 +105,13 @@
     }
 
     // change the context
-    void setContext(QStringList context) {
+    void setContext(const QStringList& context) {
       _context = context;
       _uniqueDisplayComponents = UINT_MAX;
     }
 
     // change the tag and context
-    void setTag(const QString& tag, QStringList context) {
+    void setTag(const QString& tag, const QStringList& context) {
       setTag(tag);
       setContext(context);
     }
@@ -193,7 +193,7 @@
     virtual QString tagName() const;
     virtual KstObjectTag& tag();
     virtual const KstObjectTag& tag() const;
-    virtual void setTagName(KstObjectTag tag);
+    virtual void setTagName(const KstObjectTag& tag);
 
     virtual QString tagLabel() const;
     // Returns count - 2 to account for "this" and the list pointer
--- branches/work/kst/hierarchy/kst/src/libkst/kstobjectcollection.h #613328:613329
@@ -55,8 +55,8 @@
     KstObjectTreeNode<T> *child(const QString& tag) const;
     QMap<QString, KstObjectTreeNode<T> *> children() const { return _children; }
 
-    KstObjectTreeNode<T> *descendant(QStringList tag);
-    const KstObjectTreeNode<T> *descendant(QStringList tag) const;
+    KstObjectTreeNode<T> *descendant(const QStringList& tag);
+    const KstObjectTreeNode<T> *descendant(const QStringList& tag) const;
     KstObjectTreeNode<T> *addDescendant(T *o, KstObjectNameIndex<T> *index = NULL);
     bool removeDescendant(T *o, KstObjectNameIndex<T> *index = NULL);
 
@@ -75,17 +75,17 @@
   public:
     bool addObject(T *o);
     bool removeObject(T *o);
-    void doRename(T *o, KstObjectTag newTag);
+    void doRename(T *o, const KstObjectTag& newTag);
 
-    KstSharedPtr<T> retrieveObject(QStringList tag);
-    KstSharedPtr<T> retrieveObject(KstObjectTag tag);
+    KstSharedPtr<T> retrieveObject(QStringList tag) const;
+    KstSharedPtr<T> retrieveObject(const KstObjectTag& tag) const;
     bool tagExists(const QString& tag) const;
-    bool tagExists(KstObjectTag tag) const;
+    bool tagExists(const KstObjectTag& tag) const;
 
     // get the shortest unique tag in in_tag
-    KstObjectTag shortestUniqueTag(KstObjectTag in_tag) const;
+    KstObjectTag shortestUniqueTag(const KstObjectTag& in_tag) const;
     // get the minimum number of tag components of in_tag necessary for a unique tag
-    unsigned int componentsForUniqueTag(KstObjectTag in_tag) const;
+    unsigned int componentsForUniqueTag(const KstObjectTag& in_tag) const;
 
     KstObjectTreeNode<T> *nameTreeRoot() { return &_root; }
 
@@ -191,7 +191,7 @@
 
 
 template <class T>
-const KstObjectTreeNode<T> *KstObjectTreeNode<T>::descendant(QStringList tag) const {
+const KstObjectTreeNode<T> *KstObjectTreeNode<T>::descendant(const QStringList& tag) const {
   const KstObjectTreeNode<T> *currNode = this;
   for (QStringList::ConstIterator i = tag.begin(); i != tag.end(); ++i) {
     currNode = currNode->child(*i);
@@ -205,7 +205,7 @@
 
 
 template <class T>
-KstObjectTreeNode<T> *KstObjectTreeNode<T>::descendant(QStringList tag) {
+KstObjectTreeNode<T> *KstObjectTreeNode<T>::descendant(const QStringList& tag) {
   KstObjectTreeNode<T> *currNode = this;
   for (QStringList::ConstIterator i = tag.begin(); i != tag.end(); ++i) {
     currNode = currNode->child(*i);
@@ -363,7 +363,7 @@
 // Updates the display components of all related objects. This can be somewhat
 // expensive, but it shouldn't happen very often.
 template <class T>
-void KstObjectCollection<T>::doRename(T *o, KstObjectTag newTag) {
+void KstObjectCollection<T>::doRename(T *o, const KstObjectTag& newTag) {
   QValueList<KstObjectTreeNode<T> *> relNodes = relatedNodes(o);
 
   _root.removeDescendant(o, &_index);
@@ -381,8 +381,8 @@
 
 
 template <class T>
-KstSharedPtr<T> KstObjectCollection<T>::retrieveObject(QStringList tag) {
-#if NAMEDEBUG > 0
+KstSharedPtr<T> KstObjectCollection<T>::retrieveObject(QStringList tag) const {
+#if NAMEDEBUG > 1
   kstdDebug() << "Retrieving object with tag: \"" << tag.join(KstObjectTag::tagSeparator) << "\"" << endl;
 #endif
 
@@ -392,7 +392,7 @@
 
   if (_index.contains(tag.first()) && _index[tag.first()].count() == 1) {
     // the first tag element is unique, so use the index
-#if NAMEDEBUG > 1
+#if NAMEDEBUG > 2
     kstdDebug() << "  first tag element (\"" << tag.first() << "\") is unique in index" << endl;
 #endif
 
@@ -402,7 +402,7 @@
       n = n->descendant(tag);
     }
     if (n) {
-#if NAMEDEBUG > 0
+#if NAMEDEBUG > 1
       kstdDebug() << "  found node, returning object " << (void*) n->object() << endl;
 #endif
       return n->object();
@@ -410,14 +410,14 @@
   }
 
   // search through the tree
-  KstObjectTreeNode<T> *n = _root.descendant(tag);
+  const KstObjectTreeNode<T> *n = _root.descendant(tag);
   if (n) {
-#if NAMEDEBUG > 0
+#if NAMEDEBUG > 1
     kstdDebug() << "  found node, returning object " << (void*) n->object() << endl;
 #endif
     return n->object();
   } else {
-#if NAMEDEBUG > 0
+#if NAMEDEBUG > 1
     kstdDebug() << "  node not found" << endl;
 #endif
     return NULL;
@@ -425,7 +425,7 @@
 }
 
 template <class T>
-KstSharedPtr<T> KstObjectCollection<T>::retrieveObject(KstObjectTag tag) {
+KstSharedPtr<T> KstObjectCollection<T>::retrieveObject(const KstObjectTag& tag) const {
   if (!tag.isValid()) {
     return NULL;
   }
@@ -439,13 +439,13 @@
 }
 
 template <class T>
-bool KstObjectCollection<T>::tagExists(KstObjectTag tag) const {
+bool KstObjectCollection<T>::tagExists(const KstObjectTag& tag) const {
   const KstObjectTreeNode<T> *n = _root.descendant(tag.fullTag());
   return (n != NULL);
 }
 
 template <class T>
-KstObjectTag KstObjectCollection<T>::shortestUniqueTag(KstObjectTag tag) const {
+KstObjectTag KstObjectCollection<T>::shortestUniqueTag(const KstObjectTag& tag) const {
   QStringList in_tag = tag.fullTag();
   QStringList out_tag;
 
@@ -468,7 +468,7 @@
 }
 
 template <class T>
-unsigned int KstObjectCollection<T>::componentsForUniqueTag(KstObjectTag tag) const {
+unsigned int KstObjectCollection<T>::componentsForUniqueTag(const KstObjectTag& tag) const {
   QStringList in_tag = tag.fullTag();
   unsigned int components = 0;
 
@@ -609,7 +609,7 @@
   }
 
   unsigned int nc = componentsForUniqueTag(obj->tag());
-#if NAMEDEBUG > 1
+#if NAMEDEBUG > 2
   kstdDebug() << "Changing display components on \"" << obj->tag().tagString() << "\" from " << obj->tag().uniqueDisplayComponents() << " to " << nc << endl;
 #endif
   obj->tag().setUniqueDisplayComponents(nc);
--- branches/work/kst/hierarchy/kst/src/libkst/kstscalar.cpp #613328:613329
@@ -184,7 +184,7 @@
 }
 
 
-void KstScalar::setTagName(KstObjectTag newTag) {
+void KstScalar::setTagName(const KstObjectTag& newTag) {
   KstWriteLocker l(&KST::scalarList.lock());
 
   KST::scalarList.doRename(this, newTag);
--- branches/work/kst/hierarchy/kst/src/libkst/kstscalar.h #613328:613329
@@ -37,7 +37,7 @@
     virtual ~KstScalar();
 
   public:
-    void setTagName(KstObjectTag tag);
+    void setTagName(const KstObjectTag& tag);
 
     /* return true if any scalars are dirty at the moment */
     static bool scalarsDirty();
--- branches/work/kst/hierarchy/kst/src/libkst/kststring.cpp #613328:613329
@@ -69,7 +69,7 @@
 }
 
 
-void KstString::setTagName(KstObjectTag tag) {
+void KstString::setTagName(const KstObjectTag& tag) {
   KstWriteLocker l(&KST::stringList.lock());
 
   KST::stringList.doRename(this, tag);
--- branches/work/kst/hierarchy/kst/src/libkst/kststring.h #613328:613329
@@ -32,7 +32,7 @@
     ~KstString();
 
   public:
-    void setTagName(KstObjectTag tag);
+    void setTagName(const KstObjectTag& tag);
 
     /** Save information */
     void save(QTextStream &ts, const QString& indent = QString::null);
--- branches/work/kst/hierarchy/kst/src/libkst/kstvector.cpp #613328:613329
@@ -591,7 +591,7 @@
 }
 
 
-void KstVector::setTagName(KstObjectTag newTag) {
+void KstVector::setTagName(const KstObjectTag& newTag) {
   KstWriteLocker l(&KST::vectorList.lock());
 
   KST::vectorList.doRename(this, newTag);
@@ -626,7 +626,7 @@
 }
 
 
-KstVectorPtr KstVector::generateVector(double x0, double x1, int n, KstObjectTag tag) {
+KstVectorPtr KstVector::generateVector(double x0, double x1, int n, const KstObjectTag& tag) {
   if (n < 2) {
     n = 2;
   }
--- branches/work/kst/hierarchy/kst/src/libkst/kstvector.h #613328:613329
@@ -129,9 +129,9 @@
 
     /** Generate a new vector [x0..x1] with n total points */
     // #### Remove
-    static KstVectorPtr generateVector(double x0, double x1, int n, KstObjectTag tag);
+    static KstVectorPtr generateVector(double x0, double x1, int n, const KstObjectTag& tag);
 
-    virtual void setTagName(KstObjectTag newTag);
+    virtual void setTagName(const KstObjectTag& newTag);
 
     /** Return a pointer to the raw vector */
     double *const value() const;


More information about the Kst mailing list