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

Keep track of whether an object id was automatically generated or not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/object.cpp

    r511 r769  
    33namespace xios 
    44{ 
    5    /// ////////////////////// Définitions ////////////////////// /// 
     5  /// ////////////////////// Définitions ////////////////////// /// 
    66 
    7    CObject::CObject(void) 
    8       : id(), IdDefined(false) 
    9    { /* Ne rien faire de plus */ } 
     7  CObject::CObject(void) 
     8    : id(), idDefined(false), idAutoGenerated(false) 
     9  { /* Ne rien faire de plus */ } 
    1010 
    11    CObject::CObject(const StdString & id) 
    12       : id(id), IdDefined(true) 
    13    { /* Ne rien faire de plus */ } 
     11  CObject::CObject(const StdString& id, bool idAutoGenerated /*= false*/) 
     12    : id(id) 
     13    , idDefined(true) 
     14    , idAutoGenerated(idAutoGenerated) 
     15  { /* Ne rien faire de plus */ } 
    1416 
    15    CObject::CObject(const CObject & object) 
    16       : id(object.id), IdDefined(object.IdDefined) 
    17    { /* Ne rien faire de plus */ } 
     17  CObject::CObject(const CObject& object) 
     18    : id(object.id) 
     19    , idDefined(object.idDefined) 
     20    , idAutoGenerated(object.idAutoGenerated) 
     21  { /* Ne rien faire de plus */ } 
    1822 
    19    CObject::~CObject(void) 
    20    { /* Ne rien faire de plus */ } 
     23  CObject::~CObject(void) 
     24  { /* Ne rien faire de plus */ } 
    2125 
    22    const StdString & CObject::getId(void) const 
    23    { 
    24       return (this->id); 
    25    } 
     26  const StdString& CObject::getId(void) const 
     27  { 
     28    return this->id; 
     29  } 
    2630 
    27    const StdString& CObject::getIdServer() 
    28    { 
    29       return (this->id); 
    30    } 
     31  const StdString& CObject::getIdServer() const 
     32  { 
     33    return this->id; 
     34  } 
    3135 
    32    bool CObject::hasId(void) const 
    33    { 
    34       return (this->IdDefined); 
    35    } 
     36  bool CObject::hasId(void) const 
     37  { 
     38    return this->idDefined; 
     39  } 
    3640 
    37    void CObject::resetId(void) 
    38    { 
    39       this->IdDefined = false ; 
    40    } 
     41  bool CObject::hasAutoGeneratedId(void) const 
     42  { 
     43    return this->idAutoGenerated; 
     44  } 
    4145 
    42    void CObject::setId(const StdString & id) 
    43    { 
    44       this->id = id ; 
    45       this->IdDefined = true ; 
    46    } 
    47 /* 
    48    bool CObject::operator==(const CObject & other) const 
    49    { 
    50       if(!this->hasId() || !other.hasId()) 
    51          return (false); 
    52       return (this->id.compare(other.id) == 0); 
    53    } 
     46  void CObject::resetId(void) 
     47  { 
     48    this->idDefined = false; 
     49  } 
    5450 
    55    bool CObject::operator!=(const CObject & other) const 
    56    { 
    57       return (!(*this == other)); 
    58    } 
    59 */ 
    60    StdOStream & operator << (StdOStream & os, const CObject & object) 
    61    { 
    62       os << object.toString(); 
    63       return (os); 
    64    } 
     51  void CObject::setId(const StdString& id, bool idAutoGenerated /*= false*/) 
     52  { 
     53    this->id = id; 
     54    this->idDefined = true; 
     55    this->idAutoGenerated = false; 
     56  } 
    6557 
     58  /* 
     59  bool CObject::operator==(const CObject& other) const 
     60  { 
     61    if(!this->hasId() || !other.hasId()) 
     62    return false; 
     63    return this->id.compare(other.id) == 0; 
     64  } 
     65 
     66  bool CObject::operator!=(const CObject& other) const 
     67  { 
     68    return !(*this == other); 
     69  } 
     70  */ 
     71 
     72  StdOStream& operator<<(StdOStream& os, const CObject& object) 
     73  { 
     74    os << object.toString(); 
     75    return os; 
     76  } 
    6677} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.