Open Lighting Architecture
Latest Git
include
ola
web
OptionalItem.h
1
/*
2
* This library is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU Lesser General Public
4
* License as published by the Free Software Foundation; either
5
* version 2.1 of the License, or (at your option) any later version.
6
*
7
* This library is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
* Lesser General Public License for more details.
11
*
12
* You should have received a copy of the GNU Lesser General Public
13
* License along with this library; if not, write to the Free Software
14
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
*
16
* OptionalItem.h
17
* A value which may or may not be present.
18
* Copyright (C) 2014 Simon Newton
19
*/
20
21
#ifndef INCLUDE_OLA_WEB_OPTIONALITEM_H_
22
#define INCLUDE_OLA_WEB_OPTIONALITEM_H_
23
24
#include <
ola/base/Macro.h
>
25
#include <string>
26
27
namespace
ola
{
28
namespace
web {
29
30
template
<
typename
T>
31
class
OptionalItem
{
32
public
:
33
OptionalItem
();
34
35
void
Reset() { m_is_set =
false
; }
36
37
void
Set(
const
T &value) {
38
m_is_set =
true
;
39
m_value = value;
40
}
41
42
bool
IsSet()
const
{
return
m_is_set; }
43
const
T& Value()
const
{
return
m_value; }
44
45
private
:
46
bool
m_is_set;
47
T m_value;
48
49
DISALLOW_COPY_AND_ASSIGN(
OptionalItem
);
50
};
51
52
template
<>
53
inline
OptionalItem<std::string>::OptionalItem
()
54
: m_is_set(
false
) {
55
}
56
57
template
<
typename
T>
58
OptionalItem<T>::OptionalItem
()
59
: m_is_set(
false
),
60
m_value(0) {
61
}
62
63
64
}
// namespace web
65
}
// namespace ola
66
#endif // INCLUDE_OLA_WEB_OPTIONALITEM_H_
ola::web::OptionalItem
Definition:
OptionalItem.h:31
Macro.h
Helper macros.
ola
The namespace containing all OLA symbols.
Definition:
Credentials.cpp:44
Generated on Mon Jan 2 2023 23:40:35 for Open Lighting Architecture by
1.8.13