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 
36 namespace gazebo
37 {
38  namespace common
39  {
41  class ModelDatabasePrivate;
42 
45 
49  class GZ_COMMON_VISIBLE ModelDatabase : public SingletonT<ModelDatabase>
50  {
52  private: ModelDatabase();
53 
55  private: virtual ~ModelDatabase();
56 
60  public: void Start(bool _fetchImmediately = false);
61 
63  public: void Fini();
64 
67  public: std::string GetURI();
68 
74  public: std::map<std::string, std::string> GetModels();
75 
83  public: event::ConnectionPtr GetModels(boost::function<
84  void (const std::map<std::string, std::string> &)> _func);
85 
93  public: std::string GetModelName(const std::string &_uri);
94 
97  public: std::string GetModelConfig(const std::string &_uri);
98 
101  public: std::string GetDBConfig(const std::string &_uri);
102 
110  public: std::string GetModelPath(const std::string &_uri,
111  bool _forceDownload = false);
112 
119  public: std::string GetModelFile(const std::string &_uri);
120 
127  public: void DownloadDependencies(const std::string &_path);
128 
134  public: bool HasModel(const std::string &_modelName);
135 
139  private: std::string GetManifestImpl(const std::string &_uri);
140 
144  private: void UpdateModelCache(bool _fetchImmediately);
145 
148  private: bool UpdateModelCacheImpl();
149 
151  private: ModelDatabasePrivate *dataPtr;
152 
154  private: friend class SingletonT<ModelDatabase>;
155 
158  private: static ModelDatabase *myself;
159  };
160  }
161 }
162 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Singleton template class.
Definition: SingletonT.hh:33
Connects to model database, and has utility functions to find models.
Definition: ModelDatabase.hh:49
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134