Changeset 1989 for code/branches/objecthierarchy/src/core
- Timestamp:
- Oct 21, 2008, 4:56:41 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/core
- Files:
-
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/BaseObject.cc
r1625 r1989 37 37 #include "XMLPort.h" 38 38 #include "Level.h" 39 #include "Template.h" 39 40 40 41 namespace orxonox … … 76 77 XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode); 77 78 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode); 79 80 XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, const std::string&); 78 81 } 79 82 … … 86 89 return this->level_->getFile(); 87 90 } 91 92 /** 93 @brief Adds a Template to the object. 94 @param name The name of the Template 95 */ 96 void BaseObject::addTemplate(const std::string& name) 97 { 98 Template* temp = Template::getTemplate(name); 99 if (temp) 100 this->addTemplate(temp); 101 else 102 COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl; 103 } 104 105 /** 106 @brief Adds a Template to the object. 107 @param temp The Template 108 */ 109 void BaseObject::addTemplate(Template* temp) 110 { 111 this->templates_.insert(temp); 112 temp->applyOn(this); 113 } 114 115 /** 116 @brief Returns the Template with the given index. 117 @param index The index 118 */ 119 Template* BaseObject::getTemplate(unsigned int index) const 120 { 121 unsigned int i = 0; 122 for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it) 123 { 124 if (i == index) 125 return (*it); 126 i++; 127 } 128 return 0; 129 } 88 130 } -
code/branches/objecthierarchy/src/core/BaseObject.h
r1950 r1989 87 87 const std::string& getLevelfile() const; 88 88 89 void addTemplate(const std::string& name); 90 void addTemplate(Template* temp); 91 /** @brief Returns the set of all aplied templates. */ 92 inline const std::set<Template*>& getTemplates() const 93 { return this->templates_; } 94 89 95 virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; } 90 96 inline Namespace* getNamespace() const { return this->namespace_; } … … 102 108 103 109 private: 110 Template* getTemplate(unsigned int index) const; 111 104 112 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 105 113 const Level* level_; //!< The level that loaded this object 106 114 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 107 115 Namespace* namespace_; 116 std::set<Template*> templates_; 108 117 }; 109 118 -
code/branches/objecthierarchy/src/core/CMakeLists.txt
r1961 r1989 31 31 Namespace.cc 32 32 NamespaceNode.cc 33 Template.cc 33 34 XMLPort.cc 34 35 -
code/branches/objecthierarchy/src/core/CorePrereqs.h
r1757 r1989 153 153 struct TclInterpreterBundle; 154 154 class TclThreadManager; 155 class Template; 155 156 class Tickable; 156 157 template <class T, class O> -
code/branches/objecthierarchy/src/core/Template.cc
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/code/branches/ceguilua/src/orxonox/objects/Template.cc 1802-1808 /code/branches/core3/src/orxonox/objects/Template.cc 1572-1739 /code/branches/gcc43/src/orxonox/objects/Template.cc 1580 /code/branches/gui/src/orxonox/objects/Template.cc 1635-1723 /code/branches/input/src/orxonox/objects/Template.cc 1629-1636 /code/branches/script_trigger/src/orxonox/objects/Template.cc 1295-1953,1955
r1971 r1989 49 49 Template::~Template() 50 50 { 51 Template::getTemplateMap().erase(this->getName()); 51 52 } 52 53 … … 59 60 60 61 this->setXMLElement(*xmlelement.FirstChildElement(false)); 62 } 63 64 void Template::changedName() 65 { 66 if (this->getName() != "") 67 { 68 std::map<std::string, Template*>::iterator it; 69 it = Template::getTemplateMap().find(this->getOldName()); 70 if (it != Template::getTemplateMap().end()) 71 Template::getTemplateMap().erase(it); 72 73 it = Template::getTemplateMap().find(this->getName()); 74 if (it != Template::getTemplateMap().end()) 75 COUT(2) << "Warning: Template with name \"" << this->getName() << "\" already exists." << std::endl; 76 else 77 Template::getTemplateMap()[this->getName()] = this; 78 } 61 79 } 62 80 -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
code/branches/objecthierarchy/src/core/Template.h
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/code/branches/ceguilua/src/orxonox/objects/Template.h 1802-1808 /code/branches/core3/src/orxonox/objects/Template.h 1572-1739 /code/branches/gcc43/src/orxonox/objects/Template.h 1580 /code/branches/gui/src/orxonox/objects/Template.h 1635-1723 /code/branches/input/src/orxonox/objects/Template.h 1629-1636 /code/branches/script_trigger/src/orxonox/objects/Template.h 1295-1953,1955
r1971 r1989 32 32 #include <map> 33 33 34 #include "OrxonoxPrereqs.h" 35 #include "core/BaseObject.h" 34 #include "CorePrereqs.h" 35 36 #include "BaseObject.h" 36 37 #include "tinyxml/ticpp.h" 37 38 38 39 namespace orxonox 39 40 { 40 class _ OrxonoxExport Template : public BaseObject41 class _CoreExport Template : public BaseObject 41 42 { 42 43 public: … … 45 46 46 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 virtual void changedName(); 47 49 48 50 inline void setLink(const std::string& link) -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
code/branches/objecthierarchy/src/core/XMLPort.h
r1940 r1989 219 219 */ 220 220 #define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \ 221 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)221 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore) 222 222 223 223 // ------------- … … 233 233 */ 234 234 #define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \ 235 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true)235 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true) 236 236 237 237 // --------------------
Note: See TracChangeset
for help on using the changeset viewer.