SystemPaths.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_SYSTEMPATHS_HH_
18 #define _GAZEBO_SYSTEMPATHS_HH_
19 
20 #include <stdio.h>
21 
22 #define LINUX
23 #ifdef _WIN32
24  #include <direct.h>
25  #define GetCurrentDir _getcwd
26 #else
27  #include <unistd.h>
28  #define GetCurrentDir getcwd
29 #endif
30 
31 #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
32 #include <boost/filesystem.hpp>
33 #endif
34 #include <list>
35 #include <string>
36 
38 #include "gazebo/common/Event.hh"
40 #include "gazebo/util/system.hh"
41 
42 namespace gazebo
43 {
44  namespace common
45  {
48 
58  class GZ_COMMON_VISIBLE SystemPaths : public SingletonT<SystemPaths>
59  {
61  private: SystemPaths();
62 
65  public: std::string GetLogPath() const;
66 
69  public: const std::list<std::string> &GetGazeboPaths();
70 
73  public: const std::list<std::string> &GetOgrePaths();
74 
77  public: const std::list<std::string> &GetPluginPaths();
78 
81  public: const std::list<std::string> &GetModelPaths();
82 
85  public: std::string GetWorldPathExtension();
86 
90  public: std::string GetTmpPath();
91 
95  public: std::string GetTmpInstancePath();
96 
100  public: std::string GetDefaultTestPath();
101 
105  public: std::string FindFileURI(const std::string &_uri);
106 
112  public: std::string FindFile(const std::string &_filename,
113  bool _searchLocalPath = true);
114 
117  public: void AddGazeboPaths(const std::string &_path);
118 
121  public: void AddModelPaths(const std::string &_path);
122 
126  public: void AddModelPathsUpdate(const std::string &_path);
127 
130  public: void AddOgrePaths(const std::string &_path);
131 
134  public: void AddPluginPaths(const std::string &_path);
135 
137  public: void ClearGazeboPaths();
138 
140  public: void ClearModelPaths();
141 
143  public: void ClearOgrePaths();
144 
146  public: void ClearPluginPaths();
147 
150  public: void AddSearchPathSuffix(const std::string &_suffix);
151 
153  private: void UpdateModelPaths();
154 
156  private: void UpdateGazeboPaths();
157 
159  private: void UpdatePluginPaths();
160 
162  private: void UpdateOgrePaths();
163 
167  private: void InsertUnique(const std::string &_path,
168  std::list<std::string> &_list);
169 
171  private: std::list<std::string> gazeboPaths;
172 
174  private: std::list<std::string> ogrePaths;
175 
177  private: std::list<std::string> pluginPaths;
178 
179  private: std::list<std::string> suffixPaths;
180 
181  private: std::list<std::string> modelPaths;
182 
183  private: std::string logPath;
184 
188 
190  public: bool modelPathsFromEnv;
191 
193  public: bool gazeboPathsFromEnv;
194 
196  public: bool pluginPathsFromEnv;
197 
199  public: bool ogrePathsFromEnv;
200 
201  private: friend class SingletonT<SystemPaths>;
202 
204  private: boost::filesystem::path tmpPath;
205 
207  private: boost::filesystem::path tmpInstancePath;
208  };
210  }
211 }
212 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Singleton template class.
Definition: SingletonT.hh:33
bool gazeboPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:193
bool pluginPathsFromEnv
if true, call UpdatePluginPaths() within GetPluginPaths()
Definition: SystemPaths.hh:196
event::EventT< void(std::string)> updateModelRequest
Event to notify InsertModelWidget that the model paths were changed.
Definition: SystemPaths.hh:187
bool modelPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:190
Functions to handle getting system paths, keeps track of:
Definition: SystemPaths.hh:58
bool ogrePathsFromEnv
if true, call UpdateOgrePaths() within GetOgrePaths()
Definition: SystemPaths.hh:199