aslUValue.h
Go to the documentation of this file.
/*
* Advanced Simulation Library <http://asl.org.il>
*
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
*
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef ASLUVALUE_H
#define ASLUVALUE_H
#include "aslTimeStamp.h"
#include <memory>
namespace asl
{
template<typename T> class UValue
{
public:
std::shared_ptr<T> p;
TimeStamp ts;
inline explicit UValue():p(new T){}
inline explicit UValue(const T & a):p(new T(a)){ts.update();}
inline const T & operator=(const T& a){ts.update(); return (*p = a);}
inline const T & v() const {return *p;};
inline T & v() {return *p;};
};
template<typename T> inline bool operator==(const asl::UValue<T> & a,const T & v);
template<typename T> inline bool operator!=(const asl::UValue<T> & a,const T & v);
//-------------------------- Implementation --------------------------
template<typename T> inline bool operator==(const asl::UValue<T> & a,const T & v)
{
return *(a.p) == v;
}
template<typename T> inline bool operator!=(const asl::UValue<T> & a,const T & v)
{
return *(a.p) != v;
}
} //namespace asl
#endif // ASLUVALUE_H
asl::TimeStamp
<>
Definition: aslTimeStamp.h:31
asl::TimeStamp::update
void update()
Definition: aslTimeStamp.h:39
asl::UValue
Updatable value. This class stores value and its TimeStamp.
Definition: aslUValue.h:35
asl::UValue::v
const T & v() const
Definition: aslUValue.h:43
asl::UValue::operator=
const T & operator=(const T &a)
updates UValue::ts automaticaly
Definition: aslUValue.h:42
asl::UValue::UValue
UValue(const T &a)
Definition: aslUValue.h:40
asl::UValue::v
T & v()
Definition: aslUValue.h:44
asl::UValue::UValue
UValue()
Definition: aslUValue.h:39
asl::UValue::ts
TimeStamp ts
Definition: aslUValue.h:38
asl::UValue::p
std::shared_ptr< T > p
Definition: aslUValue.h:37
asl
Advanced Simulation Library.
Definition: aslDataInc.h:31
asl::operator==
bool operator==(const std::vector< T > &vector1, const std::vector< T > &vector2)
Compares two vectors.
Definition: aslUtilities.h:185
asl::operator!=
const bool operator!=(const AVec< T > &a, const AVec< T > &b)
Definition: aslVectorsDynamicLengthOperations.h:246
aslTimeStamp.h