00001 #include "stdafx.h"
00002
00003 #include "BON.h"
00004 #include "BONImpl.h"
00005 #include "Sheet.h"
00006 #include "logger.h"
00007 #include <algorithm>
00008 #include "globals.h"
00009 extern Globals global_vars;
00010
00011 Sheet * Sheet::m_theOnlyInstance = 0;
00012 BON::Folder Sheet::m_BON_Project_Root_Folder = BON::Folder();
00013 Sheet::Sheet()
00014 : m_projName(""),
00015 m_projVersion(),
00016 m_projGUID(),
00017 m_projCreated(),
00018 m_projModified(),
00019 m_projAuthor(),
00020 m_projComment(),
00021 m_projNamespace(),
00022 m_rootFolder(),
00023 m_fcoRepList(),
00024 m_atomList(),
00025 m_modelList(),
00026 m_connList(),
00027 m_refList(),
00028 m_setList(),
00029 m_folderList(),
00030 m_aspectList(),
00031 m_constraintList(),
00032 m_constraintFuncList(),
00033 m_attributeList()
00034 {
00035 }
00036
00037
00038 Sheet::~Sheet()
00039 {
00040 m_theOnlyInstance = 0;
00041
00042 {
00043 FcoRep_Iterator it( m_fcoRepList.begin() );
00044 for( ; it != m_fcoRepList.end(); ++it)
00045 {
00046 FcoRep * act_ptr = * it;
00047 delete act_ptr;
00048 }
00049 }
00050 {
00051 AtomRep_Iterator it = m_atomList.begin();
00052 for( ; it != m_atomList.end(); ++it)
00053 {
00054 AtomRep * act_ptr = * it;
00055 delete act_ptr;
00056 }
00057 }
00058 {
00059 ModelRep_Iterator it = m_modelList.begin();
00060 for( ; it != m_modelList.end(); ++it)
00061 {
00062 ModelRep * act_ptr = * it;
00063 delete act_ptr;
00064 }
00065 }
00066 {
00067 ConnectionRep_Iterator it = m_connList.begin();
00068 for( ; it != m_connList.end(); ++it)
00069 {
00070 ConnectionRep * act_ptr = * it;
00071 delete act_ptr;
00072 }
00073 }
00074 {
00075 SetRep_Iterator it = m_setList.begin();
00076 for( ; it != m_setList.end(); ++it)
00077 {
00078 SetRep * act_ptr = * it;
00079 delete act_ptr;
00080 }
00081 }
00082 {
00083 ReferenceRep_Iterator it = m_refList.begin();
00084 for( ; it != m_refList.end(); ++it)
00085 {
00086 ReferenceRep * act_ptr = * it;
00087 delete act_ptr;
00088 }
00089 }
00090 {
00091 FolderRep_Iterator ai = m_folderList.begin();
00092 for( ; ai != m_folderList.end(); ++ai)
00093 {
00094 FolderRep * act_ptr = * ai;
00095 delete act_ptr;
00096 }
00097 }
00098 {
00099 AspectRep_Iterator ai = m_aspectList.begin();
00100 for( ; ai != m_aspectList.end(); ++ai)
00101 {
00102 AspectRep * act_ptr = * ai;
00103 delete act_ptr;
00104 }
00105 }
00106 {
00107 ConstraintRep_Iterator ai = m_constraintList.begin();
00108 for( ; ai != m_constraintList.end(); ++ai)
00109 {
00110 ConstraintRep * act_ptr = * ai;
00111 delete act_ptr;
00112 }
00113 }
00114 {
00115 ConstraintFuncRep_Iterator ai = m_constraintFuncList.begin();
00116 for( ; ai != m_constraintFuncList.end(); ++ai)
00117 {
00118 ConstraintFuncRep * act_ptr = * ai;
00119 delete act_ptr;
00120 }
00121 }
00122 {
00123 AttributeRep_Iterator ai = m_attributeList.begin();
00124 for( ; ai != m_attributeList.end(); ++ai)
00125 {
00126 AttributeRep * act_ptr = * ai;
00127 delete act_ptr;
00128 }
00129 }
00130 m_fcoRepList.clear();
00131 m_atomList.clear();
00132 m_modelList.clear();
00133 m_connList.clear();
00134 m_refList.clear();
00135 m_setList.clear();
00136
00137 m_folderList.clear();
00138
00139 m_aspectList.clear();
00140 m_constraintList.clear();
00141 m_constraintFuncList.clear();
00142
00143 m_attributeList.clear();
00144 Sheet::m_BON_Project_Root_Folder = BON::Folder();
00145 }
00146
00147
00148 void Sheet::setProject( BON::Project& project)
00149 {
00150 m_projName = project->getName();
00151 m_projVersion = project->getVersion();
00152 m_projGUID = project->getGUID();
00153 m_projCreated = project->getCreationTime();
00154 m_projModified = project->getChangeTime();
00155 m_projAuthor = project->getAuthor();
00156 m_projComment = project->getComment();
00157
00158 BON::RegistryNode rn = project->getRootFolder()->getRegistry()->getChild( "Namespace");
00159 if( rn) m_projNamespace = rn->getValue();
00160 else m_projNamespace = "";
00161
00162
00163 std::string new_name;
00164 if( !Sheet::makeValidParadigmName( m_projName, new_name))
00165 {
00166 global_vars.err << MSG_ERROR << "Error: Incorrect paradigm name: \"" << m_projName << "\". Use only alphanumerics, '.' and '_'. No spaces please. Using modified name: \"" << new_name << "\".\n";
00167 m_projName = new_name;
00168 }
00169
00170
00171 new_name = "";
00172 if( !Sheet::makeValidNamespace( m_projNamespace, new_name))
00173 {
00174 global_vars.err << MSG_ERROR << "Error: Incorrect namespace specified: \"" << m_projNamespace << "\". Use only alphanumerics and '_'. Using modified name: \"" << new_name << "\".\n";
00175 m_projNamespace = new_name;
00176 }
00177 }
00178
00179 bool Sheet::finalize()
00180 {
00181 bool ret_val = false;
00182 if ( doInheritance( FCO::INTERFACE)
00183 && doInheritance( FCO::IMPLEMENTATION))
00184 {
00185 init();
00186 initRoleNames();
00187 ret_val = true;
00188 }
00189 else
00190 global_vars.err << MSG_ERROR << "Error: Inheritance problems\n";
00191
00192 return ret_val;
00193 }
00194
00195 void Sheet::init()
00196 {
00197 {FcoRep_Iterator it0( m_fcoRepList.begin());
00198 for( ; it0 != m_fcoRepList.end(); ++it0 )
00199 {
00200 (*it0)->initNamespace();
00201 (*it0)->initAttributes();
00202 if ( isInRootFolder( *it0)) m_rootFolder.addRootElement( *it0);
00203 }}
00204
00205 {AtomRep_Iterator it1 = m_atomList.begin();
00206 for( ; it1 != m_atomList.end(); ++it1 )
00207 {
00208 (*it1)->initNamespace();
00209 (*it1)->initAttributes();
00210 if ( isInRootFolder( *it1)) m_rootFolder.addRootElement( *it1);
00211 }}
00212
00213 {ModelRep_Iterator it2 = m_modelList.begin();
00214 for( ; it2 != m_modelList.end(); ++it2 )
00215 {
00216 (*it2)->initNamespace();
00217 (*it2)->initAttributes();
00218 if ( isInRootFolder( *it2)) m_rootFolder.addRootElement( *it2);
00219 }}
00220
00221 {ConnectionRep_Iterator it3 = m_connList.begin();
00222 for( ; it3 != m_connList.end(); ++it3 )
00223 {
00224 (*it3)->initNamespace();
00225 (*it3)->initAttributes();
00226 if ( isInRootFolder( *it3)) m_rootFolder.addRootElement( *it3);
00227 }}
00228
00229 {SetRep_Iterator it4 = m_setList.begin();
00230 for( ; it4 != m_setList.end(); ++it4 )
00231 {
00232 (*it4)->initNamespace();
00233 (*it4)->initAttributes();
00234 if ( isInRootFolder( *it4)) m_rootFolder.addRootElement( *it4);
00235 }}
00236
00237 {ReferenceRep_Iterator it5 = m_refList.begin();
00238 for( ; it5 != m_refList.end(); ++it5 )
00239 {
00240 (*it5)->initNamespace();
00241 (*it5)->initAttributes();
00242 if ( isInRootFolder( *it5)) m_rootFolder.addRootElement( *it5);
00243 }}
00244
00245 {FolderRep_Iterator it6 = m_folderList.begin();
00246 for( ; it6 != m_folderList.end(); ++it6 )
00247 {
00248 (*it6)->initNamespace();
00249 (*it6)->initAttributes();
00250 if ( isInRootFolder( *it6)) m_rootFolder.addSubFolder( *it6);
00251 }}
00252
00253 {AttributeRep_Iterator it7 = m_attributeList.begin();
00254 for( ; it7 != m_attributeList.end(); ++it7 )
00255 {
00256 (*it7)->initNamespace();
00257 }}
00258
00259 {ConstraintFuncRep_Iterator it8 = m_constraintFuncList.begin();
00260 for( ; it8 != m_constraintFuncList.end(); ++it8 )
00261 {
00262 (*it8)->initNamespace();
00263 }}
00264
00265 {ConstraintRep_Iterator it9 = m_constraintList.begin();
00266 for( ; it9 != m_constraintList.end(); ++it9 )
00267 {
00268 (*it9)->initNamespace();
00269 }}
00270 }
00271
00272
00273 void Sheet::initRoleNames()
00274 {
00275 ModelRep_Iterator jt1( m_modelList.begin());
00276 for( ; jt1 != m_modelList.end(); ++jt1)
00277 {
00278 ModelRep * mod_ptr = *jt1;
00279 mod_ptr->initRoles();
00280 }
00281 }
00282
00283
00284 FcoRep* Sheet::createFcoRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00285 {
00286 FcoRep * ll = new FcoRep( ptr, resp_ptr);
00287 addFcoRep( ll);
00288 return ll;
00289 }
00290
00291
00292 AtomRep* Sheet::createAtomRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00293 {
00294 AtomRep * ll = new AtomRep( ptr, resp_ptr);
00295 addAtomRep( ll);
00296 return ll;
00297 }
00298
00299
00300 ModelRep* Sheet::createModelRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00301 {
00302 ModelRep * ll = new ModelRep( ptr, resp_ptr);
00303 addModelRep( ll);
00304 return ll;
00305 }
00306
00307
00308 ConnectionRep* Sheet::createConnectionRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00309 {
00310 ConnectionRep * ll = new ConnectionRep( ptr, resp_ptr);
00311 addConnectionRep( ll);
00312 return ll;
00313 }
00314
00315
00316 SetRep* Sheet::createSetRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00317 {
00318 SetRep * ll = new SetRep( ptr, resp_ptr);
00319 addSetRep( ll);
00320 return ll;
00321 }
00322
00323
00324 ReferenceRep* Sheet::createReferenceRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00325 {
00326 ReferenceRep * ll = new ReferenceRep( ptr, resp_ptr);
00327 addReferenceRep( ll);
00328 return ll;
00329 }
00330
00331
00332 FolderRep* Sheet::createFolderRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00333 {
00334 FolderRep * ll = new FolderRep( ptr, resp_ptr);
00335 addFolderRep( ll);
00336 return ll;
00337 }
00338
00339
00340 AspectRep* Sheet::createAspectRep( BON::FCO& ptr, BON::FCO& resp_ptr)
00341 {
00342 AspectRep * ll = new AspectRep( ptr, resp_ptr);
00343 addAspectRep( ll);
00344 return ll;
00345 }
00346
00347
00348 ConstraintRep* Sheet::createConstraintRep( BON::FCO& ptr)
00349 {
00350 ConstraintRep * ll = new ConstraintRep( ptr);
00351 addConstraintRep( ll);
00352 return ll;
00353 }
00354
00355
00356 ConstraintFuncRep* Sheet::createConstraintFuncRep( BON::FCO& ptr)
00357 {
00358 ConstraintFuncRep * ll = new ConstraintFuncRep( ptr);
00359 addConstraintFuncRep( ll);
00360 return ll;
00361 }
00362
00363
00364 AttributeRep* Sheet::createBoolAttributeRep( BON::FCO& ptr)
00365 {
00366 AttributeRep * ll = new BoolAttributeRep( ptr);
00367 addAttributeRep( ll);
00368 return ll;
00369 }
00370
00371
00372 AttributeRep* Sheet::createEnumAttributeRep( BON::FCO& ptr)
00373 {
00374 AttributeRep * ll = new EnumAttributeRep( ptr);
00375 addAttributeRep( ll);
00376 return ll;
00377 }
00378
00379
00380 AttributeRep* Sheet::createFieldAttributeRep( BON::FCO& ptr)
00381 {
00382 AttributeRep * ll = new FieldAttributeRep( ptr);
00383 addAttributeRep( ll);
00384 return ll;
00385 }
00386
00387
00388 void Sheet::addFcoRep( FcoRep * ptr)
00389 {
00390 m_fcoRepList.push_back( ptr);
00391 }
00392
00393
00394 void Sheet::addAtomRep( AtomRep * ptr)
00395 {
00396 m_atomList.push_back( ptr);
00397 }
00398
00399
00400 void Sheet::addModelRep( ModelRep * ptr)
00401 {
00402 m_modelList.push_back( ptr);
00403 }
00404
00405
00406 void Sheet::addConnectionRep( ConnectionRep * ptr)
00407 {
00408 m_connList.push_back( ptr);
00409 }
00410
00411
00412 void Sheet::addReferenceRep( ReferenceRep * ptr)
00413 {
00414 m_refList.push_back( ptr);
00415 }
00416
00417
00418 void Sheet::addSetRep( SetRep * ptr)
00419 {
00420 m_setList.push_back( ptr);
00421 }
00422
00423
00424 void Sheet::addAspectRep( AspectRep * ptr)
00425 {
00426 m_aspectList.push_back( ptr);
00427 }
00428
00429
00430 void Sheet::addFolderRep( FolderRep * ptr)
00431 {
00432 m_folderList.push_back(ptr);
00433 }
00434
00435
00436 void Sheet::addConstraintRep( ConstraintRep * ptr)
00437 {
00438 m_constraintList.push_back( ptr);
00439 }
00440
00441
00442 void Sheet::addConstraintFuncRep( ConstraintFuncRep * ptr)
00443 {
00444 m_constraintFuncList.push_back( ptr);
00445 }
00446
00447
00448 void Sheet::addAttributeRep( AttributeRep * ptr)
00449 {
00450 m_attributeList.push_back(ptr);
00451 }
00452
00453
00454
00463 FCO* Sheet::findFCO( const BON::FCO& ptr)
00464 {
00465 FcoRep_Iterator it0( m_fcoRepList.begin());
00466 for( ; it0 != m_fcoRepList.end(); ++it0 )
00467 {
00468 if ((*it0)->getPtr() == ptr) return *it0;
00469 }
00470
00471 AtomRep_Iterator it1 = m_atomList.begin();
00472 for( ; it1 != m_atomList.end(); ++it1 )
00473 {
00474 if ((*it1)->getPtr() == ptr) return *it1;
00475 }
00476
00477 ModelRep_Iterator it2 = m_modelList.begin();
00478 for( ; it2 != m_modelList.end(); ++it2 )
00479 {
00480 if ((*it2)->getPtr() == ptr) return *it2;
00481 }
00482
00483 ConnectionRep_Iterator it3 = m_connList.begin();
00484 for( ; it3 != m_connList.end(); ++it3 )
00485 {
00486 if ((*it3)->getPtr() == ptr) return *it3;
00487 }
00488
00489 SetRep_Iterator it4 = m_setList.begin();
00490 for( ; it4 != m_setList.end(); ++it4 )
00491 {
00492 if ((*it4)->getPtr() == ptr) return *it4;
00493 }
00494
00495 ReferenceRep_Iterator it5 = m_refList.begin();
00496 for( ; it5 != m_refList.end(); ++it5 )
00497 {
00498 if ((*it5)->getPtr() == ptr) return *it5;
00499 }
00500 return 0;
00501 }
00502
00503
00504 ReferenceRep* Sheet::findRef( const BON::FCO& ptr)
00505 {
00506 ReferenceRep_Iterator it( m_refList.begin());
00507 for( ; it != m_refList.end(); ++it )
00508 {
00509 if ((*it)->getPtr() == ptr) return *it;
00510 }
00511 return 0;
00512
00513 }
00514
00515
00516 Any* Sheet::findAny( const BON::FCO& ptr)
00517 {
00518 FolderRep_Iterator it5 = m_folderList.begin();
00519 for( ; it5 != m_folderList.end(); ++it5 )
00520 {
00521 if ((*it5)->getPtr() == ptr) return *it5;
00522 }
00523
00524 AspectRep_Iterator it1( m_aspectList.begin());
00525 for( ; it1 != m_aspectList.end(); ++it1 )
00526 {
00527 if ((*it1)->getPtr() == ptr) return *it1;
00528 }
00529
00530 ConstraintRep_Iterator it2 = m_constraintList.begin();
00531 for( ; it2 != m_constraintList.end(); ++it2 )
00532 {
00533 if ((*it2)->getPtr() == ptr) return *it2;
00534 }
00535
00536 ConstraintFuncRep_Iterator it3 = m_constraintFuncList.begin();
00537 for( ; it3 != m_constraintFuncList.end(); ++it3 )
00538 {
00539 if ((*it3)->getPtr() == ptr) return *it3;
00540 }
00541
00542 AttributeRep_Iterator it4 = m_attributeList.begin();
00543 for( ; it4 != m_attributeList.end(); ++it4 )
00544 {
00545 if ((*it4)->getPtr() == ptr) return *it4;
00546 }
00547
00548 return findFCO( ptr);
00549 }
00550
00551
00552 bool Sheet::isInRootFolder( Any * elem)
00553 {
00554 return elem->isInRootFolder();
00555 }
00556
00557
00558 void Sheet::gatherNodes( NODE_VECTOR & nodes)
00559 {
00560 nodes.insert( nodes.end(), m_fcoRepList.begin(), m_fcoRepList.end());
00561 nodes.insert( nodes.end(), m_atomList.begin(), m_atomList.end());
00562 nodes.insert( nodes.end(), m_modelList.begin(), m_modelList.end());
00563 nodes.insert( nodes.end(), m_connList.begin(), m_connList.end());
00564 nodes.insert( nodes.end(), m_setList.begin(), m_setList.end());
00565 nodes.insert( nodes.end(), m_refList.begin(), m_refList.end());
00566
00567 }
00568
00569
00570 void Sheet::assignCliqueId( CLIQUE_VECTOR & clique_id, const NODE_VECTOR & nodes)
00571 {
00572 unsigned int cl_id = 0;
00573 unsigned int len = nodes.size();
00574 for(unsigned int i = 0 ; i < len; ++i)
00575 clique_id.push_back(i+1);
00576
00577 }
00578
00579
00580 void Sheet::replaceCliqueId( CLIQUE_VECTOR & clique_id, unsigned int id1, unsigned int id2)
00581 {
00582 unsigned int search_id = id1, replace_id = id2;
00583
00584 for (unsigned int k = 0; k < clique_id.size(); ++k)
00585 if ( clique_id[k] == search_id)
00586 clique_id[k] = replace_id;
00587
00588 }
00589
00590
00591 unsigned int Sheet::howManyCliques( CLIQUE_VECTOR & clique_id)
00592 {
00593 std::map<unsigned int,unsigned int> t_m;
00594 for (unsigned int k = 0; k < clique_id.size(); ++k)
00595 {
00596 unsigned int curr_id = clique_id[k];
00597 ++t_m[curr_id];
00598 }
00599 unsigned int val = 0;
00600 std::map<unsigned int,unsigned int>::iterator i = t_m.begin();
00601 for( ; i != t_m.end(); ++i)
00602 {
00603 ++val;
00604 }
00605 return val;
00606 }
00607
00608
00609 void Sheet::getChildren( unsigned int base, const NODE_VECTOR & nodes, UI_LIST & children, FCO::INHERITANCE_TYPE inh_type)
00610 {
00611 for (unsigned int i = 0; i < nodes.size(); ++i)
00612 if ( edge(i, base, nodes, inh_type))
00613 {
00614 unsigned int j = 0;
00615 while( j < children.size() && children[j] != i)
00616 ++j;
00617 if ( j == children.size())
00618 children.push_back( i);
00619 }
00620 }
00621
00622
00623 void Sheet::vectorCopy( UI_LIST & target, const UI_LIST & source, UI_LIST & duplicates)
00624 {
00625 for(unsigned int i = 0; i < source.size(); ++i)
00626 {
00627 unsigned int j = 0;
00628 while( j != target.size() && target[j] != source[i])
00629 ++j;
00630 if ( j == target.size())
00631 target.push_back( source[i]);
00632 else
00633 duplicates.push_back( source[i]);
00634 }
00635 }
00636
00637
00638 bool Sheet::edge( unsigned int i, unsigned int j, const NODE_VECTOR & nodes, FCO::INHERITANCE_TYPE inh_type)
00639 {
00640 return nodes[i]->hasParent( nodes[j], inh_type);
00641 }
00642
00643
00644 bool Sheet::doInheritance( FCO::INHERITANCE_TYPE inh_type)
00645 {
00646 unsigned int i, j;
00647 std::map<unsigned int, unsigned int> depends_upon;
00648 CLIQUE_VECTOR clique_vec;
00649 NODE_VECTOR node_vec;
00650
00651 gatherNodes( node_vec);
00652
00653 assignCliqueId( clique_vec, node_vec);
00654
00655 for( i = 0; i < node_vec.size(); ++i)
00656 for ( j = 0; j < node_vec.size(); ++j)
00657 {
00658 if ( edge(i,j, node_vec, inh_type))
00659 {
00660 ++depends_upon[i];
00661
00662 if ( clique_vec[j] != clique_vec[i])
00663 replaceCliqueId( clique_vec, clique_vec[j], clique_vec[i]);
00664 }
00665 }
00666
00667 std::list<unsigned int> elements;
00668 std::vector<unsigned int> dupl_temp;
00669
00670 unsigned int no_of_cliques = howManyCliques( clique_vec);
00671
00672 for( i = 0; i < node_vec.size(); ++i)
00673 if (depends_upon[i]==0)
00674 elements.push_back(i);
00675
00676 if (elements.size() < no_of_cliques)
00677 {
00678 TO("Inheritance loop found in model!!! Please correct it!\n");
00679 global_vars.err << MSG_ERROR << "Inheritance loop found in model!!! Please correct it!\n";
00680
00681
00682
00683 return false;
00684 }
00685
00686 std::map< unsigned int, std::vector<unsigned int> > ancestors;
00687 std::map< unsigned int, std::vector<unsigned int> > descendants;
00688
00689 bool loop = false;
00690
00691 while ( !elements.empty() && !loop)
00692 {
00693
00694 unsigned int base = *elements.begin();
00695 elements.pop_front();
00696
00697
00698 std::vector<unsigned int> children;
00699 getChildren( base, node_vec, children, inh_type);
00700 for( j = 0; j < children.size(); ++j)
00701 {
00702 unsigned int child = children[j];
00703 elements.push_back( child);
00704 if (ancestors[child].end() ==
00705 std::find(ancestors[child].begin(), ancestors[child].end(), base))
00706 ancestors[child].push_back(base);
00707
00708 vectorCopy( ancestors[child], ancestors[base], dupl_temp);
00709 for ( unsigned int k = 0; k < ancestors[child].size(); ++k)
00710 if ( edge( ancestors[child][k], child, node_vec, inh_type))
00711 {
00712 FCO * fco1 = node_vec[ancestors[child][k]];
00713 FCO * fco2 = node_vec[child];
00714 TO("Loop between " + fco1->getName() + " and " + fco2->getName());
00715 global_vars.err << MSG_ERROR << "Loop between " << fco1 << " and " << fco2 << "\n";
00716
00717 loop = true;
00718
00719 return false;
00720 }
00721 }
00722 }
00723
00724
00725 std::map< unsigned int, std::vector<unsigned int> >::iterator anc_it = ancestors.begin();
00726 for( ; anc_it != ancestors.end(); ++anc_it)
00727 {
00728 unsigned int id = anc_it->first;
00729 std::vector<unsigned int> & ancestors_of_id = anc_it->second;
00730
00731 for( unsigned int k = 0; k < ancestors_of_id.size(); ++k)
00732 {
00733
00734
00735
00736
00737 if ( std::find( descendants[ancestors_of_id[k]].begin(), descendants[ancestors_of_id[k]].end(), id) ==
00738 descendants[ancestors_of_id[k]].end())
00739 {
00740 descendants[ancestors_of_id[k]].push_back(id);
00741 std::string m1 = node_vec[ancestors_of_id[k]]->getName() + " has desc " + node_vec[id]->getName();
00742
00743 }
00744 }
00745 }
00746
00747 for( i = 0; i < node_vec.size(); ++i)
00748 {
00749
00750 std::vector< FCO*> anc_list, desc_list;
00751 for ( unsigned int k = 0; k < ancestors[i].size(); ++k)
00752 {
00753 anc_list.push_back( node_vec[ancestors[i][k]]);
00754
00755 }
00756
00757 for ( unsigned int l = 0; l < descendants[i].size(); ++l)
00758 {
00759 desc_list.push_back( node_vec[descendants[i][l]]);
00760
00761 }
00762
00763
00764 node_vec[i]->setAncestors( inh_type, anc_list);
00765 node_vec[i]->setDescendants( inh_type, desc_list);
00766 }
00767 return true;
00768 }
00769
00770 bool Sheet::makeValidParadigmName( const std::string& pInName, std::string& res)
00771 {
00772 res = pInName;
00773 bool inv(res.length() == 0);
00774
00775 for( unsigned int i = 0; i < res.length(); ++i)
00776 {
00777 bool v = res[i] >= 'a' && res[i] <= 'z' ||
00778 res[i] >= 'A' && res[i] <= 'Z' ||
00779 res[i] >= '0' && res[i] <= '9' ||
00780 res[i] == '.' ||
00781 res[i] >= '_';
00782
00783 if( !v)
00784 {
00785 res[i] = '_';
00786 inv = true;
00787 }
00788 }
00789 return !inv;
00790 }
00791
00792 bool Sheet::makeValidNamespace( const std::string& pInName, std::string& res)
00793 {
00794 res = pInName;
00795 bool inv = false;
00796 for( unsigned int i = 0; i < res.length(); ++i)
00797 {
00798 bool v = res[i] >= 'a' && res[i] <= 'z'
00799 || res[i] >= 'A' && res[i] <= 'Z'
00800 || res[i] >= '0' && res[i] <= '9' && i >= 1
00801 || res[i] == '_';
00802
00803 if( !v)
00804 {
00805 res[i] = '_';
00806 inv = true;
00807 }
00808 }
00809 return !inv;
00810 }