softwarecontainer  0.18.0-739e8d7 2017-05-04
defaultconfigsource.cpp
1 
2 /*
3  * Copyright (C) 2016 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 
22 #include "softwarecontainer-common.h"
23 #include "config.h"
24 #include "configdefinition.h"
25 #include "defaultconfigsource.h"
26 
27 
28 namespace softwarecontainer {
29 
30 DefaultConfigSource::DefaultConfigSource():
31  m_stringConfigs(std::vector<StringConfig>()),
32  m_intConfigs(std::vector<IntConfig>()),
33  m_boolConfigs(std::vector<BoolConfig>())
34 {
35  log_debug() << "Initializing config defaults source";
36 
37  /*
38  * Add all values defined by the build system
39  */
40 
41  StringConfig stringConfig = StringConfig(ConfigDefinition::SC_GROUP,
42  ConfigDefinition::SC_SHARED_MOUNTS_DIR_KEY,
43  SC_SHARED_MOUNTS_DIR);
44  stringConfig.setSource(ConfigSourceType::Default);
45  m_stringConfigs.push_back(stringConfig);
46 
47  stringConfig = StringConfig(ConfigDefinition::SC_GROUP,
48  ConfigDefinition::SC_LXC_CONFIG_PATH_KEY,
49  SC_LXC_CONFIG_PATH);
50  stringConfig.setSource(ConfigSourceType::Default);
51  m_stringConfigs.push_back(stringConfig);
52 
53  stringConfig = StringConfig(ConfigDefinition::SC_GROUP,
54  ConfigDefinition::SC_SERVICE_MANIFEST_DIR_KEY,
55  SC_SERVICE_MANIFEST_DIR);
56  stringConfig.setSource(ConfigSourceType::Default);
57  m_stringConfigs.push_back(stringConfig);
58 
59  stringConfig = StringConfig(ConfigDefinition::SC_GROUP,
60  ConfigDefinition::SC_DEFAULT_SERVICE_MANIFEST_DIR_KEY,
61  SC_DEFAULT_SERVICE_MANIFEST_DIR);
62  stringConfig.setSource(ConfigSourceType::Default);
63  m_stringConfigs.push_back(stringConfig);
64 
65  IntConfig intConfig = IntConfig(ConfigDefinition::SC_GROUP,
66  ConfigDefinition::SC_SHUTDOWN_TIMEOUT_KEY,
67  SC_SHUTDOWN_TIMEOUT);
68  intConfig.setSource(ConfigSourceType::Default);
69  m_intConfigs.push_back(intConfig);
70 
71  BoolConfig boolConfig = BoolConfig(ConfigDefinition::SC_GROUP,
72  ConfigDefinition::SC_USE_SESSION_BUS_KEY,
73  SC_USE_SESSION_BUS);
74  boolConfig.setSource(ConfigSourceType::Default);
75  m_boolConfigs.push_back(boolConfig);
76 }
77 
78 std::vector<StringConfig> DefaultConfigSource::stringConfigs()
79 {
80  return m_stringConfigs;
81 }
82 
83 std::vector<IntConfig> DefaultConfigSource::intConfigs()
84 {
85  return m_intConfigs;
86 }
87 
88 std::vector<BoolConfig> DefaultConfigSource::boolConfigs()
89 {
90  return m_boolConfigs;
91 }
92 
93 } // namespace softwarecontainer
Developers guide to adding a config item: