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 
88  public: const std::string &TmpPath() const;
89 
93  public: const std::string &TmpInstancePath() const;
94 
98  public: std::string DefaultTestPath() const;
99 
104  public: std::string FindFileURI(const std::string &_uri);
105 
113  public: std::string FindFile(const std::string &_filename,
114  bool _searchLocalPath = true);
115 
123  public: void AddFindFileCallback(
124  std::function<std::string (const std::string &)> _cb);
125 
128  public: void AddGazeboPaths(const std::string &_path);
129 
132  public: void AddModelPaths(const std::string &_path);
133 
137  public: void AddModelPathsUpdate(const std::string &_path);
138 
141  public: void AddOgrePaths(const std::string &_path);
142 
145  public: void AddPluginPaths(const std::string &_path);
146 
148  public: void ClearGazeboPaths();
149 
151  public: void ClearModelPaths();
152 
154  public: void ClearOgrePaths();
155 
157  public: void ClearPluginPaths();
158 
161  public: void AddSearchPathSuffix(const std::string &_suffix);
162 
164  private: void UpdateModelPaths();
165 
167  private: void UpdateGazeboPaths();
168 
170  private: void UpdatePluginPaths();
171 
173  private: void UpdateOgrePaths();
174 
178  private: void InsertUnique(const std::string &_path,
179  std::list<std::string> &_list);
180 
182  private: std::list<std::string> gazeboPaths;
183 
185  private: std::list<std::string> ogrePaths;
186 
188  private: std::list<std::string> pluginPaths;
189 
190  private: std::list<std::string> suffixPaths;
191 
192  private: std::list<std::string> modelPaths;
193 
194  private: std::string logPath;
195 
199 
201  public: bool modelPathsFromEnv;
202 
204  public: bool gazeboPathsFromEnv;
205 
207  public: bool pluginPathsFromEnv;
208 
210  public: bool ogrePathsFromEnv;
211 
212  private: friend class SingletonT<SystemPaths>;
213 
215  private: boost::filesystem::path tmpPath;
216 
218  private: boost::filesystem::path tmpInstancePath;
219  };
221  }
222 }
223 #endif
Forward declarations for the common classes.
Definition: Animation.hh:26
Singleton template class.
Definition: SingletonT.hh:33
bool gazeboPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:204
bool pluginPathsFromEnv
if true, call UpdatePluginPaths() within GetPluginPaths()
Definition: SystemPaths.hh:207
event::EventT< void(std::string)> updateModelRequest
Event to notify InsertModelWidget that the model paths were changed.
Definition: SystemPaths.hh:198
bool modelPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:201
Functions to handle getting system paths, keeps track of:
Definition: SystemPaths.hh:56
bool ogrePathsFromEnv
if true, call UpdateOgrePaths() within GetOgrePaths()
Definition: SystemPaths.hh:210