Ignition Rendering

API Reference

5.0.0
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 IGNITION_RENDERING_STORAGE_HH_
18 #define IGNITION_RENDERING_STORAGE_HH_
19 
20 #include <memory>
21 #include <string>
22 #include "ignition/rendering/config.hh"
31 #include "ignition/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  template class Store<Scene>;
298  template class Store<Node>;
299  template class Store<Light>;
300  template class Store<Sensor>;
301  template class Store<Visual>;
302  template class Store<Geometry>;
303  template class Store<SubMesh>;
304  template class Map<Material>;
305  template class CompositeStore<Node>;
306 
310 
314 
318 
322 
326 
330 
334 
338 
342 
346 
350 
354 
358 
362 
366 
370 
374 
378  }
379  }
380 }
381 #endif
Represents a collection of Store objects, collectively working as a single composite store...
Definition: Storage.hh:227
std::shared_ptr< NodeCompositeStore > NodeCompositeStorePtr
Definition: Storage.hh:377
Store< Geometry > GeometryStore
Definition: Storage.hh:329
std::shared_ptr< VisualStore > VisualStorePtr
Definition: Storage.hh:361
virtual ~CompositeStore()
Destructor.
Definition: Storage.hh:247
Store< Scene > SceneStore
Definition: Storage.hh:309
std::shared_ptr< NodeStore > NodeStorePtr
Definition: Storage.hh:349
virtual ~Store()
Destructor.
Definition: Storage.hh:125
std::shared_ptr< SubMeshStore > SubMeshStorePtr
Definition: Storage.hh:369
std::shared_ptr< GeometryStore > GeometryStorePtr
Definition: Storage.hh:365
Store< Visual > VisualStore
Definition: Storage.hh:325
Store< Light > LightStore
Definition: Storage.hh:317
virtual ~Map()
Destructor.
Definition: Storage.hh:60
Map< Material > MaterialMap
Definition: Storage.hh:337
std::shared_ptr< SceneStore > SceneStorePtr
Definition: Storage.hh:345
std::shared_ptr< MaterialMap > MaterialMapPtr
Definition: Storage.hh:373
STL class.
Store< SubMesh > SubMeshStore
Definition: Storage.hh:333
Store< Node > NodeStore
Definition: Storage.hh:313
virtual ~StoreWrapper()
Definition: Storage.hh:294
std::shared_ptr< SensorStore > SensorStorePtr
Definition: Storage.hh:357
Storage map from std::string to template class T.
Definition: Storage.hh:49
Multi-access storage structure of template class T. Template class T is expected to have functions Ge...
Definition: Storage.hh:114
CompositeStore< Node > NodeCompositeStore
Definition: Storage.hh:341
Store< Sensor > SensorStore
Definition: Storage.hh:321
Simple wrapper class that allows a Store of type Derived to be treated as a Store of type Base...
Definition: Storage.hh:291
std::shared_ptr< LightStore > LightStorePtr
Definition: Storage.hh:353