ModelDatabase.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_MODELDATABSE_HH_
18 #define _GAZEBO_MODELDATABSE_HH_
19 
20 #include <string>
21 #include <map>
22 #include <utility>
23 
24 #include <boost/function.hpp>
25 #include "gazebo/common/Event.hh"
28 #include "gazebo/util/system.hh"
29 
31 #define GZ_MODEL_MANIFEST_FILENAME "model.config"
32 
34 #define GZ_MODEL_DB_MANIFEST_FILENAME "database.config"
35 
37 GZ_SINGLETON_DECLARE(GZ_COMMON_VISIBLE, gazebo, common, ModelDatabase)
38 
39 namespace gazebo
40 {
41  namespace common
42  {
44  class ModelDatabasePrivate;
45 
48 
52  class GZ_COMMON_VISIBLE ModelDatabase : public SingletonT<ModelDatabase>
53  {
55  private: ModelDatabase();
56 
58  private: virtual ~ModelDatabase();
59 
63  public: void Start(bool _fetchImmediately = false);
64 
66  public: void Fini();
67 
70  public: std::string GetURI();
71 
77  public: std::map<std::string, std::string> GetModels();
78 
86  public: event::ConnectionPtr GetModels(boost::function<
87  void (const std::map<std::string, std::string> &)> _func);
88 
96  public: std::string GetModelName(const std::string &_uri);
97 
100  public: std::string GetModelConfig(const std::string &_uri);
101 
104  public: std::string GetDBConfig(const std::string &_uri);
105 
113  public: std::string GetModelPath(const std::string &_uri,
114  bool _forceDownload = false);
115 
122  public: std::string GetModelFile(const std::string &_uri);
123 
130  public: void DownloadDependencies(const std::string &_path);
131 
137  public: bool HasModel(const std::string &_modelName);
138 
142  private: std::string GetManifestImpl(const std::string &_uri);
143 
147  private: void UpdateModelCache(bool _fetchImmediately);
148 
151  private: bool UpdateModelCacheImpl();
152 
154  private: ModelDatabasePrivate *dataPtr;
155 
157  private: friend class SingletonT<ModelDatabase>;
158 
161  private: static ModelDatabase *myself;
162  };
163  }
164 }
165 #endif
Forward declarations for the common classes.
Definition: Animation.hh:26
Singleton template class.
Definition: SingletonT.hh:33
common
Definition: ModelDatabase.hh:37
Connects to model database, and has utility functions to find models.
Definition: ModelDatabase.hh:52
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61