diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ecb650c..2707f163 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,6 +258,7 @@ if(NOT DEFINED PYNGL_ONLY) ${CMAKE_SOURCE_DIR}/tests/MessageTests.cpp ${CMAKE_SOURCE_DIR}/tests/NGLStreamTest.cpp ${CMAKE_SOURCE_DIR}/tests/TextureTests.cpp + ${CMAKE_SOURCE_DIR}/tests/VAOFactoryTests.cpp ) add_compile_definitions(GLM_ENABLE_EXPERIMENTAL) diff --git a/include/ngl/VAOFactory.h b/include/ngl/VAOFactory.h index 1cb5a314..d037ba00 100644 --- a/include/ngl/VAOFactory.h +++ b/include/ngl/VAOFactory.h @@ -58,9 +58,11 @@ class NGL_DLLEXPORT VAOFactory //---------------------------------------------------------------------------------------------------------------------- /// @brief debug function to list all creators //---------------------------------------------------------------------------------------------------------------------- - static void listCreators(); + static void listCreators() noexcept; - private: + static size_t getNumCreators() noexcept {return m_vaoCreators.size();} + + private: //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- static std::unordered_map< std::string, std::function< std::unique_ptr< AbstractVAO >(GLenum _mode) > > m_vaoCreators; diff --git a/src/VAOFactory.cpp b/src/VAOFactory.cpp index e089ee41..000a550f 100644 --- a/src/VAOFactory.cpp +++ b/src/VAOFactory.cpp @@ -18,8 +18,8 @@ void VAOFactory::unregisterVAOCreator(std::string_view _type) std::unique_ptr< AbstractVAO > VAOFactory::createVAO(std::string_view _type, GLenum _mode) { - auto it = m_vaoCreators.find(_type.data()); - if(it != m_vaoCreators.end()) + + if(auto it = m_vaoCreators.find(_type.data()); it != m_vaoCreators.end()) { // call the creation callback to construct this derived type return it->second(_mode); @@ -27,7 +27,7 @@ std::unique_ptr< AbstractVAO > VAOFactory::createVAO(std::string_view _type, GLe return nullptr; } -void VAOFactory::listCreators() +void VAOFactory::listCreators() noexcept { NGLMessage::addMessage("******************************\n", Colours::WHITE, TimeFormat::NONE); NGLMessage::addMessage("VAOFactory Creators List ", Colours::WHITE, TimeFormat::NONE); diff --git a/tests/main.cpp b/tests/main.cpp index 7307d402..6deed068 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -87,7 +87,7 @@ int main(int argc, char **argv) if(useOpenGL == false) { std::cerr << "excluding tests\n"; - ::testing::GTEST_FLAG(filter) = "-ShaderLib.*:VAOPrimitives.*:NGLInit*"; + ::testing::GTEST_FLAG(filter) = "-ShaderLib.*:VAOPrimitives.*:NGLInit*:VAOFactory*"; } // testing::internal::CaptureStdout(); testing::internal::CaptureStderr();