Radium Engine  1.5.0
DefaultCameraManager.cpp
1 #include <Engine/Scene/DefaultCameraManager.hpp>
2 
3 #include <Engine/RadiumEngine.hpp>
4 #include <Engine/Scene/CameraComponent.hpp>
5 
6 #include <algorithm>
7 
8 namespace Ra {
9 namespace Engine {
10 namespace Scene {
11 
12 DefaultCameraManager::DefaultCameraManager() {
13  m_data = std::make_unique<DefaultCameraStorage>();
14 }
15 
17  // return ( *m_data )[cam];
18  return ( *m_data )[cam];
19 }
20 
22  registerComponent( cam->getEntity(), cam );
23 }
24 
25 DefaultCameraStorage::DefaultCameraStorage() = default;
26 
28  // m_data.emplace( cam->getType(), cam );
29  m_data.push_back( cam );
30 }
31 
33  // auto range = m_data.equal_range( cam->getType() );
34  // for ( auto i = range.first; i != range.second; ++i )
35  // {
36  // if ( i->second == cam )
37  // {
38  // m_data.erase( i );
39  // break;
40  // }
41  // }
42  auto itr = std::find( m_data.begin(), m_data.end(), cam );
43  if ( itr != m_data.end() ) m_data.erase( itr );
44 }
45 
47  return m_data.size();
48 }
49 
51  m_data.clear();
52 }
53 
55 
56  // auto iterator = m_data.begin();
57  // std::advance( iterator, n );
58  // return iterator->second;
59  return m_data[n];
60 }
61 
62 } // namespace Scene
63 } // namespace Engine
64 } // namespace Ra
std::unique_ptr< CameraStorage > m_data
Stores the object that stores the Cameras...
void registerComponent(const Entity *entity, Component *component) final
virtual Entity * getEntity() const
Return the entity the component belongs to.
Definition: Component.hpp:53
const CameraComponent * getCamera(size_t cam) const override
Return the cam-th camera.
void addCamera(CameraComponent *cam) override
Add cam for management.
void clear() override
Clear the container.
size_t size() const override
Returns the container size.
void remove(CameraComponent *cam) override
Remove a Camera from the container.
void add(CameraComponent *cam) override
Add a Camera to the container.
CameraComponent * operator[](unsigned int n) override
Access the container.
Definition: Cage.cpp:3