Gazebo Rendering

API Reference

7.4.2
gz/rendering/Storage.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 GZ_RENDERING_STORAGE_HH_
18 #define GZ_RENDERING_STORAGE_HH_
19 
20 #include <memory>
21 #include <string>
22 #include "gz/rendering/config.hh"
23 #include "gz/rendering/Scene.hh"
24 #include "gz/rendering/Node.hh"
25 #include "gz/rendering/Light.hh"
26 #include "gz/rendering/Sensor.hh"
27 #include "gz/rendering/Visual.hh"
28 #include "gz/rendering/Geometry.hh"
29 #include "gz/rendering/Material.hh"
30 #include "gz/rendering/Mesh.hh"
31 #include "gz/rendering/Export.hh"
32 
33 // An X11 header file defines a macro that conflicts with our function name,
34 // so undefine it here
35 #ifdef DestroyAll
36 #undef DestroyAll
37 #endif
38 
39 namespace gz
40 {
41  namespace rendering
42  {
43  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
44  //
48  template <class T>
49  class GZ_RENDERING_VISIBLE Map
50  {
53  typedef std::shared_ptr<T> TPtr;
54 
58 
60  public: virtual ~Map() = default;
61 
64  public: virtual unsigned int Size() const = 0;
65 
69  public: virtual bool ContainsKey(const std::string &_key) const = 0;
70 
74  public: virtual bool ContainsValue(ConstTPtr _value) const = 0;
75 
79  public: virtual TPtr Get(const std::string &_key) const = 0;
80 
84  public: virtual TPtr GetByIndex(unsigned int _index) const = 0;
85 
91  public: virtual bool Put(const std::string &_key, TPtr _value) = 0;
92 
96  public: virtual void Remove(const std::string &_key) = 0;
97 
101  public: virtual void Remove(TPtr _value) = 0;
102 
104  public: virtual void RemoveAll() = 0;
105  };
106 
113  template <class T>
114  class GZ_RENDERING_VISIBLE Store
115  {
118  typedef std::shared_ptr<T> TPtr;
119 
123 
125  public: virtual ~Store() = default;
126 
129  public: virtual unsigned int Size() const = 0;
130 
134  public: virtual bool Contains(ConstTPtr _object) const = 0;
135 
139  public: virtual bool ContainsId(unsigned int _id) const = 0;
140 
144  public: virtual bool ContainsName(const std::string &_name) const = 0;
145 
149  public: virtual TPtr GetById(unsigned int _id) const = 0;
150 
154  public: virtual TPtr GetByName(const std::string &_name) const = 0;
155 
159  public: virtual TPtr GetByIndex(unsigned int _index) const = 0;
160 
166  public: virtual bool Add(TPtr _object) = 0;
167 
172  public: virtual TPtr Remove(TPtr _object) = 0;
173 
178  public: virtual TPtr RemoveById(unsigned int _id) = 0;
179 
184  public: virtual TPtr RemoveByName(const std::string &_name) = 0;
185 
190  public: virtual TPtr RemoveByIndex(unsigned int _index) = 0;
191 
193  public: virtual void RemoveAll() = 0;
194 
198  public: virtual void Destroy(TPtr _object) = 0;
199 
203  public: virtual void DestroyById(unsigned int _id) = 0;
204 
209  public: virtual void DestroyByName(const std::string &_name) = 0;
210 
215  public: virtual void DestroyByIndex(unsigned int _index) = 0;
216 
218  public: virtual void DestroyAll() = 0;
219  };
220 
226  template <class T>
227  class GZ_RENDERING_VISIBLE CompositeStore :
228  public Store<T>
229  {
232  typedef std::shared_ptr<T> TPtr;
233 
236  typedef Store<T> TStore;
237 
241 
245 
247  public: virtual ~CompositeStore() = default;
248 
251  public: virtual unsigned int GetStoreCount() const = 0;
252 
256  public: virtual bool ContainsStore(ConstTStorePtr _store) const = 0;
257 
262  public: virtual bool AddStore(TStorePtr _store) = 0;
263 
268  public: virtual TStorePtr GetStore(unsigned int _index) const = 0;
269 
274  public: virtual TStorePtr RemoveStore(TStorePtr _store) = 0;
275 
280  public: virtual TStorePtr RemoveStore(unsigned int _index) = 0;
281  };
282 
290  template <class T, class U>
291  class GZ_RENDERING_VISIBLE StoreWrapper :
292  public Store<T>
293  {
294  public: virtual ~StoreWrapper() = default;
295  };
296 
297 // armhf failed to build with this code. It can not be removed for the rest
298 // of arches to keep ABI but should be removed in major versions unreleased
299 // see https://github.com/gazebosim/gz-rendering/pull/457
300 #ifndef __ARM_PCS_VFP
301  template class Store<Scene>;
302  template class Store<Node>;
303  template class Store<Light>;
304  template class Store<Sensor>;
305  template class Store<Visual>;
306  template class Store<Geometry>;
307  template class Store<SubMesh>;
308  template class Map<Material>;
309  template class CompositeStore<Node>;
310 #endif
311 
315 
319 
323 
327 
331 
335 
339 
343 
347 
351 
355 
359 
363 
367 
371 
375 
379 
383  }
384  }
385 }
386 #endif