Changeset 962


Ignore:
Timestamp:
10/04/16 19:01:39 (8 years ago)
Author:
mhnguyen
Message:

Improving name-search in inheritance tree

+) If there is no name defined in a inheritance tree, id of the ancestor will be used

Test
+) Ok

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/declare_ref_func.hpp

    r941 r962  
    1818  bool hasDirect##type##Reference(void) const;              \ 
    1919  C##type* getDirect##type##Reference(void) const;          \ 
    20   const StdString& get##type##OutputName(void) const;       \ 
     20  const StdString get##type##OutputName(void) const;        \ 
    2121  void setAttributesReference(bool apply = true);           \ 
    2222  bool hasRefTo(C##type* ref) const;                        \ 
     
    8787}                                                                      \ 
    8888                                                                       \ 
    89 const StdString& C##type::get##type##OutputName(void) const            \ 
     89const StdString C##type::get##type##OutputName(void) const            \ 
    9090{                                                                      \ 
    9191  if (!this->name.isEmpty())                                           \ 
     
    9595    const C##type* refer_ptr = this, *tmp_ptr;                         \ 
    9696    StdString nameRef = this->name_##_ref;                             \ 
     97    std::set<const C##type*> tmpRefObjects;                                  \ 
    9798    while (refer_ptr->hasAutoGeneratedId() &&                          \ 
    9899          (C##type::has(nameRef)))                                     \ 
    99100    {                                                                  \ 
     101      tmpRefObjects.insert(refer_ptr);                                 \ 
    100102      tmp_ptr = refer_ptr;                                             \ 
    101103      refer_ptr = tmp_ptr->getDirect##type##Reference();               \ 
    102104      if (refer_ptr->hasDirect##type##Reference())                     \ 
    103105        nameRef = refer_ptr->name_##_ref;                              \ 
     106      if (tmpRefObjects.end() != tmpRefObjects.find(refer_ptr))        \ 
     107      {                                                                \ 
     108        ERROR("const StdString& C" #type "::get" #type "OutputName(void) const ",      \ 
     109              << "Circular dependency stopped for " #name_ " object "  \ 
     110              << "with id = \"" << refer_ptr->getId() << "\".");       \ 
     111      }                                                                \ 
    104112    }                                                                  \ 
    105     return refer_ptr->name_##_ref;                                     \ 
     113    return nameRef;                                                    \ 
    106114  }                                                                    \ 
    107115  else                                                                 \ 
Note: See TracChangeset for help on using the changeset viewer.