LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
IModel.hpp
Go to the documentation of this file.
1#ifndef MVC_IMODEL_HPP
2#define MVC_IMODEL_HPP
3
4#include "LogEvent.hpp"
5#include "IView.hpp"
6
7#include <vector>
8
9namespace mvc
10{
12class IModel
13{
14 public:
15 IModel() = default;
16 virtual ~IModel() = default;
17
18 virtual void RegisterOndDataUpdated(IView* view)
19 {
20 m_views.push_back(view);
21 }
22
23 virtual void NotifyDataChanged()
24 {
25 for (auto* v : m_views)
26 if (v) [[likely]] v->OnDataUpdated();
27 }
28
29 virtual int GetCurrentItemIndex() = 0;
30 virtual void SetCurrentItem(int item) = 0;
31 virtual size_t Size() const = 0;
32 virtual void AddItem(db::LogEvent&& item) = 0;
33
34 [[nodiscard]] virtual db::LogEvent& GetItem(size_t index) = 0;
35 [[nodiscard]] virtual const db::LogEvent& GetItem(size_t index) const = 0;
36
37 virtual void Clear() = 0;
38
39 protected:
40 std::vector<IView*> m_views;
41};
42
43} // namespace mvc
44
45#endif // MVC_MODEL_HPP
Interface for view components in the MVC architecture.
Defines the LogEvent class for representing structured log entries.
Represents a single, structured log event with key-value data.
Definition LogEvent.hpp:97
Definition IModel.hpp:13
virtual void SetCurrentItem(int item)=0
virtual void RegisterOndDataUpdated(IView *view)
Definition IModel.hpp:18
virtual const db::LogEvent & GetItem(size_t index) const =0
virtual db::LogEvent & GetItem(size_t index)=0
std::vector< IView * > m_views
Definition IModel.hpp:40
virtual size_t Size() const =0
virtual int GetCurrentItemIndex()=0
IModel()=default
virtual void Clear()=0
virtual ~IModel()=default
virtual void AddItem(db::LogEvent &&item)=0
virtual void NotifyDataChanged()
Definition IModel.hpp:23
Interface for view components in the MVC architecture.
Definition IView.hpp:26
Definition IControler.hpp:27