Changeset 1989 for code/branches/objecthierarchy/src/core/BaseObject.cc
- Timestamp:
- Oct 21, 2008, 4:56:41 PM (16 years ago)
- File:
-
- 1 edited
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 }
Note: See TracChangeset
for help on using the changeset viewer.