rospack.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008, Willow Garage, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
105 #ifndef ROSPACK_ROSPACK_H
106 #define ROSPACK_ROSPACK_H
107 
108 #include <boost/unordered_set.hpp>
109 #include <boost/unordered_map.hpp>
110 #include <list>
111 #include <map>
112 #include <set>
113 #include <string>
114 #include <vector>
115 #include "macros.h"
116 
117 //#ifdef ROSPACK_API_BACKCOMPAT_V1
118 #if 1 // def ROSPACK_API_BACKCOMPAT_V1
120 #endif
121 
122 
123 namespace rospack
124 {
125 
126 typedef enum
127 {
131 
132 // Forward declarations
133 class Stackage;
134 class DirectoryCrawlRecord;
135 
142 {
143  private:
144  std::string manifest_name_;
145  std::string cache_prefix_;
146  bool crawled_;
147  std::string name_;
148  std::string tag_;
149  bool quiet_;
150  std::vector<std::string> search_paths_;
151  boost::unordered_map<std::string, std::vector<std::string> > dups_;
152  boost::unordered_map<std::string, Stackage*> stackages_;
153  Stackage* findWithRecrawl(const std::string& name);
154  void log(const std::string& level, const std::string& msg, bool append_errno);
155  void clearStackages();
156  void addStackage(const std::string& path);
157  void crawlDetail(const std::string& path,
158  bool force,
159  int depth,
160  bool collect_profile_data,
161  std::vector<DirectoryCrawlRecord*>& profile_data,
162  boost::unordered_set<std::string>& profile_hash);
163  bool isStackage(const std::string& path);
164  void loadManifest(Stackage* stackage);
165  bool computeDeps(Stackage* stackage, bool ignore_errors=false, bool ignore_missing=false);
166  bool computeDepsInternal(Stackage* stackage, bool ignore_errors, const std::string& depend_tag, bool ignore_missing=false);
167  bool isSysPackage(const std::string& pkgname);
168  void gatherDeps(Stackage* stackage, bool direct,
169  traversal_order_t order,
170  std::vector<Stackage*>& deps,
171  bool no_recursion_on_wet=false);
172  void gatherDepsFull(Stackage* stackage, bool direct,
173  traversal_order_t order, int depth,
174  boost::unordered_set<Stackage*>& deps_hash,
175  std::vector<Stackage*>& deps,
176  bool get_indented_deps,
177  std::vector<std::string>& indented_deps,
178  bool no_recursion_on_wet=false);
179  std::string getCachePath();
180  std::string getCacheHash();
181  bool readCache();
182  void writeCache();
183  FILE* validateCache();
184  bool expandExportString(Stackage* stackage,
185  const std::string& instring,
186  std::string& outstring);
187  bool depsWhyDetail(Stackage* from,
188  Stackage* to,
189  std::list<std::list<Stackage*> >& acc_list);
190 
191  void initPython();
192 
193  protected:
202  Rosstackage(const std::string& manifest_name,
203  const std::string& cache_prefix,
204  const std::string& name,
205  const std::string& tag);
206 
207  public:
211  virtual ~Rosstackage();
212 
217  virtual const char* usage() { return ""; }
229  void crawl(std::vector<std::string> search_path, bool force);
236  bool inStackage(std::string& name);
243  void setQuiet(bool quiet);
248  const std::string& getName() {return name_;}
257  bool getSearchPathFromEnv(std::vector<std::string>& sp);
264  bool find(const std::string& name, std::string& path);
271  bool contents(const std::string& name, std::set<std::string>& packages);
279  bool contains(const std::string& name,
280  std::string& stack,
281  std::string& path);
282 
287  void list(std::set<std::pair<std::string, std::string> >& list);
293  void listDuplicates(std::vector<std::string>& dups);
299  void listDuplicatesWithPaths(std::map<std::string, std::vector<std::string> >& dups);
310  bool deps(const std::string& name, bool direct, std::vector<std::string>& deps);
321  bool depsOn(const std::string& name, bool direct,
322  std::vector<std::string>& deps);
333  bool depsDetail(const std::string& name, bool direct, std::vector<Stackage*>& deps);
343  bool depsOnDetail(const std::string& name, bool direct,
344  std::vector<Stackage*>& deps, bool ignore_missing=false);
354  bool depsManifests(const std::string& name, bool direct,
355  std::vector<std::string>& manifests);
369  bool depsMsgSrv(const std::string& name, bool direct,
370  std::vector<std::string>& gens);
392  bool depsIndent(const std::string& name, bool direct,
393  std::vector<std::string>& deps);
410  bool depsWhy(const std::string& from,
411  const std::string& to,
412  std::string& output);
424  bool rosdeps(const std::string& name, bool direct,
425  std::set<std::string>& rosdeps);
426  void _rosdeps(Stackage* stackage, std::set<std::string>& rosdeps, const char* tag_name);
439  bool vcs(const std::string& name, bool direct,
440  std::vector<std::string>& vcs);
453  bool cpp_exports(const std::string& name, const std::string& type,
454  const std::string& attrib, bool deps_only,
455  std::vector<std::pair<std::string, bool> >& flags);
462  bool reorder_paths(const std::string& paths, std::string& reordered);
475  bool exports(const std::string& name, const std::string& lang,
476  const std::string& attrib, bool deps_only,
477  std::vector<std::string>& flags);
486  bool exports_dry_package(Stackage* stackage, const std::string& lang,
487  const std::string& attrib,
488  std::vector<std::string>& flags);
500  bool plugins(const std::string& name, const std::string& attrib,
501  const std::string& top,
502  std::vector<std::string>& flags);
528  bool profile(const std::vector<std::string>& search_path,
529  bool zombie_only,
530  int length,
531  std::vector<std::string>& dirs);
538  void logWarn(const std::string& msg,
539  bool append_errno = false);
546  void logError(const std::string& msg,
547  bool append_errno = false);
548 
549  /*
550  * @brief The manifest type.
551  * @return Either "package" or "stack".
552  */
553  virtual std::string get_manifest_type() { return ""; }
554 };
555 
561 {
562  public:
566  Rospack();
571  virtual const char* usage();
572 
573  virtual std::string get_manifest_type();
574 };
575 
581 {
582  public:
586  Rosstack();
591  virtual const char* usage();
592 
593  virtual std::string get_manifest_type();
594 };
595 
596 } // namespace rospack
597 
598 #endif
rospack::Rosstackage::usage
virtual const char * usage()
Usage string, to be overridden by derived classes.
Definition: rospack.h:217
rospack::traversal_order_t
traversal_order_t
Definition: rospack.h:126
rospack::Rospack
Package crawler. Create one of these to operate on a package tree. Call public methods inherited from...
Definition: rospack.h:560
rospack::Rosstackage::cache_prefix_
std::string cache_prefix_
Definition: rospack.h:145
macros.h
rospack::Rosstackage::getName
const std::string & getName()
Get the name of the tool that's in use (e.g., "rospack" or "rosstack")
Definition: rospack.h:248
rospack::PREORDER
@ PREORDER
Definition: rospack.h:129
rospack::Rosstackage::name_
std::string name_
Definition: rospack.h:147
rospack::Rosstackage::quiet_
bool quiet_
Definition: rospack.h:149
rospack::POSTORDER
@ POSTORDER
Definition: rospack.h:128
rospack::Rosstackage::crawled_
bool crawled_
Definition: rospack.h:146
rospack_backcompat.h
rospack::Rosstackage::tag_
std::string tag_
Definition: rospack.h:148
ROSPACK_DECL
#define ROSPACK_DECL
Definition: macros.h:71
rospack::Rosstackage::search_paths_
std::vector< std::string > search_paths_
Definition: rospack.h:150
rospack::Rosstack
Stack crawler. Create one of these to operate on a stack tree. Call public methods inherited from Ros...
Definition: rospack.h:580
rospack::Rosstackage::manifest_name_
std::string manifest_name_
Definition: rospack.h:144
rospack
Definition: rospack.h:123
rospack::Rosstackage::dups_
boost::unordered_map< std::string, std::vector< std::string > > dups_
Definition: rospack.h:151
rospack::Rosstackage
The base class for package/stack ("stackage") crawlers. Users of the library should use the functiona...
Definition: rospack.h:141
rospack::Stackage
Definition: rospack.cpp:139
rospack::Rosstackage::stackages_
boost::unordered_map< std::string, Stackage * > stackages_
Definition: rospack.h:152
rospack::Rosstackage::get_manifest_type
virtual std::string get_manifest_type()
Definition: rospack.h:553


rospack
Author(s): Brian Gerkey, Morgan Quigley, Dirk Thomas
autogenerated on Wed Mar 2 2022 00:54:50