• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NeonGE / geEngineSDK / 6df40300-503d-431f-87b0-40d5fc812173

05 Mar 2026 07:06PM UTC coverage: 57.896% (-0.01%) from 57.909%
6df40300-503d-431f-87b0-40d5fc812173

push

circleci

NeonGE
Make core classes final, modernize lambdas and destructors

Refactored several classes to be final and updated destructors to use override for safer inheritance. Switched event signal lambdas in main.cpp to non-capturing for improved safety and efficiency. Annotated ImGuiPlatform member with GE_NO_UNIQUE_ADDRESS for potential memory optimization. Used C++20 map contains in FileTracker for cleaner code. These changes enhance code safety, clarity, and performance.

Make classes final, clean up destructors, improve safety

Refactored several classes to be final and removed unnecessary virtual destructors, marking them override where appropriate. Updated event signal lambdas in main.cpp to be non-capturing for better performance and safety. Annotated ImGuiPlatform with GE_NO_UNIQUE_ADDRESS for potential memory optimizations. Switched to C++20 map contains in geFileTracker.h when available. In geFrameAlloc.cpp, allocation functions now safely return nullptr if m_freeBlock is null, improving robustness.

0 of 8 new or added lines in 4 files covered. (0.0%)

3 existing lines in 2 files now uncovered.

5613 of 9695 relevant lines covered (57.9%)

9099.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sdk/geCore/include/geFileTracker.h
1
/*****************************************************************************/
2
/**
3
 * @file    geFileWatcher.h
4
 * @author  Samuel Prince (samuel.prince.quezada@gmail.com)
5
 * @date    2025/06/26
6
 * @brief   File Watcher System.
7
 *
8
 * File Watcher System. This system is a subscription-based system that informs
9
 * the engine when a file is modified, created or deleted. It can be used to
10
 * automatically reload resources when they are modified.
11
 *
12
 * @bug            No known bugs.
13
 */
14
/*****************************************************************************/
15
#pragma once
16

17
/*****************************************************************************/
18
/**
19
 * Includes
20
 */
21
/*****************************************************************************/
22
#include "gePrerequisitesCore.h"
23

24
#include <geEvent.h>
25
#include <geModule.h>
26
#include <geStringID.h>
27
#include <geFileSystem.h>
28
#include <geDebug.h>
29

30
namespace geEngineSDK {
31

32
  using FILE_CHANGED_EVENT_CALLBACK = void(const PlatformString&);
33
  using ChangeCallback = Event<FILE_CHANGED_EVENT_CALLBACK>;
34

35
  struct TrackedFile
36
  {
37
    bool
38
    operator==(const TrackedFile& other) const {
×
39
      return m_systemID == other.m_systemID && m_filePath == other.m_filePath;
×
40
    }
41

42
    bool
43
    operator<(const TrackedFile& other) const {
44
      if (m_systemID < other.m_systemID) {
45
        return true;
46
      }
47
      if (m_systemID > other.m_systemID) {
48
        return false;
49
      }
50
      return m_filePath < other.m_filePath;
51
    }
52

53
    uint32 m_systemID = 0;          //ID of the system that is watching the file
54
    PlatformString m_filePath;      //Absolute path of the file being watched
55
    time_t m_lastModifiedTime = 0;  //Last modified time of the file
56
  };
57

58
  struct TrackedFileHash
59
  {
60
    std::size_t
61
    operator()(const TrackedFile& file) const _NOEXCEPT {
×
62
      return std::hash<uint32>()(file.m_systemID) ^
×
63
             std::hash<PlatformString>()(file.m_filePath);
×
64
    }
65
  };
66

67
  class GE_CORE_EXPORT FileTracker final : public Module<FileTracker>
68
  {
69
   public:
70
    FileTracker() = default;
×
NEW
71
    ~FileTracker() override = default;
×
72

73
    /**
74
     * @brief Start monitoring the files
75
     */
76
    void
77
    startWatching() {
78
      m_stopFlag = false;
79
      m_monitoringThread = Thread(&FileTracker::watchFiles, this);
80
    }
81

82
    /**
83
     * @brief Stop monitoring the files
84
     */
85
    void
86
    stopWatching() {
×
87
      m_stopFlag = true;
×
88
      if (m_monitoringThread.joinable()) {
×
89
        m_monitoringThread.join();
×
90
      }
91
    }
×
92

93
    /**
94
     * @brief Subscribe to file changes for a specific system
95
     * @param systemID ID of the system that is subscribing to file changes
96
     * @param callback Callback function to be called when a file change is detected
97
     */
98
    uint32
99
    subscribe(const String systemName, const ChangeCallback& callback) {
×
100
      uint32 systemID = StringID(systemName).id();
×
101

102
      ScopedLock<true> lock(m_dataMutex);
×
103
#if USING(GE_CPP20_OR_LATER)
NEW
104
      if(!m_subscribersCallbacks.contains(systemID)) {
×
105
#else
106
      if (m_subscribersCallbacks.find(systemID) == m_subscribersCallbacks.end()) {
107
#endif
UNCOV
108
        m_subscribersCallbacks[systemID] = callback;
×
109
      }
110

111
      return systemID;
×
112
    }
×
113

114
    /**
115
     * @brief Unsubscribe from file changes for a specific system
116
     * @param systemID ID of the system that is unsubscribing from file changes
117
     */
118
    void
119
    unsubscribe(const StringID systemID) {
120
      ScopedLock<true> lock(m_dataMutex);
121
      m_subscribersCallbacks.erase(systemID.id());
122
    }
123

124
    /**
125
     * @brief Add files to be watched
126
     * @param directory
127
     */
128
    void
129
    addFiles(const uint32 systemID, const Vector<Path>& newFiles);
130

131
    /**
132
     * @brief Add directories to be watched
133
     * @param directory
134
     */
135
    void
136
    clearFiles() {
×
137
      ScopedLock<true> lock(m_dataMutex);
×
138
      m_filesToWatch.clear();
×
139
    }
×
140

141
   protected:
142
    void
143
    onStartUp() override;
144

145
    void
146
    onShutDown() override;
147

148
   private:
149
    /**
150
     * @brief Thread function that watches the files
151
     */
152
    void
153
    watchFiles();
154

155
    UnorderedMap<uint32, ChangeCallback> m_subscribersCallbacks;
156
    UnorderedSet<TrackedFile, TrackedFileHash> m_filesToWatch;
157

158
    Thread m_monitoringThread;
159
    Mutex m_dataMutex;
160
    atomic<bool> m_stopFlag{ false };
161
  };
162

163
  GE_CORE_EXPORT FileTracker&
164
  g_fileWatcher();
165

166
  GE_LOG_CATEGORY(FileTracker, 500);
167
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc