softwarecontainer  0.18.0-739e8d7 2017-05-04
configitem.cpp
1 
2 /*
3  * Copyright (C) 2016-2017 Pelagicore AB
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
12  * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
13  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
14  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
15  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16  * SOFTWARE.
17  *
18  * For further information see LICENSE
19  */
20 
21 #include "softwarecontainer-common.h"
22 #include "configitem.h"
23 
24 
25 namespace softwarecontainer {
26 
31 ConfigItem::ConfigItem(const std::string &group, const std::string &name):
32  m_group(group),
33  m_name(name)
34 {
35 }
36 
37 std::string ConfigItem::key() const
38 {
39  return m_name;
40 }
41 
42 std::string ConfigItem::group() const
43 {
44  return m_group;
45 }
46 
47 void ConfigItem::setSource(ConfigSourceType type)
48 {
49  m_source = type;
50 }
51 
52 ConfigSourceType ConfigItem::source() const
53 {
54  return m_source;
55 }
56 
57 
62 StringConfig::StringConfig(const std::string &group, const std::string &name, std::string value):
63  ConfigItem(group, name),
64  m_value(value)
65 {
66 }
67 
68 std::string StringConfig::value()
69 {
70  return m_value;
71 }
72 
73 
78 IntConfig::IntConfig(const std::string &group, const std::string &name, int value):
79  ConfigItem(group, name),
80  m_value(value)
81 {
82 }
83 
84 int IntConfig::value()
85 {
86  return m_value;
87 }
88 
89 
94 BoolConfig::BoolConfig(const std::string &group, const std::string &name, bool value):
95  ConfigItem(group, name),
96  m_value(value)
97 {
98 }
99 
100 bool BoolConfig::value()
101 {
102  return m_value;
103 }
104 
105 } // namespace softwarecontainer
Developers guide to adding a config item: