All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ModelDatabase.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_MODELDATABSE_HH_
18 #define _GAZEBO_MODELDATABSE_HH_
19 
20 #include <string>
21 #include <map>
22 #include <utility>
23 
24 #include "gazebo/common/Event.hh"
27 #include "gazebo/util/system.hh"
28 
30 #define GZ_MODEL_MANIFEST_FILENAME "model.config"
31 
33 #define GZ_MODEL_DB_MANIFEST_FILENAME "database.config"
34 
35 namespace gazebo
36 {
37  namespace common
38  {
40  class ModelDatabasePrivate;
41 
44 
48  class GAZEBO_VISIBLE ModelDatabase : public SingletonT<ModelDatabase>
49  {
51  private: ModelDatabase();
52 
54  private: virtual ~ModelDatabase();
55 
59  public: void Start(bool _fetchImmediately = false);
60 
62  public: void Fini();
63 
66  public: std::string GetURI();
67 
73  public: std::map<std::string, std::string> GetModels();
74 
82  public: event::ConnectionPtr GetModels(boost::function<
83  void (const std::map<std::string, std::string> &)> _func);
84 
92  public: std::string GetModelName(const std::string &_uri);
93 
96  public: std::string GetModelConfig(const std::string &_uri);
97 
100  public: std::string GetDBConfig(const std::string &_uri);
101 
109  public: std::string GetModelPath(const std::string &_uri,
110  bool _forceDownload = false);
111 
118  public: std::string GetModelFile(const std::string &_uri);
119 
126  public: void DownloadDependencies(const std::string &_path);
127 
133  public: bool HasModel(const std::string &_modelName);
134 
138  private: std::string GetManifestImpl(const std::string &_uri);
139 
143  private: void UpdateModelCache(bool _fetchImmediately);
144 
147  private: bool UpdateModelCacheImpl();
148 
150  private: ModelDatabasePrivate *dataPtr;
151 
153  private: friend class SingletonT<ModelDatabase>;
154 
157  private: static ModelDatabase *myself;
158  };
159  }
160 }
161 #endif