00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROSPACK_ROSPACK_H
00029 #define ROSPACK_ROSPACK_H
00030
00031
00032
00135 #if defined(WIN32)
00136 #if defined(ROS_STATIC)
00137 #define ROSPACK_EXPORT
00138 #elif defined(rospack_EXPORTS)
00139 #define ROSPACK_EXPORT __declspec(dllexport)
00140 #else
00141 #define ROSPACK_EXPORT __declspec(dllimport)
00142 #endif
00143 #else
00144 #define ROSPACK_EXPORT
00145 #endif
00146
00147 #include <string>
00148 #include <vector>
00149 #include <list>
00150
00151 #include "tinyxml-2.5.3/tinyxml.h"
00152
00153 namespace rospack
00154 {
00155
00156 class Package;
00157
00158 void string_split(const std::string &s, std::vector<std::string> &t, const std::string &d);
00159 bool file_exists(const std::string &fname);
00160 extern const char *fs_delim;
00161 Package *g_get_pkg(const std::string &name);
00162
00163 typedef std::vector<Package *> VecPkg;
00164 typedef std::list<Package*> Acc;
00165 typedef std::list<Acc> AccList;
00166
00170 class ROSPACK_EXPORT Package
00171 {
00172 public:
00173 enum traversal_order_t { POSTORDER, PREORDER };
00174 std::string name, path;
00175
00176
00177
00178
00179
00180 static std::vector<Package *> pkgs;
00181 static std::vector<Package *> deleted_pkgs;
00182
00183 Package(std::string _path);
00184 static bool is_package(std::string path);
00185 static bool is_no_subdirs(std::string path);
00186 const VecPkg &deps1();
00187 const VecPkg &deps(traversal_order_t order, int depth=0);
00188 std::string manifest_path();
00189 std::string flags(std::string lang, std::string attrib);
00190 std::string rosdep();
00191 std::string versioncontrol();
00192 std::vector<std::pair<std::string, std::string> > plugins();
00193 VecPkg descendants1();
00194 const std::vector<Package *> &descendants(int depth=0);
00195 rospack_tinyxml::TiXmlElement *manifest_root();
00196 void accumulate_deps(AccList& acc_list, Package* to);
00197
00204 std::string cpp_message_flags(bool cflags, bool lflags);
00205
00206
00207 private:
00208 bool deps_calculated, direct_deps_calculated, descendants_calculated;
00209 std::vector<Package *> _deps, _direct_deps, _descendants;
00210 rospack_tinyxml::TiXmlDocument manifest;
00211 bool manifest_loaded;
00212
00213 Package(const Package &p) { }
00214
00215 bool has_parent(std::string pkg);
00216 const std::vector<Package *> &direct_deps(bool missing_pkg_as_warning=false);
00217 std::string direct_flags(std::string lang, std::string attrib);
00218 void load_manifest();
00219 };
00220
00225 class ROSPACK_EXPORT ROSPack
00226 {
00227 public:
00228 static const char* usage();
00229
00230 char *ros_root;
00231
00232 ROSPack();
00233
00234 ~ROSPack();
00235
00236 Package *get_pkg(std::string pkgname);
00237
00238 int cmd_depends_on(bool include_indirect);
00239
00240 int cmd_depends_why();
00241
00242 int cmd_find();
00243
00244 int cmd_deps();
00245
00246 int cmd_depsindent(Package* pkg, int indent);
00247
00248 int cmd_deps_manifests();
00249 int cmd_deps_msgsrv();
00250
00251 int cmd_deps1();
00252
00253
00254
00255
00256
00257 std::string snarf_libs(std::string flags, bool invert=false);
00258 std::string snarf_flags(std::string flags, std::string token, bool invert=false);
00259
00260 int cmd_libs_only(std::string token);
00261
00262 int cmd_cflags_only(std::string token);
00263
00264 int cmd_make(char **args, int args_len);
00265
00266 void export_flags(std::string pkg, std::string lang, std::string attrib);
00267
00268 int cmd_versioncontrol(int depth);
00269
00270 int cmd_rosdep(int depth);
00271
00272 int cmd_export();
00273
00274 int cmd_plugins();
00275
00283 int run(int argc, char **argv);
00284
00285
00286
00287 int run(const std::string& cmd);
00288
00289
00290 std::string getOutput() { return output_acc; }
00291
00292
00293 bool is_quiet() { return opt_quiet; }
00294
00295 int cmd_print_package_list(bool print_path);
00296
00297 int cmd_list_duplicates();
00298
00299 int cmd_print_langs_list();
00300
00301 void crawl_for_packages(bool force_crawl = false);
00302 VecPkg partial_crawl(const std::string &path);
00303
00304
00305 std::string deduplicate_tokens(const std::string& s);
00306
00307
00308
00309 bool opt_deps_only;
00310
00311 std::string opt_lang;
00312
00313 std::string opt_attrib;
00314
00315 std::string opt_length;
00316
00317 std::string opt_top;
00318
00319 std::string opt_package;
00320
00321 std::string opt_target;
00322
00323 int opt_profile_length;
00324
00325 bool opt_profile_zombie_only;
00326
00327 bool opt_warn_on_missing_deps;
00328
00329 bool opt_display_duplicate_pkgs;
00330
00331 private:
00332
00333 bool opt_quiet;
00334 bool cache_lock_failed;
00335 bool crawled;
00336 std::string getCachePath();
00337
00338
00339 std::vector<std::string> path_components;
00340
00341 Package* add_package(std::string path);
00343 bool cache_is_good();
00345 static double time_since_epoch();
00347 void sanitize_rppvec(std::vector<std::string> &rppvec);
00348
00349 std::string output_acc;
00350
00351
00352 int my_argc;
00353 char** my_argv;
00354 void freeArgv();
00355
00356
00357 int total_num_pkgs;
00358
00359 bool duplicate_packages_found;
00360 };
00361
00362 }
00363
00364 #endif