Index: code/branches/core/src/orxonox/core/ClassTreeMask.cc
===================================================================
--- code/branches/core/src/orxonox/core/ClassTreeMask.cc	(revision 806)
+++ code/branches/core/src/orxonox/core/ClassTreeMask.cc	(revision 807)
@@ -88,7 +88,6 @@
     ClassTreeMaskIterator::ClassTreeMaskIterator(ClassTreeMaskNode* node)
     {
-        std::list<ClassTreeMaskNode*> templist;
-        std::list<ClassTreeMaskNode*>::iterator tempiterator = templist.insert(templist.end(), node);
-        this->nodes_.push(std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator>(tempiterator, templist.end()));
+        std::list<ClassTreeMaskNode*>::iterator it = this->rootlist_.insert(this->rootlist_.end(), node);
+        this->nodes_.push(std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator>(it, this->rootlist_.end()));
     }
 
@@ -157,4 +156,11 @@
     {
         this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier("BaseObject"), true);
+    }
+
+    ClassTreeMask::ClassTreeMask(const ClassTreeMask& other)
+    {
+        this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier("BaseObject"), true);
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+            this->add(it->getClass(), it->isIncluded());
     }
 
@@ -241,13 +247,8 @@
         if (subclass->isA(node->getClass()))
         {
-//std::cout << "1_2\n";
             // Check for the special case
             if (subclass == node->getClass())
-            {
-//std::cout << "1_3\n";
                 return node->isIncluded();
-            }
-
-//std::cout << "1_4\n";
+
             // Go through the list of subnodes and look for a node containing the searched subclass
             for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)
@@ -255,5 +256,4 @@
                     return isIncluded(*it, subclass);
 
-//std::cout << "1_5\n";
             // There is no subnode containing our class -> the rule of the current node takes in effect
             return node->isIncluded();
@@ -261,5 +261,4 @@
         else
         {
-//std::cout << "1_6\n";
             // The class is not included in the mask: return false
             return false;
@@ -285,5 +284,6 @@
                 node->subnodes_.insert(node->subnodes_.end(), (*it)->subnodes_.begin(), (*it)->subnodes_.end());
                 (*it)->subnodes_.clear();
-                node->subnodes_.erase(it++);
+                node->subnodes_.erase(it);
+                it = node->subnodes_.begin();
             }
             else
@@ -294,4 +294,26 @@
     }
 
+    ClassTreeMask& ClassTreeMask::operator=(const ClassTreeMask& other)
+    {
+        ClassTreeMask temp(other);
+
+        this->reset();
+
+        for (ClassTreeMaskIterator it = temp.root_; it; ++it)
+            this->add(it->getClass(), it->isIncluded());
+
+        return (*this);
+    }
+
+    ClassTreeMask& ClassTreeMask::operator+()
+    {
+        return (*this);
+    }
+
+    ClassTreeMask ClassTreeMask::operator-() const
+    {
+        return (!(*this));
+    }
+
     ClassTreeMask ClassTreeMask::operator+(const ClassTreeMask& other) const
     {
@@ -330,4 +352,9 @@
     }
 
+    ClassTreeMask ClassTreeMask::operator-(const ClassTreeMask& other) const
+    {
+        return ((*this) * (!other));
+    }
+
     ClassTreeMask ClassTreeMask::operator!() const
     {
@@ -338,11 +365,23 @@
             newmask.add(subclass, !this->isIncluded(subclass));
         }
-
         return newmask;
     }
 
-    ClassTreeMask ClassTreeMask::operator-(const ClassTreeMask& other) const
-    {
-        return ((*this) * (!other));
+    ClassTreeMask& ClassTreeMask::operator+=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) + other;
+        return (*this);
+    }
+
+    ClassTreeMask& ClassTreeMask::operator*=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) * other;
+        return (*this);
+    }
+
+    ClassTreeMask& ClassTreeMask::operator-=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) - other;
+        return (*this);
     }
 
@@ -379,3 +418,36 @@
         return (!(*this));
     }
+
+    ClassTreeMask& ClassTreeMask::operator&=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) & other;
+        return (*this);
+    }
+
+    ClassTreeMask& ClassTreeMask::operator|=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) | other;
+        return (*this);
+    }
+
+    ClassTreeMask& ClassTreeMask::operator^=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) ^ other;
+        return (*this);
+    }
+
+    std::ostream& operator<<(std::ostream& out, const ClassTreeMask& mask)
+    {
+        for (ClassTreeMaskIterator it = mask.root_; it; ++it)
+        {
+            if (it->isIncluded())
+                out << "+";
+            else
+                out << "-";
+
+            out << it->getClass()->getName() << " ";
+        }
+
+        return out;
+    }
 }
