X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingTimeLabel.cxx;h=66b495b8c32f050269dd0fe925514e42fe85a9bd;hb=30e370a928f879a1c9be2bd685cda6cabec223cf;hp=e91f08a4e76f546428a2c0ec830194b4edce0ee3;hpb=10f37bf6f33a762626d7f1093b2f5450c1688667;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx index e91f08a4e..66b495b8c 100644 --- a/src/MEDCoupling/MEDCouplingTimeLabel.cxx +++ b/src/MEDCoupling/MEDCouplingTimeLabel.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,12 +16,17 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay (CEA/DEN) #include "MEDCouplingTimeLabel.hxx" +#include "InterpKernelException.hxx" + +#include + using namespace ParaMEDMEM; -unsigned int TimeLabel::GLOBAL_TIME=0; +std::size_t TimeLabel::GLOBAL_TIME=0; TimeLabel::TimeLabel():_time(GLOBAL_TIME++) { @@ -47,3 +52,61 @@ void TimeLabel::updateTimeWith(const TimeLabel& other) const if(_time::max()) +{ + if(!_tl) + throw INTERP_KERNEL::Exception("TimeLabelConstOverseer constructor : input instance must be not NULL !"); + _tl->updateTime(); + _ref_time=tl->getTimeOfThis(); +} + +/*! + * This method checks that the tracked instance is not NULL and if not NULL that its internal state has not changed. + */ +void TimeLabelConstOverseer::checkConst() const +{ + if(!_tl) + throw INTERP_KERNEL::Exception("TimeLabelConstOverseer::checkConst : NULL tracked instance !"); + _tl->updateTime(); + if(_ref_time!=_tl->getTimeOfThis()) + throw INTERP_KERNEL::Exception("TimeLabelConstOverseer::checkConst : the state of the controlled instance of TimeLable has changed !"); +} + +bool TimeLabelConstOverseer::resetState() +{ + if(_tl) + { + _tl->updateTime(); + _ref_time=_tl->getTimeOfThis(); + return true; + } + else + return false; +} + +bool TimeLabelConstOverseer::keepTrackOfNewTL(const TimeLabel *tl) +{ + if(_tl==tl) + return false; + _tl=tl; + if(_tl) + { + _tl->updateTime(); + _ref_time=_tl->getTimeOfThis(); + } + else + { + _ref_time=std::numeric_limits::max(); + } + return true; +}