softwarecontainer  0.18.0-739e8d7 2017-05-04
configloader.h
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 
22 #pragma once
23 
24 
25 namespace softwarecontainer {
26 
27 /*
28  * Abstract interface to a concrete loader.
29  *
30  * The concrete loader will either be a production loader that loads a config
31  * from a file on the system, or a test loader that loads a config from a string.
32  */
34 {
35 public:
36  // Enforce inheriting classes to initialize config source member
37  ConfigLoader() = delete;
38  ConfigLoader(const std::string &source) : m_source(source) {}
39 
40  virtual ~ConfigLoader() {}
41 
42  virtual std::unique_ptr<Glib::KeyFile> loadConfig() = 0;
43 
44 protected:
45  // A string with the source of the config, e.g. a path or config string.
46  std::string m_source;
47 };
48 
49 } // namespace softwarecontainer
Developers guide to adding a config item: