Ignition Rendering

API Reference

0.1.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>
30 #include "ignition/rendering/Export.hh"
31 
32 // An X11 header file defines a macro that conflicts with our function name,
33 // so undefine it here
34 #ifdef DestroyAll
35 #undef DestroyAll
36 #endif
37 
38 namespace ignition
39 {
40  namespace rendering
41  {
45  template <class T>
46  class IGNITION_RENDERING_VISIBLE Map
47  {
50  typedef std::shared_ptr<T> TPtr;
51 
55 
57  public: virtual ~Map() { }
58 
61  public: virtual unsigned int Size() const = 0;
62 
66  public: virtual bool ContainsKey(const std::string &_key) const = 0;
67 
71  public: virtual bool ContainsValue(ConstTPtr _value) const = 0;
72 
76  public: virtual TPtr Get(const std::string &_key) const = 0;
77 
81  public: virtual TPtr GetByIndex(unsigned int _index) const = 0;
82 
88  public: virtual bool Put(const std::string &_key, TPtr _value) = 0;
89 
93  public: virtual void Remove(const std::string &_key) = 0;
94 
98  public: virtual void Remove(TPtr _value) = 0;
99 
101  public: virtual void RemoveAll() = 0;
102  };
103 
110  template <class T>
111  class IGNITION_RENDERING_VISIBLE Store
112  {
115  typedef std::shared_ptr<T> TPtr;
116 
120 
122  public: virtual ~Store() { }
123 
126  public: virtual unsigned int Size() const = 0;
127 
131  public: virtual bool Contains(ConstTPtr _object) const = 0;
132 
136  public: virtual bool ContainsId(unsigned int _id) const = 0;
137 
141  public: virtual bool ContainsName(const std::string &_name) const = 0;
142 
146  public: virtual TPtr GetById(unsigned int _id) const = 0;
147 
151  public: virtual TPtr GetByName(const std::string &_name) const = 0;
152 
156  public: virtual TPtr GetByIndex(unsigned int _index) const = 0;
157 
163  public: virtual bool Add(TPtr _object) = 0;
164 
169  public: virtual TPtr Remove(TPtr _object) = 0;
170 
175  public: virtual TPtr RemoveById(unsigned int _id) = 0;
176 
181  public: virtual TPtr RemoveByName(const std::string &_name) = 0;
182 
187  public: virtual TPtr RemoveByIndex(unsigned int _index) = 0;
188 
190  public: virtual void RemoveAll() = 0;
191 
195  public: virtual void Destroy(TPtr _object) = 0;
196 
200  public: virtual void DestroyById(unsigned int _id) = 0;
201 
206  public: virtual void DestroyByName(const std::string &_name) = 0;
207 
212  public: virtual void DestroyByIndex(unsigned int _index) = 0;
213 
215  public: virtual void DestroyAll() = 0;
216  };
217 
223  template <class T>
224  class IGNITION_RENDERING_VISIBLE CompositeStore :
225  public Store<T>
226  {
229  typedef std::shared_ptr<T> TPtr;
230 
233  typedef Store<T> TStore;
234 
238 
242 
244  public: virtual ~CompositeStore() { }
245 
248  public: virtual unsigned int GetStoreCount() const = 0;
249 
253  public: virtual bool ContainsStore(ConstTStorePtr _store) const = 0;
254 
259  public: virtual bool AddStore(TStorePtr _store) = 0;
260 
265  public: virtual TStorePtr GetStore(unsigned int _index) const = 0;
266 
271  public: virtual TStorePtr RemoveStore(TStorePtr _store) = 0;
272 
277  public: virtual TStorePtr RemoveStore(unsigned int _index) = 0;
278  };
279 
287  template <class T, class U>
288  class IGNITION_RENDERING_VISIBLE StoreWrapper :
289  public Store<T>
290  {
291  public: virtual ~StoreWrapper() { }
292  };
293 
294  template class Store<Scene>;
295  template class Store<Node>;
296  template class Store<Light>;
297  template class Store<Sensor>;
298  template class Store<Visual>;
299  template class Store<Geometry>;
300  template class Store<SubMesh>;
301  template class Map<Material>;
302  template class CompositeStore<Node>;
303 
307 
311 
315 
319 
323 
327 
331 
335 
339 
343 
347 
351 
355 
359 
363 
367 
371 
375  }
376 }
377 #endif
Represents a collection of Store objects, collectively working as a single composite store...
Definition: Storage.hh:224
std::shared_ptr< NodeCompositeStore > NodeCompositeStorePtr
Definition: Storage.hh:374
Store< Geometry > GeometryStore
Definition: Storage.hh:326
std::shared_ptr< VisualStore > VisualStorePtr
Definition: Storage.hh:358
virtual ~CompositeStore()
Deconstructor.
Definition: Storage.hh:244
Store< Scene > SceneStore
Definition: Storage.hh:306
std::shared_ptr< NodeStore > NodeStorePtr
Definition: Storage.hh:346
virtual ~Store()
Deconstructor.
Definition: Storage.hh:122
std::shared_ptr< SubMeshStore > SubMeshStorePtr
Definition: Storage.hh:366
std::shared_ptr< GeometryStore > GeometryStorePtr
Definition: Storage.hh:362
Store< Visual > VisualStore
Definition: Storage.hh:322
Store< Light > LightStore
Definition: Storage.hh:314
virtual ~Map()
Deconstructor.
Definition: Storage.hh:57
Map< Material > MaterialMap
Definition: Storage.hh:334
std::shared_ptr< SceneStore > SceneStorePtr
Definition: Storage.hh:342
std::shared_ptr< MaterialMap > MaterialMapPtr
Definition: Storage.hh:370
STL class.
Store< SubMesh > SubMeshStore
Definition: Storage.hh:330
Store< Node > NodeStore
Definition: Storage.hh:310
virtual ~StoreWrapper()
Definition: Storage.hh:291
std::shared_ptr< SensorStore > SensorStorePtr
Definition: Storage.hh:354
Storage map from std::string to template class T.
Definition: Storage.hh:46
Multi-access storage structure of template class T. Template class T is expected to have functions Ge...
Definition: Storage.hh:111
CompositeStore< Node > NodeCompositeStore
Definition: Storage.hh:338
Store< Sensor > SensorStore
Definition: Storage.hh:318
Simple wrapper class that allows a Store of type Derived to be treated as a Store of type Base...
Definition: Storage.hh:288
Definition: ArrowVisual.hh:22
std::shared_ptr< LightStore > LightStorePtr
Definition: Storage.hh:350