ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
aslUValue.h
Go to the documentation of this file.
1/*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
24#ifndef ASLUVALUE_H
25#define ASLUVALUE_H
26
27#include "aslTimeStamp.h"
28#include <memory>
29
30namespace asl
31{
32
34 template<typename T> class UValue
35 {
36 public:
37 std::shared_ptr<T> p;
39 inline explicit UValue():p(new T){}
40 inline explicit UValue(const T & a):p(new T(a)){ts.update();}
42 inline const T & operator=(const T& a){ts.update(); return (*p = a);}
43 inline const T & v() const {return *p;};
44 inline T & v() {return *p;};
45 };
46
48 template<typename T> inline bool operator==(const asl::UValue<T> & a,const T & v);
50 template<typename T> inline bool operator!=(const asl::UValue<T> & a,const T & v);
51
52//-------------------------- Implementation --------------------------
53
54
55 template<typename T> inline bool operator==(const asl::UValue<T> & a,const T & v)
56 {
57 return *(a.p) == v;
58 }
59
60 template<typename T> inline bool operator!=(const asl::UValue<T> & a,const T & v)
61 {
62 return *(a.p) != v;
63 }
64
65} //namespace asl
66
67
68#endif // ASLUVALUE_H
Updatable value. This class stores value and its TimeStamp.
Definition aslUValue.h:35
const T & v() const
Definition aslUValue.h:43
const T & operator=(const T &a)
updates UValue::ts automaticaly
Definition aslUValue.h:42
UValue(const T &a)
Definition aslUValue.h:40
TimeStamp ts
Definition aslUValue.h:38
std::shared_ptr< T > p
Definition aslUValue.h:37
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
Advanced Simulation Library.
Definition aslDataInc.h:31
bool operator==(const std::vector< T > &vector1, const std::vector< T > &vector2)
Compares two vectors.
const bool operator!=(const AVec< T > &a, const AVec< T > &b)