NDEVR
API Documentation
DesignTask.h
1#pragma once
2#include <NDEVR/UUID.h>
3#include <NDEVR/TranslatedString.h>
4namespace NDEVR
5{
11 {
15 fltp08 progress = Constant<fltp08>::Invalid;
17 bool allow_import_file = false;
18 bool allow_open_project = false;
19 bool is_active = false;
22 : id(UUID::CreateUUID())
23 {}
24 };
25
29 {
30 public:
33 virtual bool canExitApplication() const
34 {
35 RLock lock(&m_tasks);
36 for (const auto& iter : m_tasks)
37 {
38 if (iter.second.is_active && !iter.second.allow_application_close)
39 return false;
40 }
41 return true;
42 }
43
45 virtual bool canOpenProject() const
46 {
47 RLock lock(&m_tasks);
48 for (const auto& iter : m_tasks)
49 {
50 if (iter.second.is_active && !iter.second.allow_open_project)
51 return false;
52 }
53 return true;
54 }
55
57 virtual bool canImportFile() const
58 {
59 RLock lock(&m_tasks);
60 for (const auto& iter : m_tasks)
61 {
62 if (iter.second.is_active && !iter.second.allow_import_file)
63 return false;
64 }
65 return true;
66 }
67
69 virtual void addTask(const DesignTask& task)
70 {
71 WLock lock(&m_tasks);
72 m_tasks[task.id] = task;
73 }
74
76 virtual void updateTask(const DesignTask& task)
77 {
78 WLock lock(&m_tasks);
79 m_tasks[task.id] = task;
80 }
81
83 virtual void removeTask(const UUID& id)
84 {
85 WLock lock(&m_tasks);
86 m_tasks.erase(id);
87 }
88
91 DesignTask task(const UUID& id) const
92 {
93 RLock lock(&m_tasks);
94 return m_tasks[id];
95 }
97 };
98}
Manages all active and inactive tasks for a DesignObjectLookup.
Definition DesignTask.h:29
virtual void removeTask(const UUID &id)
Removes a task from the manager by its UUID.
Definition DesignTask.h:83
virtual bool canImportFile() const
Checks whether importing a file is allowed based on active tasks.
Definition DesignTask.h:57
virtual void updateTask(const DesignTask &task)
Updates an existing task in the manager, replacing it by its UUID.
Definition DesignTask.h:76
DesignTask task(const UUID &id) const
Retrieves a copy of a task by its UUID.
Definition DesignTask.h:91
Dictionary< UUID, DesignTask > m_tasks
Thread-safe dictionary of all managed tasks, keyed by UUID.
Definition DesignTask.h:96
virtual bool canOpenProject() const
Checks whether opening a project is allowed based on active tasks.
Definition DesignTask.h:45
virtual bool canExitApplication() const
Checks whether the application is allowed to exit based on active tasks.
Definition DesignTask.h:33
virtual void addTask(const DesignTask &task)
Adds a new task to the manager.
Definition DesignTask.h:69
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Used to lock a particular variable for reading.
Definition RWLock.h:157
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
Used to lock a particular variable for writing.
Definition RWLock.h:272
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.
A task which is to be executed by a DesignObjectLookup.
Definition DesignTask.h:11
fltp08 progress
Current progress of the task (Invalid when indeterminate).
Definition DesignTask.h:15
bool allow_application_close
Whether the application may close while this task is active.
Definition DesignTask.h:16
bool allow_open_project
Whether opening a project is permitted while this task is active.
Definition DesignTask.h:18
bool is_active
Whether this task is currently active.
Definition DesignTask.h:19
TranslatedString name
Display name of the task.
Definition DesignTask.h:13
TranslatedString description
Detailed description of the task.
Definition DesignTask.h:14
UUID id
Unique identifier for this task.
Definition DesignTask.h:12
bool allow_import_file
Whether file imports are permitted while this task is active.
Definition DesignTask.h:17
DesignTask()
Constructs a DesignTask with a newly generated UUID.
Definition DesignTask.h:21