Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
provision-config.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License version 2.1 as published by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  */
17 
24 #ifndef LXCPP_PROVISION_CONFIG_HPP
25 #define LXCPP_PROVISION_CONFIG_HPP
26 
27 #include "config.hpp"
28 #include "cargo/fields.hpp"
29 #include "cargo/fields-union.hpp"
30 
31 #include <vector>
32 #include <string>
33 #include <string.h>
34 
35 namespace lxcpp {
36 namespace provision {
37 
38 typedef std::string ProvisionID;
39 
43 struct File
44 {
45  enum class Type : int
46  {
47  DIRECTORY,
48  FIFO,
49  REGULAR
50  };
51 
53  {
54  return "file " +
55  path + " " +
56  std::to_string(static_cast<int>(type)) + " " +
57  std::to_string(flags) + " " +
58  std::to_string(mode);
59  }
60 
62  std::string path;
63  std::int32_t flags;
64  std::int32_t mode;
65 
67  (
68  type,
69  path,
70  flags,
71  mode
72  )
73 
74  bool operator==(const File& m) const
75  {
76  return ((m.type == type) && (m.path == path) &&
77  (m.flags == flags) && (m.mode == mode));
78  }
79 };
80 
81 struct Mount
82 {
84  {
85  return "mount " +
86  source + " " +
87  target + " " +
88  type + " " +
89  std::to_string(flags) + " " +
90  data;
91  }
92 
93  std::string source;
94  std::string target;
95  std::string type;
96  std::int64_t flags;
97  std::string data;
98 
100  (
101  source,
102  target,
103  type,
104  flags,
105  data
106  )
107 
108  bool operator==(const Mount& m) const
109  {
110  return ((m.source == source) && (m.target == target) && (m.type == type) &&
111  (m.flags == flags) && (m.data == data));
112  }
113 };
114 
115 struct Link
116 {
118  {
119  return "link " + source + " " + target;
120  }
121 
122  std::string source;
123  std::string target;
124 
126  (
127  source,
128  target
129  )
130 
131  bool operator==(const Link& m) const
132  {
133  return ((m.source == source) && (m.target == target));
134  }
135 };
136 } // namespace provision
137 
138 typedef std::vector<provision::File> FileVector;
139 typedef std::vector<provision::Mount> MountVector;
140 typedef std::vector<provision::Link> LinkVector;
141 
143 {
147 
148  void addFile(const provision::File& newFile);
149  const FileVector& getFiles() const;
150  void removeFile(const provision::File& item);
151 
152  void addMount(const provision::Mount& newMount);
153  const MountVector& getMounts() const;
154  void removeMount(const provision::Mount& item);
155 
156  void addLink(const provision::Link& newLink);
157  const LinkVector& getLinks() const;
158  void removeLink(const provision::Link& item);
159 
161  (
162  files,
163  mounts,
164  links
165  )
166 };
167 
168 } // namespace lxcpp
169 
170 #endif // LXCPP_PROVISION_CONFIG_HPP
Type type
Definition: provision-config.hpp:61
std::string source
Definition: provision-config.hpp:93
MountVector mounts
Definition: provision-config.hpp:145
std::string target
Definition: provision-config.hpp:94
std::string data
Definition: provision-config.hpp:97
const FileVector & getFiles() const
Definition: provision-config.cpp:43
std::int32_t flags
Definition: provision-config.hpp:63
void removeLink(const provision::Link &item)
Definition: provision-config.cpp:106
Provision configuration items.
Definition: provision-config.hpp:43
const MountVector & getMounts() const
Definition: provision-config.cpp:72
Type
Definition: provision-config.hpp:45
void removeMount(const provision::Mount &item)
Definition: provision-config.cpp:77
std::int64_t flags
Definition: provision-config.hpp:96
std::int32_t mode
Definition: provision-config.hpp:64
ProvisionID getId() const
Definition: provision-config.hpp:52
Configuration file for the code.
std::vector< provision::Mount > MountVector
Definition: provision-config.hpp:139
Definition: provision-config.hpp:81
const LinkVector & getLinks() const
Definition: provision-config.cpp:101
FileVector files
Definition: provision-config.hpp:144
ProvisionID getId() const
Definition: provision-config.hpp:83
void removeFile(const provision::File &item)
Definition: provision-config.cpp:48
LinkVector links
Definition: provision-config.hpp:146
std::vector< provision::File > FileVector
Definition: provision-config.hpp:138
#define CARGO_REGISTER(...)
Registers cargo fields within class.
Definition: fields.hpp:74
void addMount(const provision::Mount &newMount)
Definition: provision-config.cpp:60
std::string type
Definition: provision-config.hpp:95
Macros for declare cargo fields.
Definition: provision-config.hpp:142
void addFile(const provision::File &newFile)
Definition: provision-config.cpp:31
std::string ProvisionID
Definition: provision-config.hpp:38
std::string path
Definition: provision-config.hpp:62
std::vector< provision::Link > LinkVector
Definition: provision-config.hpp:140
void addLink(const provision::Link &newLink)
Definition: provision-config.cpp:89