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 ROSSTACK_ROSSTACK_H
00029 #define ROSSTACK_ROSSTACK_H
00030
00031
00032
00043 #if defined(WIN32)
00044 #if defined(ROS_STATIC)
00045 #define ROSSTACK_EXPORT
00046 #elif defined(rosstack_EXPORTS)
00047 #define ROSSTACK_EXPORT __declspec(dllexport)
00048 #else
00049 #define ROSSTACK_EXPORT __declspec(dllimport)
00050 #endif
00051 #else
00052 #define ROSSTACK_EXPORT
00053 #endif
00054
00055 #include <string>
00056 #include <vector>
00057
00058 #include "tinyxml-2.5.3/tinyxml.h"
00059 #include "rospack/rospack.h"
00060
00061 namespace rosstack
00062 {
00063
00064 class ROSSTACK_EXPORT Stack;
00065
00066 void string_split(const std::string &s, std::vector<std::string> &t, const std::string &d);
00067 bool file_exists(const std::string &fname);
00068 extern const char *fs_delim;
00069 extern const char *path_delim;
00070 Stack *g_get_stack(const std::string &name);
00071 typedef std::vector<Stack *> VecStack;
00072
00076 class ROSSTACK_EXPORT Stack
00077 {
00078 public:
00079 enum traversal_order_t { POSTORDER, PREORDER };
00080 std::string name, path;
00081 static std::vector<Stack *> stacks;
00082
00083 Stack(std::string _path);
00084 static bool is_stack(const std::string &path);
00085 static bool is_package(const std::string &path);
00086 static bool is_no_subdirs(const std::string &path);
00087 const VecStack &deps1();
00088 const VecStack &deps(traversal_order_t order, int depth=0);
00089 std::string manifest_path();
00090 VecStack descendants1();
00091 const VecStack &descendants(int depth=0);
00092 TiXmlElement *manifest_root();
00093
00094 private:
00095 bool deps_calculated, direct_deps_calculated, descendants_calculated;
00096 VecStack _deps, _direct_deps, _descendants;
00097 TiXmlDocument manifest;
00098 bool manifest_loaded;
00099
00100 Stack(const Stack &p) { }
00101
00102 bool has_parent(std::string stk);
00103 const VecStack &direct_deps(bool missing_pkg_as_warning=false);
00104 void load_manifest();
00105 };
00106
00111 class ROSSTACK_EXPORT ROSStack
00112 {
00113 public:
00114 static const char* usage();
00115 char *ros_root;
00116 rospack::ROSPack rp;
00117
00118 ROSStack();
00119 ~ROSStack();
00120 Stack *get_stack(const std::string &name);
00121 int cmd_depends_on(bool include_indirect);
00122 int cmd_find();
00123 int cmd_contains();
00124 int cmd_contains_path();
00125 int cmd_deps();
00126 int cmd_depsindent(Stack* stk, int indent);
00127 int cmd_deps_manifests();
00128 int cmd_deps1();
00129
00137 int run(int argc, char **argv);
00138
00139 int cmd_print_stack_list(bool print_path);
00140 int cmd_print_packages();
00141
00142 void crawl_for_stacks(bool force_crawl = false);
00143 std::string lookup_owner(std::string pkg_name, bool just_owner_name);
00144 void deleteCache();
00145 private:
00146 bool crawled;
00148 void createROSHomeDirectory();
00149 std::string getCachePath();
00150
00151 Stack* add_stack(std::string path);
00152 bool cache_is_good();
00154 static double time_since_epoch();
00156 void sanitize_rppvec(std::vector<std::string> &rppvec);
00157 };
00158
00159 }
00160
00161 #endif