NorMIT-nav  22.09
An IGT application
cxOptionalValue.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXOPTIONALVALUE_H
13 #define CXOPTIONALVALUE_H
14 
15 #include "cxResourceExport.h"
16 
17 namespace cx
18 {
19 
26 template<class T> class cxResource_EXPORT OptionalValue
27 {
28 public:
29  OptionalValue() : mValid(false) {}
30  explicit OptionalValue(T val) : mValue(val), mValid(val) {}
31  const T& get() const { return mValue; }
32  void set(const T& val) { mValue=val; mValid=true; }
33  bool isValid() const { return mValid; }
34  void reset() { mValid=false; }
35 private:
36  T mValue;
37  bool mValid;
38 };
39 
40 
41 } // namespace cx
42 
43 
44 #endif // CXOPTIONALVALUE_H
cx::OptionalValue
Definition: cxOptionalValue.h:26
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::OptionalValue::isValid
bool isValid() const
Definition: cxOptionalValue.h:33
cx::OptionalValue::get
const T & get() const
Definition: cxOptionalValue.h:31
cx::OptionalValue::OptionalValue
OptionalValue()
Definition: cxOptionalValue.h:29
cx::OptionalValue::set
void set(const T &val)
Definition: cxOptionalValue.h:32
cx::OptionalValue::reset
void reset()
Definition: cxOptionalValue.h:34
cx::OptionalValue::OptionalValue
OptionalValue(T val)
Definition: cxOptionalValue.h:30