libqipackage  release-2.5.3-2016-11-18
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
package_info.hpp
Go to the documentation of this file.
1 /*
2 ** Author(s):
3 ** - Laurent Lec <llec@aldebaran-robotics.com>
4 ** - Clément Geiger <cgeiger@aldebaran-robotics.com>
5 **
6 ** Copyright (C) 2012-2015 Aldebaran Robotics
7 */
8 
9 #pragma once
10 #ifndef _QI_PACKAGE_PACKAGE_INFO_HPP_
11 #define _QI_PACKAGE_PACKAGE_INFO_HPP_
12 
13 #include <string>
14 #include <list>
15 #include <qipackage/api.hpp>
16 #include <alvalue/alvalue.h>
17 #include <qipackage/language_info.hpp>
18 #include <qipackage/behavior_info.hpp>
19 #include <qipackage/dialog_info.hpp>
20 #include <qi/macro.hpp>
21 #include <qi/anyobject.hpp>
22 #include <qi/type/typeinterface.hpp>
23 #include <QFile>
24 
25 namespace qi
26 {
27  class PackageInfoPrivate;
28 
29  struct WebInfo;
30 
34  struct QI_PACKAGE_API PackageInfo2
35  {
36  std::string uuid;
37  std::string version;
38  std::string author;
39  std::string channel;
40  std::string organization;
41  std::string date;
42  std::string typeVersion;
43  std::string installer;
44  std::string path;
45 
60  std::map<std::string, qi::AnyValue> elems;
61 
62  std::map<std::string, qi::AnyValue> contents() const;
63  std::map<std::string, qi::AnyValue>& contents();
64 
65  std::vector<qi::BehaviorInfo> behaviors() const;
66  std::vector<qi::BehaviorInfo>& behaviors();
67 
68  std::vector<qi::DialogInfo> dialogs() const;
69  std::vector<qi::DialogInfo>& dialogs();
70 
71  std::vector<qi::LanguageInfo> languages() const;
72  std::vector<qi::LanguageInfo>& languages();
73 
74  qi::WebInfo web() const;
75  qi::WebInfo& web();
76  };
77 
81  QI_PACKAGE_API qi::PackageInfo2 loadManifest(const std::string& manifestPath);
82 
83 
87  struct QI_PACKAGE_API RobotRequirement
88  {
89  std::string model;
90  std::string minHeadVersion;
91  std::string maxHeadVersion;
92  std::string minBodyVersion;
93  std::string maxBodyVersion;
94  };
95 
99  struct QI_PACKAGE_API NaoqiRequirement
100  {
101  std::string minVersion;
102  std::string maxVersion;
103  };
104 
108  struct QI_PACKAGE_API PackageService
109  {
110  std::string execStart;
111  std::string name;
112  bool autoRun;
113  };
114 
118  struct QI_PACKAGE_API WebInfo
119  {
120  std::string path;
121  };
122 
128  class QI_PACKAGE_API PackageInfo
129  {
130  public:
131  PackageInfo();
132 
133  PackageInfo(const PackageInfo &package);
134  PackageInfo(const PackageInfo2 &package);
135  ~PackageInfo();
136 
137  PackageInfo operator=(const PackageInfo& package);
138 
139  /* For serialization purpose */
140  PackageInfo(const AL::ALValue& alvalue);
141  void toALValue(AL::ALValue &alvalue);
142 
143  bool loadFromManifestFile(const std::string& filePath);
144  bool loadFromManifestFile(QFile &file);
145  bool loadFromManifestContent(const std::string& manifestContent);
146 
149  void trimExtraInfo();
150 
151  bool saveToManifestFile(const std::string& filePath) const;
152  bool saveToManifestFile(QFile &file) const;
153  std::string saveToManifestContent() const;
154 
155  const std::string& installer() const;
156  void setInstaller(const std::string &installer);
157 
158  const std::string& uuid() const;
159  void setUuid(const std::string &uuid);
160 
161  const std::string& version() const;
162  void setVersion(const std::string &version);
163 
164  const std::string& typeVersion() const;
165  void setTypeVersion(const std::string &typeVersion);
166 
167  const std::string& author() const;
168  void setAuthor(const std::string &author);
169 
170  const std::string& organization() const;
171  void setOrganization(const std::string &organization);
172 
173  const std::string& date() const;
174  void setDate(const std::string &date);
175 
176  const std::string& channel() const;
177  void setChannel(const std::string &channel);
178 
179  const std::string& path() const;
180  void setPath(const std::string &path);
181 
182  const std::string& name(const std::string &lang) const;
183  const std::map<std::string, std::string> &names() const;
184  void setName(const std::string &name,
185  const std::string &lang);
186  void clearNames();
187 
188  const std::list<std::string>& supportedLanguages() const;
189  void addSupportedLanguage(const std::string & language);
190  void removeSupportedLanguage(const std::string & language);
191  void clearSupportedLanguages();
192 
193  const std::list<std::string>& descriptionLanguages() const;
194  void addDescriptionLanguage(const std::string & language);
195  void removeDescriptionLanguage(const std::string & language);
196  void clearDescriptionLanguages();
197 
198  const std::string& description(const std::string &lang) const;
199  const std::map<std::string, std::string> &descriptions() const;
200  void setDescription(const std::string description,
201  const std::string &lang);
202 
203  std::list<RobotRequirement>& robotRequirements() const;
204  void addRobotRequirement(const RobotRequirement& requirement);
205  void clearRobotRequirements();
206 
207  std::list<NaoqiRequirement>& naoqiRequirements() const;
208  void addNaoqiRequirement(const NaoqiRequirement& requirement);
209  void clearNaoqiRequirements();
210 
211  std::list<BehaviorInfo> & behaviors();
212  const std::list<BehaviorInfo>& behaviors() const;
213  void addBehavior(const BehaviorInfo& behavior);
214  bool hasBehavior() const;
215  void clearBehaviors();
216 
217  const std::list<DialogInfo>& dialogs() const;
218  void addDialog(const DialogInfo& dialog);
219  void clearDialogs();
220 
221  const std::list<LanguageInfo>& languages() const;
222  void addLanguage(const LanguageInfo& language);
223 
224  const std::list<PackageService> &services() const;
225  void addService(const PackageService &service);
226  void clearServices();
227 
228  const std::list<std::string> &executableFiles() const;
229  void addExecutableFile(const std::string &executableFile);
230 
231  PackageInfoPrivate *_p;
232  };
233 
234  typedef std::vector<PackageInfo> PackageInfoList;
235 
236  QI_PACKAGE_API std::ostream& operator<<(std::ostream& os,
237  const PackageInfo& package);
238 }
239 
240 
241 QI_TYPE_STRUCT(::qi::RobotRequirement, model, minHeadVersion, maxHeadVersion, minBodyVersion, maxBodyVersion);
242 QI_TYPE_STRUCT(::qi::NaoqiRequirement, minVersion, maxVersion);
243 QI_TYPE_STRUCT(::qi::PackageService, execStart, name, autoRun);
244 QI_TYPE_STRUCT(::qi::PackageInfo2, uuid, version, author, channel, organization, date, typeVersion, installer, path, elems);
245 QI_TYPE_STRUCT(::qi::WebInfo, path);
246 
247 #endif // _QI_PACKAGE_PACKAGE_INFO_HPP_
QI_PACKAGE_API qi::PackageInfo2 loadManifest(const std::string &manifestPath)
Returns a qi::PackageInfo2 from a manifest path.
std::string minBodyVersion
The minimum version for the body to be compatible with this package.
This structure defines robot requirements for this package.
std::string maxBodyVersion
The maximum version for the body to be compatible with this package.
std::string minHeadVersion
The minimum needed version for the head to be compatible with this package.
A dynamic struct for managing packages information.
std::string installer
Source of the package.
QI_TYPE_STRUCT(::qi::RobotRequirement, model, minHeadVersion, maxHeadVersion, minBodyVersion, maxBodyVersion)
Structure matching a service.
std::string path
The path to web pages.
A structure defining web pages location.
std::string maxVersion
The maximum version of naoqi compatible with this package.
std::string minVersion
The minimum version of naoqi compatible with this package.
Requirement on naoqi version.
std::string uuid
Unique ID to identify the package.
std::string version
Version of the package.
std::string model
Model of the robot (ROBOT_TYPE_NAO, ROBOT_TYPE_JULIETTE, ROBOT_TYPE_ROMEO, ...)
std::string path
Path to the files. Should not be used.
std::string date
Data of the package.
std::string organization
Organization.
std::string maxHeadVersion
The maximum version of the head to be compatible with this package.
std::string author
Author of the package.
bool autoRun
If this service should be started automatically at start-up.
std::string name
The name of the service.
std::map< std::string, qi::AnyValue > elems
PackageInfoPrivate * _p
std::vector< PackageInfo > PackageInfoList
std::string typeVersion
Type version.
QI_PACKAGE_API std::ostream & operator<<(std::ostream &os, const PackageInfo &package)
A class that represents a package.
std::string channel
Channel.
std::string execStart
The command line with arguments.