libqipackage  2.8.7.4
 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 <map>
16 #include <qipackage/api.hpp>
17 #include <alvalue/alvalue.h>
18 #include <qipackage/language_info.hpp>
19 #include <qipackage/behavior_info.hpp>
20 #include <qipackage/dialog_info.hpp>
21 #include <qi/macro.hpp>
22 #include <qi/anyobject.hpp>
23 #include <qi/type/typeinterface.hpp>
24 #include <QFile>
25 
26 namespace qi
27 {
28  class PackageInfoPrivate;
29 
30  struct WebInfo;
31 
35  struct QI_PACKAGE_API PackageInfo2
36  {
37  std::string uuid;
38  std::string version;
39  std::string author;
40  std::string channel;
41  std::string organization;
42  std::string date;
43  std::string typeVersion;
44  std::string installer;
46  std::string path;
47 
62  std::map<std::string, qi::AnyValue> elems;
63 
64  std::map<std::string, qi::AnyValue> contents() const;
65  std::map<std::string, qi::AnyValue>& contents();
66 
67  std::vector<qi::BehaviorInfo> behaviors() const;
68  std::vector<qi::BehaviorInfo>& behaviors();
69 
70  std::vector<qi::DialogInfo> dialogs() const;
71  std::vector<qi::DialogInfo>& dialogs();
72 
73  std::vector<qi::LanguageInfo> languages() const;
74  std::vector<qi::LanguageInfo>& languages();
75 
76  qi::WebInfo web() const;
77  qi::WebInfo& web();
78  };
79 
83  QI_PACKAGE_API qi::PackageInfo2 loadManifest(const std::string& manifestPath);
84 
85 
89  struct QI_PACKAGE_API RobotRequirement
90  {
91  std::string model;
92  std::string minHeadVersion;
93  std::string maxHeadVersion;
94  std::string minBodyVersion;
95  std::string maxBodyVersion;
96  };
97 
101  struct QI_PACKAGE_API NaoqiRequirement
102  {
103  std::string minVersion;
104  std::string maxVersion;
105  };
106 
110  struct QI_PACKAGE_API PackageService
111  {
112  std::string execStart;
113  std::string name;
114  bool autoRun;
115  std::map<std::string, std::string> envVars;
116  };
117 
121  struct QI_PACKAGE_API WebInfo
122  {
123  std::string path;
124  };
125 
131  class QI_PACKAGE_API PackageInfo
132  {
133  public:
134  PackageInfo();
135 
136  PackageInfo(const PackageInfo &package);
137  PackageInfo(const PackageInfo2 &package);
138  ~PackageInfo();
139 
140  PackageInfo operator=(const PackageInfo& package);
141 
142  /* For serialization purpose */
143  PackageInfo(const AL::ALValue& alvalue);
144  void toALValue(AL::ALValue &alvalue);
145 
146  bool loadFromManifestFile(const std::string& filePath);
147  bool loadFromManifestFile(QFile &file);
148  bool loadFromManifestContent(const std::string& manifestContent);
149 
152  void trimExtraInfo();
153 
154  bool saveToManifestFile(const std::string& filePath) const;
155  bool saveToManifestFile(QFile &file) const;
156  std::string saveToManifestContent() const;
157 
158  const std::string& installer() const;
159  void setInstaller(const std::string &installer);
160 
161  const std::string& uuid() const;
162  void setUuid(const std::string &uuid);
163 
164  const std::string& version() const;
165  void setVersion(const std::string &version);
166 
167  const bool& installOnlyAtStartup() const;
168  void setInstallOnlyAtStartup(const bool &installOnlyAtStartup);
169 
170  const std::string& typeVersion() const;
171  void setTypeVersion(const std::string &typeVersion);
172 
173  const std::string& author() const;
174  void setAuthor(const std::string &author);
175 
176  const std::string& organization() const;
177  void setOrganization(const std::string &organization);
178 
179  const std::string& date() const;
180  void setDate(const std::string &date);
181 
182  const std::string& channel() const;
183  void setChannel(const std::string &channel);
184 
185  const std::string& path() const;
186  void setPath(const std::string &path);
187 
188  const std::string& name(const std::string &lang) const;
189  const std::map<std::string, std::string> &names() const;
190  void setName(const std::string &name,
191  const std::string &lang);
192  void clearNames();
193 
194  const std::list<std::string>& supportedLanguages() const;
195  void addSupportedLanguage(const std::string & language);
196  void removeSupportedLanguage(const std::string & language);
197  void clearSupportedLanguages();
198 
199  const std::list<std::string>& descriptionLanguages() const;
200  void addDescriptionLanguage(const std::string & language);
201  void removeDescriptionLanguage(const std::string & language);
202  void clearDescriptionLanguages();
203 
204  const std::string& description(const std::string &lang) const;
205  const std::map<std::string, std::string> &descriptions() const;
206  void setDescription(const std::string description,
207  const std::string &lang);
208 
209  std::list<RobotRequirement>& robotRequirements() const;
210  void addRobotRequirement(const RobotRequirement& requirement);
211  void clearRobotRequirements();
212 
213  std::list<NaoqiRequirement>& naoqiRequirements() const;
214  void addNaoqiRequirement(const NaoqiRequirement& requirement);
215  void clearNaoqiRequirements();
216 
217  std::list<BehaviorInfo> & behaviors();
218  const std::list<BehaviorInfo>& behaviors() const;
219  void addBehavior(const BehaviorInfo& behavior);
220  bool hasBehavior() const;
221  void clearBehaviors();
222 
223  const std::list<DialogInfo>& dialogs() const;
224  void addDialog(const DialogInfo& dialog);
225  void clearDialogs();
226 
227  const std::list<LanguageInfo>& languages() const;
228  void addLanguage(const LanguageInfo& language);
229 
230  const std::list<PackageService> &services() const;
231  void addService(const PackageService &service);
232  void clearServices();
233 
234  const std::list<std::string> &executableFiles() const;
235  void addExecutableFile(const std::string &executableFile);
236 
237  PackageInfoPrivate *_p;
238  };
239 
240  typedef std::vector<PackageInfo> PackageInfoList;
241 
242  QI_PACKAGE_API std::ostream& operator<<(std::ostream& os,
243  const PackageInfo& package);
244 }
245 
246 
247 QI_TYPE_STRUCT(::qi::RobotRequirement, model, minHeadVersion, maxHeadVersion, minBodyVersion, maxBodyVersion);
248 QI_TYPE_STRUCT(::qi::NaoqiRequirement, minVersion, maxVersion);
249 QI_TYPE_STRUCT(::qi::PackageService, execStart, name, autoRun, envVars);
251 QI_TYPE_STRUCT(::qi::PackageInfo2, uuid, version, author, channel, organization, date, typeVersion, installer, path, elems, installOnlyAtStartup);
252 QI_TYPE_STRUCT(::qi::WebInfo, path);
253 
254 #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.
QI_TYPE_STRUCT_EXTENSION_ADDED_FIELDS(::qi::PackageInfo2,"installOnlyAtStartup")
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
bool installOnlyAtStartup
Install only at Startup.
std::vector< PackageInfo > PackageInfoList
std::string typeVersion
Type version.
std::map< std::string, std::string > envVars
The specific environement variables.
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.