Ignore:
Timestamp:
10/30/15 16:33:48 (8 years ago)
Author:
rlacroix
Message:

Field: Handle more correctly the output name for the fields with a field_ref.

If the field has an explicitly defined name (which might be inherited) then it is used as the output name.
If no name was defined but an id was set, the id is used as the output name.
If no name was defined and the id was automatically generated, the id of the field directly referenced is used as the output name.

File:
1 edited

Legend:

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

    r768 r770  
    1212// Declarations 
    1313 
    14 #define DECLARE_REF_FUNC(type, name)                        \ 
     14#define DECLARE_REF_FUNC(type, name_)                       \ 
    1515public:                                                     \ 
    1616  bool hasDirect##type##Reference(void) const;              \ 
     
    2121  void solveRefInheritance(bool apply = true);              \ 
    2222  void solveBaseReference(void);                            \ 
     23  const StdString& get##type##OutputName(void) const;       \ 
    2324                                                            \ 
    2425private:                                                    \ 
     
    2728// Definitions 
    2829 
    29 #define DEFINE_REF_FUNC(type, name)                                    \ 
     30#define DEFINE_REF_FUNC(type, name_)                                   \ 
    3031void C##type::solveRefInheritance(bool apply)                          \ 
    3132{                                                                      \ 
     
    4243    {                                                                  \ 
    4344      ERROR("void C" #type "::solveRefInheritance(bool apply)",        \ 
    44             << "Circular dependency stopped for " #name " object "     \ 
     45            << "Circular dependency stopped for " #name_ " object "    \ 
    4546            << "with id = \"" << refer_ptr->getId() << "\".");         \ 
    4647    }                                                                  \ 
     
    5253void C##type::removeRefInheritance()                                   \ 
    5354{                                                                      \ 
    54   if (!this->name##_ref.isEmpty())                                     \ 
    55     this->name##_ref.reset();                                          \ 
     55  if (!this->name_##_ref.isEmpty())                                    \ 
     56    this->name_##_ref.reset();                                         \ 
    5657}                                                                      \ 
    5758                                                                       \ 
     
    7071    {                                                                  \ 
    7172      ERROR("void C" #type "::solveBaseReference(void)",               \ 
    72             << "Circular dependency stopped for " #name " object "     \ 
     73            << "Circular dependency stopped for " #name_ " object "    \ 
    7374            << "with id = \"" << baseRefObject->getId() << "\".");     \ 
    7475    }                                                                  \ 
     
    7879C##type* C##type::getDirect##type##Reference(void) const               \ 
    7980{                                                                      \ 
    80   if (this->name##_ref.isEmpty())                                      \ 
     81  if (this->name_##_ref.isEmpty())                                     \ 
    8182    return this->getBase##type##Reference();                           \ 
    8283                                                                       \ 
    83   if (!C##type::has(this->name##_ref))                                 \ 
     84  if (!C##type::has(this->name_##_ref))                                \ 
    8485    ERROR("C" #type "* C" #type "::getDirect" #type "Reference(void)", \ 
    85           << this->name##_ref                                          \ 
    86           << " refers to an unknown " #name " id.");                   \ 
     86          << this->name_##_ref                                         \ 
     87          << " refers to an unknown " #name_ " id.");                  \ 
    8788                                                                       \ 
    88   return C##type::get(this->name##_ref);                               \ 
     89  return C##type::get(this->name_##_ref);                              \ 
    8990}                                                                      \ 
    9091                                                                       \ 
     
    9899  return this->getBase##type##Reference()->getId();                    \ 
    99100}                                                                      \ 
    100                                                                        \ 
    101101bool C##type::hasDirect##type##Reference(void) const                   \ 
    102102{                                                                      \ 
    103   return !this->name##_ref.isEmpty();                                  \ 
     103  return !this->name_##_ref.isEmpty();                                 \ 
     104}                                                                      \ 
     105                                                                       \ 
     106const StdString& C##type::get##type##OutputName(void) const            \ 
     107{                                                                      \ 
     108  if (!this->name.isEmpty())                                           \ 
     109    return this->name;                                                 \ 
     110  else if (hasAutoGeneratedId() && hasDirect##type##Reference())       \ 
     111    return this->name_##_ref;                                          \ 
     112  else                                                                 \ 
     113    return getId();                                                    \ 
    104114}                                                                      \ 
    105115 
Note: See TracChangeset for help on using the changeset viewer.