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 
41 GZ_SINGLETON_DECLARE(GZ_COMMON_VISIBLE, gazebo, common, SystemPaths)
42 
43 namespace gazebo
44 {
45  namespace common
46  {
49 
59  class GZ_COMMON_VISIBLE SystemPaths : public SingletonT<SystemPaths>
60  {
62  private: SystemPaths();
63 
66  public: std::string GetLogPath() const;
67 
70  public: const std::list<std::string> &GetGazeboPaths();
71 
74  public: const std::list<std::string> &GetOgrePaths();
75 
78  public: const std::list<std::string> &GetPluginPaths();
79 
82  public: const std::list<std::string> &GetModelPaths();
83 
86  public: std::string GetWorldPathExtension();
87 
91  public: const std::string &TmpPath() const;
92 
96  public: const std::string &TmpInstancePath() const;
97 
101  public: std::string DefaultTestPath() const;
102 
107  public: std::string FindFileURI(const std::string &_uri);
108 
116  public: std::string FindFile(const std::string &_filename,
117  bool _searchLocalPath = true);
118 
126  public: void AddFindFileCallback(
127  std::function<std::string (const std::string &)> _cb);
128 
131  public: void AddGazeboPaths(const std::string &_path);
132 
135  public: void AddModelPaths(const std::string &_path);
136 
140  public: void AddModelPathsUpdate(const std::string &_path);
141 
144  public: void AddOgrePaths(const std::string &_path);
145 
148  public: void AddPluginPaths(const std::string &_path);
149 
151  public: void ClearGazeboPaths();
152 
154  public: void ClearModelPaths();
155 
157  public: void ClearOgrePaths();
158 
160  public: void ClearPluginPaths();
161 
164  public: void AddSearchPathSuffix(const std::string &_suffix);
165 
167  private: void UpdateModelPaths();
168 
170  private: void UpdateGazeboPaths();
171 
173  private: void UpdatePluginPaths();
174 
176  private: void UpdateOgrePaths();
177 
181  private: void InsertUnique(const std::string &_path,
182  std::list<std::string> &_list);
183 
185  private: std::list<std::string> gazeboPaths;
186 
188  private: std::list<std::string> ogrePaths;
189 
191  private: std::list<std::string> pluginPaths;
192 
193  private: std::list<std::string> suffixPaths;
194 
195  private: std::list<std::string> modelPaths;
196 
197  private: std::string logPath;
198 
202 
204  public: bool modelPathsFromEnv;
205 
207  public: bool gazeboPathsFromEnv;
208 
210  public: bool pluginPathsFromEnv;
211 
213  public: bool ogrePathsFromEnv;
214 
215  private: friend class SingletonT<SystemPaths>;
216 
218  private: boost::filesystem::path tmpPath;
219 
221  private: boost::filesystem::path tmpInstancePath;
222  };
224  }
225 }
226 #endif
common
Definition: SystemPaths.hh:41
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:207
bool pluginPathsFromEnv
if true, call UpdatePluginPaths() within GetPluginPaths()
Definition: SystemPaths.hh:210
event::EventT< void(std::string)> updateModelRequest
Event to notify InsertModelWidget that the model paths were changed.
Definition: SystemPaths.hh:201
bool modelPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:204
Functions to handle getting system paths, keeps track of:
Definition: SystemPaths.hh:59
bool ogrePathsFromEnv
if true, call UpdateOgrePaths() within GetOgrePaths()
Definition: SystemPaths.hh:213
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61