Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 10, 2008, 5:07:48 PM (17 years ago)
Author:
landauf
Message:

started implementing the Namespace hierarchy (still unfinished)

File:
1 edited

Legend:

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

    r878 r879  
    3838        RegisterObject(Namespace);
    3939
    40         this->representingNamespace_ = 0;
     40        this->representingNamespace_ = this;
    4141    }
    4242
     
    5555        BaseObject::XMLPort(xmlelement, loading);
    5656
    57         XMLPortObject(Namespace, BaseObject, "", loadObjects, saveObjects, xmlelement, loading, true);
     57        XMLPortObject(Namespace, BaseObject, "", loadObjects, saveObjects, xmlelement, loading, true, false);
    5858    }
    5959
    6060    void Namespace::loadObjects(BaseObject* object)
    6161    {
    62         object->setNamespace(this);
     62        object->setNamespace(this->representingNamespace_);
     63
     64        if (object->isA(Class(Namespace)))
     65            this->addSubnamespace((Namespace*)object);
     66    }
     67
     68    void Namespace::addSubnamespace(Namespace* ns)
     69    {
     70        std::string name = ns->getName().substr(ns->getName().find("::"
     71
     72        if (!this->hasSubnamespace(ns->getName()))
     73            this->namespaces_[ns->getName()] = ns;
     74        else
     75            ns->representingNamespace_ = object;
     76    }
     77
     78    bool Namespace::hasSubnamespace(const std::string& name) const
     79    {
     80        return (this->namespaces_.find(name) != this->namespaces_.end());
    6381    }
    6482
Note: See TracChangeset for help on using the changeset viewer.