source: flair-src/branches/sanscv/lib/FlairCore/src/Object_impl.cpp@ 326

Last change on this file since 326 was 324, checked in by Sanahuja Guillaume, 2 years ago

removing opencv dependency

File size: 2.4 KB
RevLine 
[324]1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2012/05/07
6// filename: Object.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: classe pour qobject
14//
15//
16/*********************************************************************/
17
18#include "Object.h"
19#include "Object_impl.h"
20
21using std::string;
22using std::vector;
23using namespace flair::core;
24
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;
33
34 if (parent != NULL) {
35 if (name == "")
36 this->name = parent->ObjectName();
37 }
38}
39
40Object_impl::~Object_impl() {
41 // Printf("destruction Object %s %s\n",name.c_str(),type.c_str());
42
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 }
49
50 if (type_childs.size() != 0) {
51 type_childs.clear();
52 self->Warn("type_childs not cleared\n");
53 }
54
55 // Printf("destruction Object %s %s ok\n",name.c_str(),type.c_str());
56}
57
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);
64}
65
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());
69
70 for (vector<const Object *>::iterator it = childs.begin(); it < childs.end();
71 it++) {
72 if (*it == child) {
73 childs.erase(it);
74 break;
75 }
76 }
77
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;
83 }
84 }
85}
86
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 }
93 }
94 }
95 return error_occured;
96}
Note: See TracBrowser for help on using the repository browser.