00001 #include "ability.hh" 00002 #include "element.hh" 00003 #include <iostream> 00004 #include "abstractworld.hh" 00005 00006 namespace anoid { 00007 namespace base { 00008 00009 using namespace std; 00010 using namespace config; 00011 00012 void Ability::init(Configuration &c) { 00013 parentElement = NULL; 00014 Object *tmp = getParent(); 00015 while (!parentElement && tmp != (Object *) getWorld()) { 00016 parentElement = dynamic_cast<Element *>(tmp); 00017 tmp = tmp->getParent(); 00018 } 00019 if (!parentElement) 00020 cerr << "Error" << endl; 00023 name = c.getString("name"); 00024 if (name == "") 00025 name = c.getName(); 00026 00027 // cout << "init " << this << endl; 00028 00029 Object::init(c); 00030 } 00031 00032 Ability *Ability::lookupFellowAbility(const char *c) { 00033 return parentElement->abilities[c]; 00034 } 00035 00036 void Ability::registerName(const char *c) { 00037 parentElement->abilities[c] = this; 00039 } 00040 00041 }; 00042 };