Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 896


Ignore:
Timestamp:
Mar 17, 2008, 5:05:54 PM (16 years ago)
Author:
landauf
Message:
  • added == and != operator to the ClassTreeMask
  • Included the Namespace in the Loader
Location:
code/branches/core2/src/orxonox/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/ClassTreeMask.cc

    r876 r896  
    561561
    562562    /**
     563        @brief Compares the mask with another mask and returns true if they represent the same logic.
     564        @param other The other mask
     565        @return True if both masks represent the same logic
     566    */
     567    bool ClassTreeMask::operator==(const ClassTreeMask& other) const
     568    {
     569        ClassTreeMask temp1 = other;
     570        ClassTreeMask temp2 = (*this);
     571
     572        temp1.clean();
     573        temp2.clean();
     574
     575        ClassTreeMaskIterator it1 = temp1.root_;
     576        ClassTreeMaskIterator it2 = temp2.root_;
     577
     578        for ( ; it1 && it2; ++it1, ++it2)
     579            if (it1->getClass() != it2->getClass())
     580                return false;
     581
     582        return true;
     583    }
     584
     585    /**
     586        @brief Compares the mask with another mask and returns true if they represent different logics.
     587        @param other The other mask
     588        @return True if the masks represent different logics
     589    */
     590    bool ClassTreeMask::operator!=(const ClassTreeMask& other) const
     591    {
     592        return (!((*this) == other));
     593    }
     594
     595    /**
    563596        @brief Prefix operator + does nothing.
    564597        @return A reference to the mask itself
  • code/branches/core2/src/orxonox/core/ClassTreeMask.h

    r871 r896  
    179179            ClassTreeMask& operator=(const ClassTreeMask& other);
    180180
     181            bool operator==(const ClassTreeMask& other) const;
     182            bool operator!=(const ClassTreeMask& other) const;
     183
    181184            ClassTreeMask& operator+();
    182185            ClassTreeMask operator-() const;
  • code/branches/core2/src/orxonox/core/Loader.cc

    r878 r896  
    115115            ticpp::Document xmlfile(level->getFile());
    116116            xmlfile.LoadFile();
     117            ticpp::Element rootElement;
     118            rootElement.SetAttribute("name", "rootNamespace");
    117119
    118120            for (ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++)
    119             {
    120                 Identifier* identifier = ID(child->Value());
    121                 if (identifier)
    122                 {
    123                     if (identifier->isA(Class(Namespace)) || Loader::currentMask_s.isIncluded(identifier))
    124                     {
    125                         COUT(4) << "  fabricating " << child->Value() << "..." << std::endl;
    126                         BaseObject* newObject = identifier->fabricate();
    127                         newObject->setLoaderIndentation("    ");
    128                         newObject->setLevel(level);
    129                         newObject->XMLPort(*child, true);
    130                         COUT(5) << "  ...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
    131                     }
    132                 }
    133                 else
    134                 {
    135                     COUT(2) << "  Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
    136                 }
    137             }
     121                rootElement.InsertEndChild(*child);
     122
     123            Namespace* rootNamespace = new Namespace();
     124            rootNamespace->setLoaderIndentation("    ");
     125            rootNamespace->setLevel(level);
     126            rootNamespace->deleteNamespaceNodesAfterDestruction(true);
     127            rootNamespace->XMLPort(rootElement, true);
    138128
    139129            COUT(0) << "Finished loading " << level->getFile() << "." << std::endl;
  • code/branches/core2/src/orxonox/core/Namespace.cc

    r895 r896  
    4141
    4242        this->bAutogeneratedFileRootNamespace_ = false;
     43        this->bDeleteNamespaceNodesAfterDestruction_ = false;
    4344        this->operator_ = "or";
    4445    }
     
    4647    Namespace::~Namespace()
    4748    {
     49        if (this->bDeleteNamespaceNodesAfterDestruction_)
     50            for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
     51                delete (*it);
    4852    }
    4953
  • code/branches/core2/src/orxonox/core/Namespace.h

    r895 r896  
    6262            bool isIncludedIn(const Namespace* ns) const { return ns->includes(this); }
    6363
     64            void deleteNamespaceNodesAfterDestruction(bool bDelete)
     65                { this->bDeleteNamespaceNodesAfterDestruction_ = bDelete; }
     66
    6467        private:
    6568            std::set<NamespaceNode*> representingNamespaces_;
    6669            bool bAutogeneratedFileRootNamespace_;
     70            bool bDeleteNamespaceNodesAfterDestruction_;
    6771            std::string operator_;
    6872    };
Note: See TracChangeset for help on using the changeset viewer.