FuelModelDatabase.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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_COMMON_FUELMODELDATABASE_HH_
18 #define GAZEBO_COMMON_FUELMODELDATABASE_HH_
19 
20 #include <functional>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 #ifdef _WIN32
25  // DELETE is defined in winnt.h and causes a problem with
26  // ignition::fuel_tools::REST::DELETE
27  #undef DELETE
28 #endif
29 #include <ignition/fuel_tools/ClientConfig.hh>
30 #include <ignition/fuel_tools/ModelIdentifier.hh>
31 
33 #include "gazebo/util/system.hh"
34 
36 #define GZ_MODEL_MANIFEST_FILENAME "model.config"
37 
39 #define GZ_MODEL_DB_MANIFEST_FILENAME "database.config"
40 
42 GZ_SINGLETON_DECLARE(GZ_COMMON_VISIBLE, gazebo, common, FuelModelDatabase)
43 
44 namespace gazebo
45 {
46  namespace common
47  {
49  class FuelModelDatabasePrivate;
50 
53 
57  class GZ_COMMON_VISIBLE FuelModelDatabase
58  : public SingletonT<FuelModelDatabase>
59  {
61  private: FuelModelDatabase();
62 
64  private: virtual ~FuelModelDatabase();
65 
68  public: std::vector<ignition::fuel_tools::ServerConfig> Servers() const;
69 
78  public: virtual void Models(
79  const ignition::fuel_tools::ServerConfig &_server,
80  std::function <void (
81  const std::vector<ignition::fuel_tools::ModelIdentifier> &)>
82  &_func);
83 
90  public: virtual std::vector<ignition::fuel_tools::ModelIdentifier>
91  Models(const ignition::fuel_tools::ServerConfig &_server) const;
92 
99  public: std::string ModelFile(const std::string &_uri);
100 
108  public: std::string ModelPath(const std::string &_uri,
109  const bool _forceDownload = false);
110 
118  public: std::string WorldPath(const std::string &_uri,
119  const bool _forceDownload = false);
120 
124  public: std::string CachedFilePath(const std::string &_uri);
125 
127  private: std::unique_ptr<FuelModelDatabasePrivate> dataPtr;
128 
130  private: friend class SingletonT<FuelModelDatabase>;
131 
133  private: static FuelModelDatabase *myself;
134  };
135  }
136 }
137 #endif
common
Definition: FuelModelDatabase.hh:42
Singleton template class.
Definition: SingletonT.hh:34
Connects to an Igniiton Fuel model database, and has utility functions to find models.
Definition: FuelModelDatabase.hh:59
virtual void Models(const ignition::fuel_tools::ServerConfig &_server, std::function< void(const std::vector< ignition::fuel_tools::ModelIdentifier > &)> &_func)
Get the list of all models via a callback.
std::vector< ignition::fuel_tools::ServerConfig > Servers() const
Get all the Ignition Fuel servers.
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:58
std::string ModelPath(const std::string &_uri, const bool _forceDownload=false)
Get the local path to a model.
std::string CachedFilePath(const std::string &_uri)
Get the full local path to a cached file based on its URI.
std::string ModelFile(const std::string &_uri)
Get a model's SDF file based on a URI.
std::string WorldPath(const std::string &_uri, const bool _forceDownload=false)
Get the local path to a world.
virtual std::vector< ignition::fuel_tools::ModelIdentifier > Models(const ignition::fuel_tools::ServerConfig &_server) const
Get the list of all models.
Forward declarations for the common classes.
Definition: Animation.hh:27