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