Index: /code/branches/core/src/orxonox/Orxonox.cc
===================================================================
--- /code/branches/core/src/orxonox/Orxonox.cc	(revision 806)
+++ /code/branches/core/src/orxonox/Orxonox.cc	(revision 807)
@@ -764,4 +764,5 @@
         #define TestClassTreeMask(mask) \
             std::cout << "========== ClassTreeMask-Test ===========" << std::endl; \
+            std::cout << mask << std::endl << std::endl; \
             std::cout << "                 "; \
             BoolToYesNo(mask.isIncluded(Class(BaseObject))); \
@@ -808,5 +809,4 @@
 
         ClassTreeMask test13_1;
-//        test13_1.include(Class(BaseObject));
         test13_1.exclude(Class(A1B1));
         test13_1.exclude(Class(A2));
@@ -817,4 +817,6 @@
         test13_1.exclude(Class(A3B2C1));
         test13_1.exclude(Class(A3B2C2));
+        std::cout << "Mask 1:\n";
+        TestClassTreeMask(test13_1);
 
         ClassTreeMask test13_2;
@@ -828,11 +830,138 @@
         test13_2.include(Class(A3B2));
         test13_2.exclude(Class(A3B2C2));
-
+        std::cout << std::endl;
+        std::cout << "Mask 2:\n";
+        TestClassTreeMask(test13_2);
+
+        ClassTreeMask test13_3;
+        test13_3.include(Class(A1));
+        test13_3.exclude(Class(A1B2));
+        test13_3.exclude(Class(A1B1C2));
+        test13_3.include(Class(A2));
+        test13_3.exclude(Class(A2B2));
+        test13_3.include(Class(A3B1));
+        test13_3.include(Class(A3B2));
+        test13_3.exclude(Class(A3B2C2));
+        std::cout << std::endl;
+        std::cout << "Mask 2 without excluded BaseObject:\n";
+        TestClassTreeMask(test13_3);
+        test13_3.exclude(Class(BaseObject));
+        std::cout << std::endl;
+        std::cout << "Mask 2 with BaseObject excluded afterwards:\n";
+        TestClassTreeMask(test13_3);
+
+        ClassTreeMask test13_3_2;
+        test13_3_2.include(Class(A1));
+        test13_3_2.exclude(Class(A1B2));
+        test13_3_2.exclude(Class(A1B1C2));
+        test13_3_2.include(Class(A2));
+        test13_3_2.exclude(Class(A2B2));
+        test13_3_2.include(Class(A3B1));
+        test13_3_2.include(Class(A3B2));
+        test13_3_2.exclude(Class(A3B2C2));
+        test13_3_2.clean();
+        test13_3_2.exclude(Class(BaseObject));
+        std::cout << std::endl;
+        std::cout << "Mask 2 with BaseObject excluded afterwards, but cleaned before:\n";
+        TestClassTreeMask(test13_3_2);
+        test13_3_2.include(Class(BaseObject));
+        std::cout << std::endl;
+        std::cout << "Mask 2 from before, but BaseObject re-included without cleaning:\n";
+        TestClassTreeMask(test13_3_2);
+
+        ClassTreeMask test13_4;
+        test13_4.include(Class(A3B2));
+        test13_4.exclude(Class(A1B1C2));
+        test13_4.include(Class(A3B1));
+        test13_4.exclude(Class(A3B2C2));
+        test13_4.exclude(Class(BaseObject));
+        test13_4.include(Class(A2));
+        test13_4.exclude(Class(A1B2));
+        test13_4.exclude(Class(A2B2));
+        test13_4.include(Class(A1));
+        std::cout << std::endl;
+        std::cout << "Mask 2 created in random order:\n";
+        TestClassTreeMask(test13_4);
+
+        std::cout << "2\n";
+
+        ClassTreeMask test13_5 = test13_1;
+        std::cout << std::endl;
+        std::cout << "Mask 1 assigned to a new ClassTestMask:\n";
+        TestClassTreeMask(test13_5);
+
+        std::cout << "3\n";
+
+        ClassTreeMask test13_6 = !test13_1;
+        std::cout << std::endl;
+        std::cout << "Mask 1 inverted:\n";
+        TestClassTreeMask(test13_6);
+
+        std::cout << "4\n";
+
+        ClassTreeMask test13_7 = test13_1 + test13_2;
+        std::cout << std::endl;
+        std::cout << "Mask 1 + Mask 2:\n";
+        TestClassTreeMask(test13_7);
+
+        std::cout << "5\n";
+
+        ClassTreeMask test13_8 = test13_1 * test13_2;
+        std::cout << std::endl;
+        std::cout << "Mask 1 * Mask 2:\n";
+        TestClassTreeMask(test13_8);
+
+        std::cout << "6\n";
+
+        ClassTreeMask test13_9 = test13_1 - test13_2;
+        std::cout << std::endl;
+        std::cout << "Mask 1 - Mask 2:\n";
+        TestClassTreeMask(test13_9);
+
+        std::cout << "7\n";
+
+        ClassTreeMask test13_10 = test13_1 ^ test13_2;
+        std::cout << std::endl;
+        std::cout << "Mask 1 ^ Mask 2:\n";
+        TestClassTreeMask(test13_10);
+        test13_10 = test13_10;
+        TestClassTreeMask(test13_10);
+
+        std::cout << "8\n";
+
+        std::cout << std::endl;
+        ClassTreeMask test13_11(test13_1);
+        std::cout << std::endl;
+        std::cout << "Mask 1 assigned with copyconstructor + original mask 1:\n";
+        TestClassTreeMask(test13_11);
         TestClassTreeMask(test13_1);
+
+        ClassTreeMask test13_12(!test13_11);
+        std::cout << std::endl;
+        std::cout << "Mask 1 inverted assigned with copyconstructor + the original from before:\n";
+        TestClassTreeMask(test13_12);
+        TestClassTreeMask(test13_11);
+
+        ClassTreeMask test13_13;
+        test13_13 = test13_2;
+        std::cout << std::endl;
+        std::cout << "Mask 2 assigned with = operator + original mask 2:\n";
+        TestClassTreeMask(test13_13);
         TestClassTreeMask(test13_2);
 
-        std::cout << "2\n";
-
-        std::cout << "3\n";
+        ClassTreeMask test13_14 = test13_11 + test13_13;
+        std::cout << std::endl;
+        std::cout << "Mask 1 + Mask 2 assigned with copyconstructor + originals from before:\n";
+        TestClassTreeMask(test13_14);
+        TestClassTreeMask(test13_11);
+        TestClassTreeMask(test13_13);
+
+        test13_11 += test13_13;
+        std::cout << std::endl;
+        std::cout << "Mask 1 + Mask 2 with += operator + original of mask 2 from before:\n";
+        TestClassTreeMask(test13_11);
+        TestClassTreeMask(test13_13);
+
+        std::cout << "9\n";
 
 //    startRenderLoop();
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;
+    }
 }
Index: /code/branches/core/src/orxonox/core/ClassTreeMask.h
===================================================================
--- /code/branches/core/src/orxonox/core/ClassTreeMask.h	(revision 806)
+++ /code/branches/core/src/orxonox/core/ClassTreeMask.h	(revision 807)
@@ -77,4 +77,5 @@
         private:
             std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_;
+            std::list<ClassTreeMaskNode*> rootlist_;
     };
 
@@ -83,4 +84,5 @@
         public:
             ClassTreeMask();
+            ClassTreeMask(const ClassTreeMask& other);
             ~ClassTreeMask();
 
@@ -94,8 +96,17 @@
             bool isExcluded(const Identifier* subclass) const;
 
+            ClassTreeMask& operator=(const ClassTreeMask& other);
+
+            ClassTreeMask& operator+();
+            ClassTreeMask operator-() const;
+
             ClassTreeMask operator+(const ClassTreeMask& other) const;
             ClassTreeMask operator*(const ClassTreeMask& other) const;
+            ClassTreeMask operator-(const ClassTreeMask& other) const;
             ClassTreeMask operator!() const;
-            ClassTreeMask operator-(const ClassTreeMask& other) const;
+
+            ClassTreeMask& operator+=(const ClassTreeMask& other);
+            ClassTreeMask& operator*=(const ClassTreeMask& other);
+            ClassTreeMask& operator-=(const ClassTreeMask& other);
 
             ClassTreeMask operator&(const ClassTreeMask& other) const;
@@ -103,4 +114,10 @@
             ClassTreeMask operator^(const ClassTreeMask& other) const;
             ClassTreeMask operator~() const;
+
+            ClassTreeMask& operator&=(const ClassTreeMask& other);
+            ClassTreeMask& operator|=(const ClassTreeMask& other);
+            ClassTreeMask& operator^=(const ClassTreeMask& other);
+
+            friend std::ostream& operator<<(std::ostream& out, const ClassTreeMask& mask);
 
         private:
