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
38#include "gazebo/util/system.hh"
39
41GZ_SINGLETON_DECLARE(GZ_COMMON_VISIBLE, gazebo, common, SystemPaths)
42
43namespace 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
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
201 public: event::EventT<void (std::string)> updateModelRequest;
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 FuelModelDatabase.hh:37
gazebo
Definition SystemPaths.hh:41
common
Definition SystemPaths.hh:41
Singleton template class.
Definition SingletonT.hh:34
Functions to handle getting system paths, keeps track of:
Definition SystemPaths.hh:60
void ClearOgrePaths()
clear out SystemPaths::ogrePaths
void AddSearchPathSuffix(const std::string &_suffix)
add _suffix to the list of path search suffixes
void AddGazeboPaths(const std::string &_path)
Add colon delimited paths to Gazebo install.
void AddFindFileCallback(std::function< std::string(const std::string &)> _cb)
Add a callback to use when Gazebo can't find a file.
void ClearGazeboPaths()
clear out SystemPaths::gazeboPaths
const std::string & TmpInstancePath() const
Returns a unique temporary file for this instance of SystemPath.
std::string GetLogPath() const
Get the log path.
bool ogrePathsFromEnv
if true, call UpdateOgrePaths() within GetOgrePaths()
Definition SystemPaths.hh:213
void AddModelPaths(const std::string &_path)
Add colon delimited paths to modelPaths.
void AddPluginPaths(const std::string &_path)
Add colon delimited paths to plugins.
bool gazeboPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition SystemPaths.hh:207
std::string GetWorldPathExtension()
Returns the world path extension.
void ClearPluginPaths()
clear out SystemPaths::pluginPaths
const std::string & TmpPath() const
Returns the default path suitable for temporary files.
event::EventT< void(std::string)> updateModelRequest
Event to notify InsertModelWidget that the model paths were changed.
Definition SystemPaths.hh:201
void ClearModelPaths()
clear out SystemPaths::modelPaths
void AddModelPathsUpdate(const std::string &_path)
Add colon delimited paths to modelPaths and signal the update to InsertModelWidget.
const std::list< std::string > & GetModelPaths()
Get the model paths.
bool pluginPathsFromEnv
if true, call UpdatePluginPaths() within GetPluginPaths()
Definition SystemPaths.hh:210
std::string DefaultTestPath() const
Returns the default temporary test path.
void AddOgrePaths(const std::string &_path)
Add colon delimited paths to ogre install.
std::string FindFile(const std::string &_filename, bool _searchLocalPath=true)
Find a file in the gazebo paths.
const std::list< std::string > & GetOgrePaths()
Get the ogre install paths.
const std::list< std::string > & GetGazeboPaths()
Get the gazebo install paths.
std::string FindFileURI(const std::string &_uri)
Find a file or path using a URI.
bool modelPathsFromEnv
if true, call UpdateGazeboPaths() within GetGazeboPaths()
Definition SystemPaths.hh:204
const std::list< std::string > & GetPluginPaths()
Get the plugin paths.
A class for event processing.
Definition Event.hh:98
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition SingletonT.hh:58
Forward declarations for the common classes.
Definition Animation.hh:27