Gazebo Rendering

API Reference

6.6.3
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 ignition
40 {
41  namespace rendering
42  {
43  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
44  //
48  template <class T>
49  class IGNITION_RENDERING_VISIBLE Map
50  {
53  typedef std::shared_ptr<T> TPtr;
54 
58 
60  public: virtual ~Map() { }
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 IGNITION_RENDERING_VISIBLE Store
115  {
118  typedef std::shared_ptr<T> TPtr;
119 
123 
125  public: virtual ~Store() { }
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 IGNITION_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() { }
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 IGNITION_RENDERING_VISIBLE StoreWrapper :
292  public Store<T>
293  {
294  public: virtual ~StoreWrapper() { }
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/ignitionrobotics/ign-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
virtual TStorePtr RemoveStore(TStorePtr _store)=0
Remove given store. If no such store exists no work will be done and NULL will be returned.
Storage map from std::string to template class T.
Definition: gz/rendering/Storage.hh:49
virtual unsigned int GetStoreCount() const =0
Get number of Stores.
virtual void Remove(const std::string &_key)=0
Remove the element mapped to the given key. If the specified element does not exists,...
Store< Sensor > SensorStore
Definition: gz/rendering/Storage.hh:326
virtual void DestroyByName(const std::string &_name)=0
Remove and destroy element with the given name. If the specified element does not exists in this stor...
std::shared_ptr< LightStore > LightStorePtr
Definition: gz/rendering/Storage.hh:358
STL class.
std::shared_ptr< GeometryStore > GeometryStorePtr
Definition: gz/rendering/Storage.hh:370
STL class.
virtual void RemoveAll()=0
Remove all elements from store.
virtual TPtr RemoveByIndex(unsigned int _index)=0
Remove element at the given index. If the specified element does not exists in this store,...
virtual TPtr GetById(unsigned int _id) const =0
Get element with the given ID.
virtual bool ContainsName(const std::string &_name) const =0
Determine if store contains the element with the given name.
Store< Scene > SceneStore
Definition: gz/rendering/Storage.hh:314
virtual bool ContainsStore(ConstTStorePtr _store) const =0
Determine if given store exists.
std::shared_ptr< SensorStore > SensorStorePtr
Definition: gz/rendering/Storage.hh:362
virtual void DestroyByIndex(unsigned int _index)=0
Remove and destroy element at the given index. If the specified element does not exists in this store...
Store< Visual > VisualStore
Definition: gz/rendering/Storage.hh:330
Store< Light > LightStore
Definition: gz/rendering/Storage.hh:322
virtual void RemoveAll()=0
Remove all elements from this map.
virtual ~StoreWrapper()
Definition: gz/rendering/Storage.hh:294
virtual bool Put(const std::string &_key, TPtr _value)=0
Map to given element to the given key. If the given key is already in use, no work will be done.
std::shared_ptr< SceneStore > SceneStorePtr
Definition: gz/rendering/Storage.hh:350
std::shared_ptr< MaterialMap > MaterialMapPtr
Definition: gz/rendering/Storage.hh:378
virtual void DestroyById(unsigned int _id)=0
Remove and destroy element with the given ID. If the specified element does not exists in this store,...
Map< Material > MaterialMap
Definition: gz/rendering/Storage.hh:342
Multi-access storage structure of template class T. Template class T is expected to have functions Ge...
Definition: gz/rendering/Storage.hh:114
std::shared_ptr< NodeStore > NodeStorePtr
Definition: gz/rendering/Storage.hh:354
virtual TPtr Get(const std::string &_key) const =0
Get the element mapped to the given key.
Store< Node > NodeStore
Definition: gz/rendering/Storage.hh:318
virtual ~Map()
Deconstructor.
Definition: gz/rendering/Storage.hh:60
virtual bool ContainsKey(const std::string &_key) const =0
Determine if an elements is mapped to the given key.
virtual TPtr GetByIndex(unsigned int _index) const =0
Get the element at the given index.
virtual bool Add(TPtr _object)=0
Add given element. If the element has already been added or its name or ID conflict with other existi...
virtual ~Store()
Deconstructor.
Definition: gz/rendering/Storage.hh:125
virtual ~CompositeStore()
Deconstructor.
Definition: gz/rendering/Storage.hh:247
Simple wrapper class that allows a Store of type Derived to be treated as a Store of type Base,...
Definition: gz/rendering/Storage.hh:291
virtual TPtr RemoveByName(const std::string &_name)=0
Remove element with the given name. If the specified element does not exists in this store,...
Store< SubMesh > SubMeshStore
Definition: gz/rendering/Storage.hh:338
virtual bool ContainsId(unsigned int _id) const =0
Determine if store contains the element with the given ID.
CompositeStore< Node > NodeCompositeStore
Definition: gz/rendering/Storage.hh:346
std::shared_ptr< SubMeshStore > SubMeshStorePtr
Definition: gz/rendering/Storage.hh:374
virtual TPtr GetByName(const std::string &_name) const =0
Get element with the given name.
std::shared_ptr< VisualStore > VisualStorePtr
Definition: gz/rendering/Storage.hh:366
virtual bool Contains(ConstTPtr _object) const =0
Determine if store contains the given element.
virtual bool ContainsValue(ConstTPtr _value) const =0
Determine if the given element exists in this map.
Represents a collection of Store objects, collectively working as a single composite store.
Definition: gz/rendering/Storage.hh:227
virtual void Destroy(TPtr _object)=0
Remove and destroy given element. If the given element does not exists, in this store,...
virtual unsigned int Size() const =0
Get the number of elements in this map.
Store< Geometry > GeometryStore
Definition: gz/rendering/Storage.hh:334
virtual TPtr RemoveById(unsigned int _id)=0
Remove element with the given ID. If the specified element does not exists in this store,...
virtual void DestroyAll()=0
Remove and destroy all elements in store.
virtual TPtr GetByIndex(unsigned int _index) const =0
Get element at the given index.
virtual unsigned int Size() const =0
Get number of elements in this store.
virtual TPtr Remove(TPtr _object)=0
Remove given element. If the given element does not exists in this store, then no work will be done.
virtual TStorePtr GetStore(unsigned int _index) const =0
Get store at the given index. If no such store exists NULL will be returned.
std::shared_ptr< NodeCompositeStore > NodeCompositeStorePtr
Definition: gz/rendering/Storage.hh:382
virtual bool AddStore(TStorePtr _store)=0
Add the given store. If the given store already exists, then no work will be done.