LCOV - code coverage report
Current view: top level - src/core - context_builder.cpp (source / functions) Hit Total Coverage
Test: libopenmodelviewer coverage Lines: 25 25 100.0 %
Date: 2025-07-03 20:26:48 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //
       2             : // Copyright 2024 OpenModelViewer Authors
       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             : //     http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : //
      15             : 
      16             : #include "openmodelviewer/core/context_builder.hpp"
      17             : 
      18             : namespace openmodelviewer::core
      19             : {
      20           7 :     ContextBuilder ContextBuilder::make() noexcept
      21             :     {
      22           7 :         return ContextBuilder();
      23             :     }
      24             : 
      25           2 :     ContextBuilder& ContextBuilder::withLogger(std::shared_ptr<Logger> logger) noexcept
      26             :     {
      27           2 :         m_logger = std::move(logger);
      28           2 :         return *this;
      29             :     }
      30             : 
      31           1 :     ContextBuilder& ContextBuilder::withLogger(LogLevel level) noexcept
      32             :     {
      33           1 :         m_logger = std::make_shared<Logger>(level);
      34           1 :         return *this;
      35             :     }
      36             : 
      37           3 :     ContextBuilder& ContextBuilder::withScheduler(std::shared_ptr<TaskScheduler> scheduler) noexcept
      38             :     {
      39           3 :         m_scheduler = std::move(scheduler);
      40           3 :         return *this;
      41             :     }
      42             : 
      43           1 :     ContextBuilder& ContextBuilder::withScheduler(size_t threadCount) noexcept
      44             :     {
      45           1 :         m_scheduler = std::make_shared<TaskScheduler>(threadCount);
      46           1 :         return *this;
      47             :     }
      48             : 
      49           2 :     ContextBuilder& ContextBuilder::withResourceManager(std::shared_ptr<ResourceManager> resourceManager) noexcept
      50             :     {
      51           2 :         m_resource = std::move(resourceManager);
      52           2 :         return *this;
      53             :     }
      54             : 
      55           7 :     std::shared_ptr<Context> ContextBuilder::build() noexcept
      56             :     {
      57           7 :         if (!m_scheduler)
      58             :         {
      59           3 :             m_scheduler = std::make_shared<TaskScheduler>();
      60             :         }
      61             : 
      62           7 :         if (!m_logger)
      63             :         {
      64           4 :             m_logger = std::make_shared<Logger>();
      65             :         }
      66             : 
      67           7 :         if (!m_resource)
      68             :         {
      69           5 :             m_resource = std::make_shared<ResourceManager>(*m_scheduler);
      70             :         }
      71             : 
      72           7 :         return std::make_shared<Context>(std::move(m_logger), std::move(m_scheduler), std::move(m_resource));
      73             :     }
      74             : }

Generated by: LCOV version 1.14