Skip to content
Snippets Groups Projects
Commit 1f303325 authored by Vanessa Karolek's avatar Vanessa Karolek
Browse files

[#42] add throwing exception if input index is invalid

parent deb50349
No related branches found
No related tags found
1 merge request!35Resolve "Kamera - Trackballkamera"
...@@ -94,6 +94,9 @@ namespace vkcv{ ...@@ -94,6 +94,9 @@ namespace vkcv{
} }
Camera& CameraManager::getCamera(uint32_t cameraIndex) { Camera& CameraManager::getCamera(uint32_t cameraIndex) {
if (cameraIndex < 0 || cameraIndex > m_cameras.size() - 1) {
throw std::runtime_error("Invalid camera index.");
}
return m_cameras[cameraIndex]; return m_cameras[cameraIndex];
} }
...@@ -101,8 +104,10 @@ namespace vkcv{ ...@@ -101,8 +104,10 @@ namespace vkcv{
return m_cameras[getActiveCameraIndex()]; return m_cameras[getActiveCameraIndex()];
} }
void CameraManager::setActiveCamera(uint32_t cameraIndex) { void CameraManager::setActiveCamera(uint32_t cameraIndex) {
if (cameraIndex < 0 || cameraIndex > m_cameras.size() - 1) {
throw std::runtime_error("Invalid camera index.");
}
m_activeCameraIndex = cameraIndex; m_activeCameraIndex = cameraIndex;
} }
...@@ -111,10 +116,16 @@ namespace vkcv{ ...@@ -111,10 +116,16 @@ namespace vkcv{
} }
void CameraManager::setControllerType(uint32_t cameraIndex, ControllerType controllerType) { void CameraManager::setControllerType(uint32_t cameraIndex, ControllerType controllerType) {
if (cameraIndex < 0 || cameraIndex > m_cameras.size() - 1) {
throw std::runtime_error("Invalid camera index.");
}
m_cameraControllerTypes[cameraIndex] = controllerType; m_cameraControllerTypes[cameraIndex] = controllerType;
} }
ControllerType CameraManager::getControllerType(uint32_t cameraIndex) { ControllerType CameraManager::getControllerType(uint32_t cameraIndex) {
if (cameraIndex < 0 || cameraIndex > m_cameras.size() - 1) {
throw std::runtime_error("Invalid camera index.");
}
return m_cameraControllerTypes[cameraIndex]; return m_cameraControllerTypes[cameraIndex];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment