LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PackageDescription.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef PACKAGEDESCRIPTION_H
23 #define PACKAGEDESCRIPTION_H
24 
25 #include <string>
26 #include <stdint.h>
27 #include <vector>
28 #include <cjson/json.h>
29 
30 struct json_object;
31 
33 
35 {
36 public:
37 
40 
41  static PackageDescription* fromFile(const std::string& filePath, const std::string& folderPath);
42  static PackageDescription* fromJson(json_object* root, const std::string& folderPath);
44 
45  const std::string& id() const { return m_id; }
46  const std::string& version() const { return m_version; }
47  const std::string& folderPath() const { return m_folderPath; }
48  uint64_t packageSize() const {return m_packageSize;}
49  void setPackageSize(uint64_t s) { m_packageSize = s;}
50  uint32_t blockSize() const { return m_fsBlockSize; }
51  void setBlockSize(uint32_t s) { m_fsBlockSize = s;}
52  bool isOldStyle() const { return m_isOldStyle; }
53  const std::vector<std::string>& appIds() const { return m_appIds; }
54  const std::vector<std::string>& serviceIds() const { return m_serviceIds; }
55  const std::vector<std::string>& accountIds() const { return m_accountIds; }
56  const std::string& jsonString() const { return m_jsonString; }
57 
58  // NOTE: it is the callers responsibility to json_object_put the return value
59  json_object* toJSON() const;
60 
61  bool operator==(const PackageDescription& cmp) const;
62  bool operator!=(const PackageDescription& cmp) const;
63 
64 private:
65 
66  std::string m_id;
67  std::string m_version;
68  std::string m_folderPath;
69  uint64_t m_packageSize;
70  uint32_t m_fsBlockSize;
71  bool m_isOldStyle;
72  std::vector<std::string> m_appIds;
73  std::vector<std::string> m_serviceIds;
74  std::vector<std::string> m_accountIds;
75  std::string m_jsonString;
76 };
77 
78 
79 #endif /* PACKAGEDESCRIPTION_H */