28 debug(
"deleting Hierarchy "+
name(),
"Hierarchy::~Hierarchy");
36 std::vector<Hierarchy*> listlocale;
37 std::vector<Hierarchy*>::iterator iter;
38 info(
"loop on "+
name()+
" children.",
"Hierarchy::clear");
40 info(
"processing "+(*iter)->name()+
".",
"Hierarchy::clear");
51 info(
"Adding object "+(*iter)->name()+
" from the Hierarchy to the list of deleted objects.",
"Hierarchy::clear");
52 listlocale.push_back((*iter));
55 for (iter=listlocale.begin();iter!=listlocale.end();iter++){
56 info(
"Removing object "+(*iter)->name()+
".",
"Hierarchy::clear");
86 debug(element->
name()+
" added to the child tree.",
"Hierarchy::addChild");
94 std::vector<Hierarchy*>::iterator iter,
remove;
102 debug(
"removing "+(*remove)->name()+
" from the tree.",
"Hierarchy::delChild");
112 std::vector<Hierarchy*>::iterator iter,
remove;
114 if ((*iter)->name()==n){
remove=iter; flag=
true;}
117 debug(
"removing "+(*remove)->name()+
" from the tree.",
"Hierarchy::delChild");
134 std::string newpath =
path;
135 std::string up(
"..");
136 std::string separator(1,
'/');
142 if (path.compare(
"")==0 || path.compare(
"/")==0) {
147 if (path.compare(
name())==0){
152 if (path.compare(
"..")==0){
157 if (path.compare(
"../")==0){
163 int npos=path.find(separator,0);
168 if ( npos == (
int)(path.size()-1) ) {
169 newpath = std::string(path,0,npos);
175 newpath=std::string(path,1,path.size()-1);
179 if ( npos== (
int)(std::string::npos) ){
181 std::vector <Hierarchy*> list =
children();
182 std::vector<Hierarchy*>::iterator iter;
183 for (iter=list.begin();iter!=list.end();iter++){
184 if ((*iter)->name().compare(path)==0){
188 warning(this->
name()+std::string(
" has no child '")+path+
"'",
"Hierarchy::child");
193 int ipos=path.find(separator,0);
196 std::string newcurrentname=std::string(path,0,ipos);
197 newpath=std::string(path,ipos+1,path.size()-1);
201 if (0==newcurrentname.compare(
origin()->
name())){
208 std::vector <Hierarchy*> list =
children();
209 std::vector<Hierarchy*>::iterator iter;
210 for (iter=list.begin();iter!=list.end();iter++){
211 if ((*iter)->name().compare(newcurrentname)==0){
212 newcurrent = (*iter);
218 if (newcurrentname.compare(
"..")==0 && 0!=
parent()){
219 newcurrent=this->
parent();
224 warning(this->
name()+
" has no child '"+newcurrentname+
"'",
230 return newcurrent ->
child ( newpath );
241 std::string newpath =
path;
243 std::string up(
"..");
244 std::string separator(1,
'/');
245 std::string typeopen(1,
'[');
246 std::string typeclose(1,
']');
250 unsigned int npos=path.find(separator,0);
251 unsigned int opos=path.find(typeopen,0);
252 if ( npos==std::string::npos || npos == path.size()-1 ){
253 if ( path.compare(
"..")==0 ) {
257 if ( npos == path.size()-1 ) {
258 newpath = std::string(path,0,opos);
262 std::vector < Hierarchy* > list =
children();
263 std::vector < Hierarchy* >::iterator iter;
264 for (iter=list.begin();iter!=list.end();iter++){
265 std::string notypepath = std::string(path,0,opos);
266 if ((*iter)->name().compare(notypepath)==0){
270 warning(this->
name()+std::string(
" has no child ") +path,
"Hierarchy::child");
276 if (std::string(path,0,3).compare(std::string(
"../"))==0) {
277 newpath=std::string(path,3,path.size()-3);
280 if (std::string(path,0,1).compare(std::string(
"/"))==0) {
281 newpath=std::string(path,1,path.size()-1);
284 if ((std::string(path,0,3).compare(std::string(
"../")) !=0 ) &&
285 std::string(path,0,1).compare(std::string(
"/"))!=0 ) {
286 opos = path.find(typeopen,0);
287 int cpos = path.find(typeclose,0);
288 std::string
name = std::string (path,0,opos);
291 warning(path+
": no child found with such a name",
"Hierarchy::child");
293 newpath = std::string (path,cpos+2,path.size()-cpos-1);
311 std::string line=indent+
" -> "+
name()+
"["+
type()+
"] ";
312 if (std::string(
"")==indent){
313 info(
"Hierarchy for Object "+
name()+
"["+
type()+
"]",
"Hierarchy::tree");
316 std::vector<Hierarchy*> list =
children();
317 std::vector<Hierarchy*>::iterator iter;
318 for (iter=list.begin() ; iter!=list.end() ; ++iter){
320 (*iter)->tree(indent+tab);
330 if (parent->
type().compare( type )==0) {
334 return parent->
parent( type );
348 return m_parent->
path(str);
void info(std::string mymsg)
Hierarchy * childTyped(std::string)
Hierarchy * child(std::string)
Hierarchy()
Standard constructor.
void setParent(Hierarchy *parent)
std::vector< Hierarchy * > children()
void delChild(Hierarchy *)
unsigned long numberOfChildren()
std::vector< Hierarchy * > m_children
virtual ~Hierarchy()
Destructor.
void debug(std::string mymsg)
virtual void addChild(Hierarchy *element)
void msgSvc(int level, std::string msg, std::string name)
std::string pathTyped(std::string=std::string(""))
void warning(std::string mymsg)
std::string path(std::string=std::string(""))