/* * Advanced Simulation Library * * Copyright 2015 Avtech Scientific * * * This file is part of Advanced Simulation Library (ASL). * * ASL is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, version 3 of the License. * * ASL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with ASL. If not, see . * */ #ifndef ASLUVALUE_H #define ASLUVALUE_H #include "aslTimeStamp.h" #include namespace asl { /// Updatable value. This class stores value and its TimeStamp \ingroup LDI template class UValue { public: std::shared_ptr p; TimeStamp ts; inline explicit UValue():p(new T){} inline explicit UValue(const T & a):p(new T(a)){ts.update();} /// updates UValue::ts automaticaly inline const T & operator=(const T& a){ts.update(); return (*p = a);} inline const T & v() const {return *p;}; inline T & v() {return *p;}; }; /// \related UValue template inline bool operator==(const asl::UValue & a,const T & v); /// \related UValue template inline bool operator!=(const asl::UValue & a,const T & v); //-------------------------- Implementation -------------------------- template inline bool operator==(const asl::UValue & a,const T & v) { return *(a.p) == v; } template inline bool operator!=(const asl::UValue & a,const T & v) { return *(a.p) != v; } } //namespace asl #endif // ASLUVALUE_H