All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SystemPaths.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 
37 #include "gazebo/util/system.hh"
38 
39 namespace gazebo
40 {
41  namespace common
42  {
45 
55  class GAZEBO_VISIBLE SystemPaths : public SingletonT<SystemPaths>
56  {
58  private: SystemPaths();
59 
62  public: std::string GetLogPath() const;
63 
66  public: const std::list<std::string> &GetGazeboPaths();
67 
70  public: const std::list<std::string> &GetOgrePaths();
71 
74  public: const std::list<std::string> &GetPluginPaths();
75 
78  public: const std::list<std::string> &GetModelPaths();
79 
82  public: std::string GetWorldPathExtension();
83 
87  public: std::string GetTmpPath();
88 
92  public: std::string GetTmpInstancePath();
93 
97  public: std::string GetDefaultTestPath();
98 
102  public: std::string FindFileURI(const std::string &_uri);
103 
109  public: std::string FindFile(const std::string &_filename,
110  bool _searchLocalPath = true);
111 
114  public: void AddGazeboPaths(const std::string &_path);
115 
118  public: void AddModelPaths(const std::string &_path);
119 
122  public: void AddOgrePaths(const std::string &_path);
123 
126  public: void AddPluginPaths(const std::string &_path);
127 
129  public: void ClearGazeboPaths();
131  public: void ClearModelPaths();
133  public: void ClearOgrePaths();
135  public: void ClearPluginPaths();
136 
139  public: void AddSearchPathSuffix(const std::string &_suffix);
140 
142  private: void UpdateModelPaths();
144  private: void UpdateGazeboPaths();
146  private: void UpdatePluginPaths();
148  private: void UpdateOgrePaths();
149 
153  private: void InsertUnique(const std::string &_path,
154  std::list<std::string> &_list);
155 
157  private: std::list<std::string> gazeboPaths;
158 
160  private: std::list<std::string> ogrePaths;
161 
163  private: std::list<std::string> pluginPaths;
164 
165  private: std::list<std::string> suffixPaths;
166 
167  private: std::list<std::string> modelPaths;
168 
169  private: std::string logPath;
170 
172  public: bool modelPathsFromEnv;
173 
175  public: bool gazeboPathsFromEnv;
176 
178  public: bool pluginPathsFromEnv;
179 
181  public: bool ogrePathsFromEnv;
182 
183  private: friend class SingletonT<SystemPaths>;
184 
186  private: boost::filesystem::path tmpPath;
187 
189  private: boost::filesystem::path tmpInstancePath;
190  };
192  }
193 }
194 #endif
bool modelPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:172
Singleton template class.
Definition: SingletonT.hh:33
bool gazeboPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition: SystemPaths.hh:175
bool ogrePathsFromEnv
if true, call UpdateOgrePaths() within GetOgrePaths()
Definition: SystemPaths.hh:181
bool pluginPathsFromEnv
if true, call UpdatePluginPaths() within GetPluginPaths()
Definition: SystemPaths.hh:178
Functions to handle getting system paths, keeps track of:
Definition: SystemPaths.hh:55
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48