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 #include <boost/filesystem.hpp>
32 #include <list>
33 #include <string>
34 
36 #include "gazebo/common/Event.hh"
38 #include "gazebo/util/system.hh"
39 
40 namespace gazebo
41 {
42  namespace common
43  {
46 
56  class GZ_COMMON_VISIBLE SystemPaths : public SingletonT<SystemPaths>
57  {
59  private: SystemPaths();
60 
63  public: std::string GetLogPath() const;
64 
67  public: const std::list<std::string> &GetGazeboPaths();
68 
71  public: const std::list<std::string> &GetOgrePaths();
72 
75  public: const std::list<std::string> &GetPluginPaths();
76 
79  public: const std::list<std::string> &GetModelPaths();
80 
83  public: std::string GetWorldPathExtension();
84 
89  public: std::string GetTmpPath() GAZEBO_DEPRECATED(8.0);
90 
94  public: const std::string &TmpPath() const;
95 
100  public: std::string GetTmpInstancePath() GAZEBO_DEPRECATED(8.0);
101 
105  public: const std::string &TmpInstancePath() const;
106 
111  public: std::string GetDefaultTestPath() GAZEBO_DEPRECATED(8.0);
112 
116  public: std::string DefaultTestPath() const;
117 
121  public: std::string FindFileURI(const std::string &_uri);
122 
128  public: std::string FindFile(const std::string &_filename,
129  bool _searchLocalPath = true);
130 
133  public: void AddGazeboPaths(const std::string &_path);
134 
137  public: void AddModelPaths(const std::string &_path);
138 
142  public: void AddModelPathsUpdate(const std::string &_path);
143 
146  public: void AddOgrePaths(const std::string &_path);
147 
150  public: void AddPluginPaths(const std::string &_path);
151 
153  public: void ClearGazeboPaths();
154 
156  public: void ClearModelPaths();
157 
159  public: void ClearOgrePaths();
160 
162  public: void ClearPluginPaths();
163 
166  public: void AddSearchPathSuffix(const std::string &_suffix);
167 
169  private: void UpdateModelPaths();
170 
172  private: void UpdateGazeboPaths();
173 
175  private: void UpdatePluginPaths();
176 
178  private: void UpdateOgrePaths();
179 
183  private: void InsertUnique(const std::string &_path,
184  std::list<std::string> &_list);
185 
187  private: std::list<std::string> gazeboPaths;
188 
190  private: std::list<std::string> ogrePaths;
191 
193  private: std::list<std::string> pluginPaths;
194 
195  private: std::list<std::string> suffixPaths;
196 
197  private: std::list<std::string> modelPaths;
198 
199  private: std::string logPath;
200 
204 
206  public: bool modelPathsFromEnv;
207 
209  public: bool gazeboPathsFromEnv;
210 
212  public: bool pluginPathsFromEnv;
213 
215  public: bool ogrePathsFromEnv;
216 
217  private: friend class SingletonT<SystemPaths>;
218 
220  private: boost::filesystem::path tmpPath;
221 
223  private: boost::filesystem::path tmpInstancePath;
224  };
226  }
227 }
228 #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:209
bool pluginPathsFromEnv
if true, call UpdatePluginPaths() within GetPluginPaths()
Definition: SystemPaths.hh:212
event::EventT< void(std::string)> updateModelRequest
Event to notify InsertModelWidget that the model paths were changed.
Definition: SystemPaths.hh:203
bool modelPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:206
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
Functions to handle getting system paths, keeps track of:
Definition: SystemPaths.hh:56
bool ogrePathsFromEnv
if true, call UpdateOgrePaths() within GetOgrePaths()
Definition: SystemPaths.hh:215