Changeset 15 in flair-src for trunk/lib/FlairCore/src/Object_impl.cpp


Ignore:
Timestamp:
04/08/16 15:40:57 (8 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/Object_impl.cpp

    r2 r15  
    2323using namespace flair::core;
    2424
    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;
     25Object_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;
    3333
    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  }
    3838}
    3939
    40 Object_impl::~Object_impl()
    41 {
    42     //Printf("destruction Object %s %s\n",name.c_str(),type.c_str());
     40Object_impl::~Object_impl() {
     41  // Printf("destruction Object %s %s\n",name.c_str(),type.c_str());
    4342
    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         delete childs.front();
    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  }
    5049
    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  }
    5654
    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());
    5856}
    5957
    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);
     58void 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);
    6564}
    6665
    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());
     66void 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());
    7069
    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;
    7875    }
     76  }
    7977
    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;
    8783    }
     84  }
    8885}
    8986
    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         }
     87bool 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      }
    10193    }
    102     return error_occured;
     94  }
     95  return error_occured;
    10396}
Note: See TracChangeset for help on using the changeset viewer.