Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 847


Ignore:
Timestamp:
Mar 3, 2008, 1:49:06 AM (17 years ago)
Author:
landauf
Message:

new loader-concept is taking shape, but not yet finished

added new classes: Functor, Executor and XMLPortParamContainer.
more to come (i.e. XMLPortObjectContainer)

Executor might be useless, depends on how we'll implement the ingame shell-commands and the keybindings

moved all non-identifier-related functions and variables from OrxonoxClass to BaseObject. this might result in some casts to BaseObject when working with all objects of an interface (like Synchronisable), but I think it improves the class hierarchy.

Location:
code/branches/core/src/orxonox/core
Files:
5 added
14 edited

Legend:

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

    r826 r847  
    3434
    3535#include "BaseObject.h"
     36#include "XMLPort.h"
    3637
    3738namespace orxonox
     
    4647        RegisterRootObject(BaseObject);
    4748
     49        this->bActive_ = true;
     50        this->bVisible_ = true;
    4851        this->level_ = 0;
    4952    }
     
    7578    Element& BaseObject::XMLPort(Element& xmlelement, bool loading)
    7679    {
    77 //        XMLPortParam(BaseObject, "name", setName, getName, xmlelement, loading);
     80        XMLPortParam(BaseObject, "name", setName, getName, xmlelement, loading);
    7881
    7982        return xmlelement;
  • code/branches/core/src/orxonox/core/BaseObject.h

    r845 r847  
    5252            virtual Element& XMLPort(Element& xmlelement, bool loading);
    5353
     54            /** @brief Sets the name of the object. @param name The name */
     55            inline void setName(const std::string& name) { this->name_ = name; this->changedName(); }
     56            /** @brief Returns the name of the object. @return The name */
     57            inline const std::string& getName() const { return this->name_; }
     58            /** @brief This function gets called if the name of the object changes. */
     59            virtual void changedName() {}
     60
     61            /** @brief Sets the state of the objects activity. @param bActive True = active */
     62            inline void setActivity(bool bActive) { this->bActive_ = bActive; this->changedActivity(); }
     63            /** @brief Returns the state of the objects activity. @return The state of the activity */
     64            inline const bool isActive() const { return this->bActive_; }
     65            /** @brief This function gets called if the activity of the object changes. */
     66            virtual void changedActivity() {}
     67
     68            /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
     69            inline void setVisibility(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }
     70            /** @brief Returns the state of the objects visibility. @return The state of the visibility */
     71            inline const bool isVisible() const { return this->bVisible_; }
     72            /** @brief This function gets called if the visibility of the object changes. */
     73            virtual void changedVisibility() {}
     74
     75            /** @brief Sets a pointer to the level that loaded this object. @param level The pointer to the level */
     76            inline void setLevel(const Level* level) { this->level_ = level; }
    5477            /** @brief Returns a pointer to the level that loaded this object. @return The level */
    5578            inline const Level* getLevel() const { return this->level_; }
    5679
    5780        private:
     81            std::string name_;                          //!< The name of the object
     82            bool bActive_;                              //!< True = the object is active
     83            bool bVisible_;                             //!< True = the object is visible
    5884            const Level* level_;                        //!< The level that loaded this object
    5985    };
  • code/branches/core/src/orxonox/core/CMakeLists.txt

    r820 r847  
    1515  ClassTreeMask.cc
    1616  Loader.cc
     17  Executor.cc
     18  XMLPort.cc
    1719)
    1820
  • code/branches/core/src/orxonox/core/ConfigValueContainer.cc

    r839 r847  
    957957        @return The description
    958958    */
    959     std::string ConfigValueContainer::getDescription() const
     959    const std::string& ConfigValueContainer::getDescription() const
    960960    {
    961961        return GetLocalisation(this->description_);
  • code/branches/core/src/orxonox/core/ConfigValueContainer.h

    r838 r847  
    100100
    101101            void description(const std::string& description);
    102             std::string getDescription() const;
     102            const std::string& getDescription() const;
    103103
    104104            bool parseString(const std::string& input, MultiTypeMath& defvalue);
  • code/branches/core/src/orxonox/core/CoreIncludes.h

    r845 r847  
    121121    { \
    122122        container##varname = new orxonox::ConfigValueContainer(this->getIdentifier()->getName(), #varname, varname = defvalue); \
    123         this->getIdentifier()->setConfigValueContainer(#varname, container##varname); \
     123        this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \
    124124    } \
    125125    container##varname->getValue(&varname)
  • code/branches/core/src/orxonox/core/CorePrereqs.h

    r838 r847  
    8282  class DebugLevel;
    8383  class Error;
     84  class Executor;
    8485  class Factory;
    8586  class Identifier;
     
    102103  template <class T>
    103104  class SubclassIdentifier;
     105  class XMLPortParamContainer;
     106  template <class T>
     107  class XMLPortClassParamContainer;
    104108}
    105109
  • code/branches/core/src/orxonox/core/Identifier.cc

    r820 r847  
    198198
    199199    /**
     200        @brief Returns the ConfigValueContainer of a variable, given by the string of its name.
     201        @param varname The name of the variable
     202        @return The ConfigValueContainer
     203    */
     204    ConfigValueContainer* Identifier::getConfigValueContainer(const std::string& varname)
     205    {
     206        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname);
     207        if (it != configValues_.end())
     208            return ((*it).second);
     209        else
     210            return 0;
     211    }
     212
     213    /**
     214        @brief Adds the ConfigValueContainer of a variable, given by the string of its name.
     215        @param varname The name of the variablee
     216        @param container The container
     217    */
     218    void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
     219    {
     220        this->configValues_[varname] = container;
     221    }
     222
     223    /**
    200224        @brief Searches for a given identifier in a list and returns whether the identifier is in the list or not.
    201225        @param identifier The identifier to look for
  • code/branches/core/src/orxonox/core/Identifier.h

    r845 r847  
    6262#include "Debug.h"
    6363#include "Iterator.h"
     64//#include "XMLPort.h"
    6465
    6566namespace orxonox
     
    151152            void setNetworkID(unsigned int id);
    152153
    153             /** @brief Returns the ConfigValueContainer of a variable, given by the string of its name. @param varname The name of the variable @return The ConfigValueContainer */
    154             inline ConfigValueContainer* getConfigValueContainer(const std::string& varname)
    155                 { return this->configValues_[varname]; }
    156 
    157             /** @brief Sets the ConfigValueContainer of a variable, given by the string of its name. @param varname The name of the variablee @param container The container */
    158             inline void setConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
    159                 { this->configValues_[varname] = container; }
     154            ConfigValueContainer* getConfigValueContainer(const std::string& varname);
     155            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
     156
     157            virtual XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname) = 0;
     158            virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0;
    160159
    161160            static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list);
     
    236235            inline const ObjectList<T>* getObjects() const { return this->objects_; }
    237236
     237            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
     238            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
     239
    238240        private:
    239241            ClassIdentifier();
     
    243245            ObjectList<T>* objects_;    //!< The ObjectList, containing all objects of type T
    244246            bool bSetName_;             //!< True if the name is set
     247            std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;
    245248    };
    246249
     
    317320        for (Iterator<T> it = this->objects_->start(); it;)
    318321            delete *(it++);
     322    }
     323
     324    template <class T>
     325    XMLPortParamContainer* ClassIdentifier<T>::getXMLPortParamContainer(const std::string& paramname)
     326    {
     327        typename std::map<std::string, XMLPortClassParamContainer<T>*>::const_iterator it = xmlportParamContainers_.find(paramname);
     328        if (it != xmlportParamContainers_.end())
     329            return (XMLPortParamContainer*)((*it).second);
     330        else
     331            return 0;
     332    }
     333
     334    template <class T>
     335    void ClassIdentifier<T>::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
     336    {
     337        this->xmlportParamContainers_[paramname] = (XMLPortClassParamContainer<T>*)container;
    319338    }
    320339
  • code/branches/core/src/orxonox/core/Language.cc

    r838 r847  
    145145        {
    146146            LanguageEntry* newEntry = new LanguageEntry(entry);
    147             newEntry->setName(label);
     147            newEntry->setLabel(label);
    148148            this->languageEntries_[label] = newEntry;
    149149            return newEntry;
     
    332332        for (Iterator<LanguageEntry> it = ObjectList<LanguageEntry>::start(); it; ++it)
    333333        {
    334             file << it->getName() << "=" << it->getDefault() << std::endl;
     334            file << it->getLabel() << "=" << it->getDefault() << std::endl;
    335335        }
    336336
  • code/branches/core/src/orxonox/core/Language.h

    r845 r847  
    5151#include "OrxonoxClass.h"
    5252
     53
     54#define AddLanguageEntry(label, fallbackstring) \
     55    orxonox::Language::getLanguage().addEntry(label, fallbackstring)
     56
     57#define GetLocalisation(label) \
     58    orxonox::Language::getLanguage().getLocalisation(label)
     59
     60
    5361namespace orxonox
    5462{
     
    7886                { return this->fallbackEntry_; }
    7987
     88            /**
     89                @brief Sets the label of this entry.
     90                @param label The label
     91            */
     92            inline void setLabel(const LanguageEntryLabel& label)
     93                { this->label_ = label; }
     94
     95            /**
     96                @brief Returns the label of this entry.
     97                @return The label
     98            */
     99            inline const LanguageEntryLabel& getLabel() const
     100                { return this->label_; }
     101
    80102        private:
    81             std::string fallbackEntry_;                             //!< The default entry: Used, if no translation is available or no language configured
    82             std::string localisedEntry_;                            //!< The localised entry in the configured language
    83             bool bLocalisationSet_;                                 //!< True if the translation was set
     103            LanguageEntryLabel label_;              //!< The label of the entry
     104            std::string fallbackEntry_;             //!< The default entry: Used, if no translation is available or no language configured
     105            std::string localisedEntry_;            //!< The localised entry in the configured language
     106            bool bLocalisationSet_;                 //!< True if the translation was set
    84107    };
    85108
     
    118141}
    119142
    120 #define AddLanguageEntry(label, fallbackstring) \
    121     orxonox::Language::getLanguage().addEntry(label, fallbackstring)
    122 
    123 #define GetLocalisation(label) \
    124     orxonox::Language::getLanguage().getLocalisation(label)
    125 
    126143#endif /* _Language_H__ */
  • code/branches/core/src/orxonox/core/Loader.cc

    r820 r847  
    121121                    COUT(4) << "  fabricating " << child->Value() << "..." << std::endl;
    122122                    BaseObject* newObject = identifier->fabricate();
     123                    newObject->XMLPort(*child, true);
    123124                }
    124125                else
  • code/branches/core/src/orxonox/core/OrxonoxClass.cc

    r813 r847  
    4242        this->identifier_ = 0;
    4343        this->parents_ = 0;
    44 
    45         this->bActive_ = true;
    46         this->bVisible_ = true;
    4744    }
    4845
  • code/branches/core/src/orxonox/core/OrxonoxClass.h

    r845 r847  
    155155                { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
    156156
    157 
    158             /** @brief Sets the name of the object. @param name The name */
    159             inline virtual void setName(const std::string& name) { this->name_ = name; }
    160 
    161             /** @brief Returns the name of the object. @return The name */
    162             inline const std::string& getName() const { return this->name_; }
    163 
    164             /** @brief Sets the state of the objects activity. @param bActive True = active */
    165             inline virtual void setActive(bool bActive) { this->bActive_ = bActive; }
    166 
    167             /** @brief Returns the state of the objects activity. @return The state of the activity */
    168             inline const bool isActive() const { return this->bActive_; }
    169 
    170             /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
    171             inline virtual void setVisible(bool bVisible) { this->bVisible_ = bVisible; }
    172 
    173             /** @brief Returns the state of the objects visibility. @return The state of the visibility */
    174             inline const bool isVisible() const { return this->bVisible_; }
    175 
    176157        private:
    177158            Identifier* identifier_;                    //!< The Identifier of the object
    178159            std::list<const Identifier*>* parents_;     //!< List of all parents of the object
    179160            MetaObjectList metaList_;                   //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
    180 
    181             std::string name_;                          //!< The name of the object
    182             bool bActive_;                              //!< True = the object is active
    183             bool bVisible_;                             //!< True = the object is visible
    184161    };
    185162}
Note: See TracChangeset for help on using the changeset viewer.