SystemPaths.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 WINDOWS
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 GAZEBO_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: std::string GetTmpPath();
89 
93  public: std::string GetTmpInstancePath();
94 
98  public: std::string GetDefaultTestPath();
99 
103  public: std::string FindFileURI(const std::string &_uri);
104 
110  public: std::string FindFile(const std::string &_filename,
111  bool _searchLocalPath = true);
112 
115  public: void AddGazeboPaths(const std::string &_path);
116 
119  public: void AddModelPaths(const std::string &_path);
120 
124  public: void AddModelPathsUpdate(const std::string &_path);
125 
128  public: void AddOgrePaths(const std::string &_path);
129 
132  public: void AddPluginPaths(const std::string &_path);
133 
135  public: void ClearGazeboPaths();
136 
138  public: void ClearModelPaths();
139 
141  public: void ClearOgrePaths();
142 
144  public: void ClearPluginPaths();
145 
148  public: void AddSearchPathSuffix(const std::string &_suffix);
149 
151  private: void UpdateModelPaths();
152 
154  private: void UpdateGazeboPaths();
155 
157  private: void UpdatePluginPaths();
158 
160  private: void UpdateOgrePaths();
161 
165  private: void InsertUnique(const std::string &_path,
166  std::list<std::string> &_list);
167 
169  private: std::list<std::string> gazeboPaths;
170 
172  private: std::list<std::string> ogrePaths;
173 
175  private: std::list<std::string> pluginPaths;
176 
177  private: std::list<std::string> suffixPaths;
178 
179  private: std::list<std::string> modelPaths;
180 
181  private: std::string logPath;
182 
186 
188  public: bool modelPathsFromEnv;
189 
191  public: bool gazeboPathsFromEnv;
192 
194  public: bool pluginPathsFromEnv;
195 
197  public: bool ogrePathsFromEnv;
198 
199  private: friend class SingletonT<SystemPaths>;
200 
202  private: boost::filesystem::path tmpPath;
203 
205  private: boost::filesystem::path tmpInstancePath;
206  };
208  }
209 }
210 #endif
bool modelPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:188
Singleton template class.
Definition: SingletonT.hh:33
bool gazeboPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:191
bool ogrePathsFromEnv
if true, call UpdateOgrePaths() within GetOgrePaths()
Definition: SystemPaths.hh:197
event::EventT< void(std::string)> updateModelRequest
Event to notify InsertModelWidget that the model paths were changed.
Definition: SystemPaths.hh:185
bool pluginPathsFromEnv
if true, call UpdatePluginPaths() within GetPluginPaths()
Definition: SystemPaths.hh:194
Functions to handle getting system paths, keeps track of:
Definition: SystemPaths.hh:56
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48