Changeset 15 in flair-src for trunk/lib/FlairCore/src/Object_impl.cpp
- Timestamp:
- 04/08/16 15:40:57 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Object_impl.cpp
r2 r15 23 23 using namespace flair::core; 24 24 25 Object_impl::Object_impl(const Object * self,const Object* parent,string name,string type)26 {27 //Printf("Object %s\n",name.c_str());28 this->self=self;29 this->parent=parent;30 this->name=name;31 this->type=type;32 error_occured=false;25 Object_impl::Object_impl(const Object *self, const Object *parent, string name, 26 string type) { 27 // Printf("Object %s\n",name.c_str()); 28 this->self = self; 29 this->parent = parent; 30 this->name = name; 31 this->type = type; 32 error_occured = false; 33 33 34 if(parent!=NULL)35 {36 if(name=="") this->name=parent->ObjectName();37 34 if (parent != NULL) { 35 if (name == "") 36 this->name = parent->ObjectName(); 37 } 38 38 } 39 39 40 Object_impl::~Object_impl() 41 { 42 //Printf("destruction Object %s %s\n",name.c_str(),type.c_str()); 40 Object_impl::~Object_impl() { 41 // Printf("destruction Object %s %s\n",name.c_str(),type.c_str()); 43 42 44 while(childs.size()!=0)45 {46 //Printf("child %i %s%s\n",childs.size(),childs.front()->ObjectName().c_str(),childs.front()->ObjectType().c_str());47 //if(childs.front()!=NULL)48 49 43 while (childs.size() != 0) { 44 // Printf("child %i %s 45 // %s\n",childs.size(),childs.front()->ObjectName().c_str(),childs.front()->ObjectType().c_str()); 46 // if(childs.front()!=NULL) 47 delete childs.front(); 48 } 50 49 51 if(type_childs.size()!=0) 52 { 53 type_childs.clear(); 54 self->Warn("type_childs not cleared\n"); 55 } 50 if (type_childs.size() != 0) { 51 type_childs.clear(); 52 self->Warn("type_childs not cleared\n"); 53 } 56 54 57 //Printf("destruction Object %s %s ok\n",name.c_str(),type.c_str());55 // Printf("destruction Object %s %s ok\n",name.c_str(),type.c_str()); 58 56 } 59 57 60 void Object_impl::AddChild(const Object* child) 61 { 62 childs.push_back(child); 63 //self->Printf("added Object %s %s (%s %s)\n",child->ObjectName().c_str(),child->ObjectType().c_str(),name.c_str(),type.c_str()); 64 if(child->ObjectType()==type) type_childs.push_back(child); 58 void Object_impl::AddChild(const Object *child) { 59 childs.push_back(child); 60 // self->Printf("added Object %s %s (%s 61 // %s)\n",child->ObjectName().c_str(),child->ObjectType().c_str(),name.c_str(),type.c_str()); 62 if (child->ObjectType() == type) 63 type_childs.push_back(child); 65 64 } 66 65 67 void Object_impl::RemoveChild(const Object * child)68 { 69 //self->Printf("removed Object %s %s (%s%s)\n",child->ObjectName().c_str(),child->ObjectType().c_str(),name.c_str(),type.c_str());66 void Object_impl::RemoveChild(const Object *child) { 67 // self->Printf("removed Object %s %s (%s 68 // %s)\n",child->ObjectName().c_str(),child->ObjectType().c_str(),name.c_str(),type.c_str()); 70 69 71 for(vector<const Object*>::iterator it=childs.begin() ; it < childs.end(); it++ ) 72 { 73 if(*it==child) 74 { 75 childs.erase (it); 76 break; 77 } 70 for (vector<const Object *>::iterator it = childs.begin(); it < childs.end(); 71 it++) { 72 if (*it == child) { 73 childs.erase(it); 74 break; 78 75 } 76 } 79 77 80 for(vector<const Object*>::iterator it=type_childs.begin() ; it < type_childs.end(); it++ ) 81 { 82 if(*it==child) 83 { 84 type_childs.erase (it); 85 break; 86 } 78 for (vector<const Object *>::iterator it = type_childs.begin(); 79 it < type_childs.end(); it++) { 80 if (*it == child) { 81 type_childs.erase(it); 82 break; 87 83 } 84 } 88 85 } 89 86 90 bool Object_impl::ErrorOccured(bool recursive) 91 { 92 if(recursive==true) 93 { 94 for(size_t i=0;i<childs.size();i++) 95 { 96 if(childs[i]->ErrorOccured(true)==true) 97 { 98 return true; 99 } 100 } 87 bool Object_impl::ErrorOccured(bool recursive) { 88 if (recursive == true) { 89 for (size_t i = 0; i < childs.size(); i++) { 90 if (childs[i]->ErrorOccured(true) == true) { 91 return true; 92 } 101 93 } 102 return error_occured; 94 } 95 return error_occured; 103 96 }
Note:
See TracChangeset
for help on using the changeset viewer.