DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExpCore.cpp
Go to the documentation of this file.
1 // This file is part of DynExp.
2 
3 #include "stdafx.h"
4 #include "DynExpCore.h"
5 
6 namespace DynExp
7 {
9  {
11  { "Store in project file and apply from file", ProjectParams::StoreWindowStatesType::ApplyStoredWindowStates },
12  { "Don't store in project file but apply defaults", ProjectParams::StoreWindowStatesType::ApplyDefaultWindowStates }
13  };
14 
15  return List;
16  }
17 
19  {
21  }
22 
24  ModuleLibraryVectorType ModuleLib, std::string ProjectFileToOpen)
25  : HardwareAdapterLib(std::move(HardwareAdapterLib)), InstrumentLib(std::move(InstrumentLib)),
26  ModuleLib(std::move(ModuleLib)),
27  Params(std::make_unique<ProjectParams>(*this)), OwnerThreadID(std::this_thread::get_id())
28  {
29  // Init Util::QWorker by setting its internal pointer to this DynExpCore instance.
31 
32  // Start WorkerThread (see DynExpCore.h).
33  WorkerThread.start();
34 
35  Util::EventLog().OpenLogFile("DynExp.html");
36  Util::EventLog().Log("Welcome to DynExp " + std::string(DynExpVersion) + ".");
37 
38 #ifdef DYNEXP_DEBUG
39  Util::EventLog().Log("DynExp was compiled in DEBUG mode and might thus run slowly.");
40 #endif // DYNEXP_DEBUG
41 
42  OpenProjectSafe(ProjectFileToOpen);
43  }
44 
46  {
47  Util::EventLog().Log("DynExp shut down successfully.");
48  }
49 
51  {
52  WorkerThread.quit();
53 
54  if (!WorkerThread.wait(std::chrono::milliseconds(3000)))
56  }
57 
58  void DynExpCore::Reset(bool Force)
59  {
60  // Calls to PrepareReset() and Reset() must be performed in this order to ensure that
61  // all objects making use of another object are destroyed first in case of reset.
62 
63  if (!Force)
64  {
68  }
69 
70  ModuleMgr.Reset();
73 
74  GetParams()->ProjectFilename.clear();
75  Params = std::make_unique<ProjectParams>(*this);
76 
77  if (!Force)
78  Util::EventLog().Log("Set up new project successfully.");
79  }
80 
81  void DynExpCore::SaveProject(std::string_view Filename, const QMainWindow& MainWindow, const QDialog& CircuitDiagramDlg, QSplitter& HSplitter, QSplitter& VSplitter)
82  {
83  QDomDocument Document;
84  Document.appendChild(Document.createProcessingInstruction("xml", "version=\"1.0\" standalone=\"yes\""));
85  QDomElement RootNode = Document.createElement("DynExp");
86  RootNode.setAttribute("DynExpVersion", DynExp::DynExpVersion);
87  QDomElement ProjectNode = Document.createElement("Project");
88 
89  UpdateParamsFromWindowStates(MainWindow, CircuitDiagramDlg, HSplitter, VSplitter);
90  QDomElement ParamsNode = Document.createElement("Params");
91  ParamsNode.appendChild(GetParams()->ConfigToXML(Document));
92  ProjectNode.appendChild(ParamsNode);
93 
94  ProjectNode.appendChild(HardwareAdapterMgr.EntryConfigsToXML(Document));
95  ProjectNode.appendChild(InstrumentMgr.EntryConfigsToXML(Document));
96  ProjectNode.appendChild(ModuleMgr.EntryConfigsToXML(Document));
97 
98  RootNode.appendChild(ProjectNode);
99  Document.appendChild(RootNode);
100 
101  auto DocumentString = Document.toString().toStdString();
102 
103  std::ofstream File;
104  File.exceptions(std::ofstream::failbit | std::ofstream::badbit);
105  File.open(std::string(Filename), std::ofstream::out | std::ofstream::trunc);
106  File.write(DocumentString.c_str(), DocumentString.length());
107  File.close();
108 
109  GetParams()->ProjectFilename = Filename;
110 
111  Util::EventLog().Log(std::string("Saved project successfully to ").append(Filename) + ".");
112  }
113 
114  void DynExpCore::OpenProject(std::string_view Filename)
115  {
116  std::ifstream File;
117  std::string Contents;
118  File.exceptions(std::ifstream::failbit | std::ifstream::badbit);
119  File.open(std::string(Filename), std::ifstream::in | std::ifstream::binary);
120  File.seekg(0, std::ios::end);
121  Contents.resize(File.tellg());
122  File.seekg(0, std::ios::beg);
123  File.read(&Contents[0], Contents.size());
124  File.close();
125 
126  QDomDocument Document;
127  QString ErrorMsg;
128  int Line = 0, Column = 0;
129  if (!Document.setContent(QString::fromStdString(Contents), false, &ErrorMsg, &Line, &Column))
130  throw Util::InvalidDataException("Error parsing the specified project file at line "
131  + Util::ToStr(Line) + ", column " + Util::ToStr(Column) + ": " + ErrorMsg.toStdString());
132 
133  auto RootNode = Document.documentElement();
134  auto ProjectNode = Util::GetSingleChildDOMElement(RootNode, "Project");
135  auto Version = Util::VersionFromString(Util::GetStringFromDOMAttribute(RootNode, "DynExpVersion"));
136 
137  if (Version > Util::VersionType{0, 2})
138  {
139  auto ParamsNode = Util::GetSingleChildDOMElement(ProjectNode, "Params");
140  GetParams()->ConfigFromXML(ParamsNode);
141  }
142 
143  auto HardwareAdapterNode = Util::GetSingleChildDOMElement(ProjectNode, "HardwareAdapters");
144  auto InstrumentNode = Util::GetSingleChildDOMElement(ProjectNode, "Instruments");
145  auto ModuleNode = Util::GetSingleChildDOMElement(ProjectNode, "Modules");
146 
147  HardwareAdapterMgr.MakeEntriesFromXML(HardwareAdapterNode, HardwareAdapterLib, *this);
148  InstrumentMgr.MakeEntriesFromXML(InstrumentNode, InstrumentLib, *this);
149  ModuleMgr.MakeEntriesFromXML(ModuleNode, ModuleLib, *this);
150 
151  GetParams()->ProjectFilename = Filename;
152 
153  Util::EventLog().Log(std::string("Loaded project from ").append(Filename) + " successfully.");
154  }
155 
156  void DynExpCore::EditProjectSettings(QWidget* const DialogParent)
157  {
158  auto ConfigDlg = std::make_unique<ParamsConfigDialog>(DialogParent, *this, "Project settings");
159 
160  GetParams()->ConfigFromDialog(*ConfigDlg);
161  ConfigDlg->Display();
162  }
163 
165  {
167  }
168 
170  {
171  return InstrumentMgr.AllInitialized();
172  }
173 
175  {
176  InstrumentMgr.Startup(FunctionToCallWhenInstrumentStarted);
177  }
178 
180  {
181  ModuleMgr.Startup(FunctionToCallWhenModuleStarted);
182  }
183 
185  {
188  }
189 
190  void DynExpCore::ResetFailedItems(QWidget& ParentWindow)
191  {
194 
197 
198  auto FailedAndUsedHardwareAdapters = HardwareAdapterMgr.GetFailedResourceIDs(true);
199  ItemIDListType InstrumentsToRestart;
200  for (const auto AdapterID : FailedAndUsedHardwareAdapters)
201  {
202  auto Users = HardwareAdapterMgr.GetResource(AdapterID)->GetUserIDs();
203  InstrumentsToRestart.insert(InstrumentsToRestart.cend(), Users.cbegin(), Users.cend());
204  }
205 
206  if (!InstrumentsToRestart.empty())
207  {
208  std::string InstrumentsToRestartNames("The following instruments will be stopped and restarted:");
209  for (const auto InstrID : InstrumentsToRestart)
210  {
211  auto Instr = InstrumentMgr.GetResource(InstrID);
212  InstrumentsToRestartNames += "\n- " + Instr->GetObjectName() + " (" + Instr->GetCategoryAndName() + ")";
213  }
214  InstrumentsToRestartNames += "\n\nDo you wish to continue?";
215  if (QMessageBox::question(&ParentWindow, "DynExp - Restart instruments?", QString::fromStdString(InstrumentsToRestartNames),
216  QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::No)
217  != QMessageBox::StandardButton::Yes)
218  return;
219  }
220 
221  for (const auto InstrID : InstrumentsToRestart)
222  InstrumentMgr.GetResource(InstrID)->Terminate(true);
223 
226 
227  for (const auto InstrID : InstrumentsToRestart)
228  dynamic_cast<RunnableObject&>(*InstrumentMgr.GetResource(InstrID)).Run(&ParentWindow);
229  }
230 
231  void DynExpCore::RestoreWindowStatesFromParams(QMainWindow& MainWindow, QDialog& CircuitDiagramDlg, QSplitter& HSplitter, QSplitter& VSplitter,
232  bool OnlyMainWindow)
233  {
234  {
235  auto Params = GetParams();
236 
237  if (Params->StoreWindowStates != ProjectParams::StoreWindowStatesType::ApplyStoredWindowStates)
238  return;
239 
240  Params->MainWindowStyleParams.ApplyTo(MainWindow);
241  Params->CircuitWindowStyleParams.ApplyTo(CircuitDiagramDlg,
242  Params->CircuitWindowStyleParams.WindowDockingState == WindowStyleParamsExtension::WindowDockingStateType::Undocked);
243  if (Params->CircuitWindowStyleParams.WindowDockingState == WindowStyleParamsExtension::WindowDockingStateType::Docked)
244  CircuitDiagramDlg.hide();
245 
246  if (Params->HSplitterWidgetWidths.Get().size() >= Util::NumToT<size_t>(HSplitter.sizes().size()))
247  HSplitter.setSizes(QList<int>::fromVector(QVector<int>(Params->HSplitterWidgetWidths.Get().cbegin(), Params->HSplitterWidgetWidths.Get().cend())));
248  if (Params->VSplitterWidgetHeights.Get().size() >= Util::NumToT<size_t>(VSplitter.sizes().size()))
249  VSplitter.setSizes(QList<int>::fromVector(QVector<int>(Params->VSplitterWidgetHeights.Get().cbegin(), Params->VSplitterWidgetHeights.Get().cend())));
250  } // Params unlocked here.
251 
252  if (!OnlyMainWindow)
254  }
255 
257  {
258  return MakeItem(LibEntry, std::move(Params), GetHardwareAdapterManager(), "Hardware adapter");
259  }
260 
262  {
263  return MakeItem(LibEntry, std::move(Params), GetInstrumentManager(), "Instrument");
264  }
265 
267  {
268  return MakeItem(LibEntry, std::move(Params), GetModuleManager(), "Module");
269  }
270 
272  {
273  bool LoadedProjectFromCommandlineParamsCopy = LoadedProjectFromCommandlineParams;
275 
276  return LoadedProjectFromCommandlineParamsCopy;
277  }
278 
279  std::filesystem::path DynExpCore::ToAbsolutePath(const std::filesystem::path& Path) const
280  {
281  return (Path.is_relative() && !Path.empty()) ?
282  (GetProjectFilename().remove_filename() / Path) : Path;
283  }
284 
286  {
288  }
289 
291  {
292  Worker.moveToThread(&WorkerThread);
293  QObject::connect(&WorkerThread, &QThread::finished, &Worker, &QObject::deleteLater);
294 
295  Worker.SetOwner(std::weak_ptr(GetHardwareAdapterManager().ShareResource(ID)));
296  }
297 
298  std::string DynExpCore::GetDataSaveDirectory(const std::chrono::milliseconds Timeout) const
299  {
300  auto LastDataSaveDirectory = GetLastDataSaveDirectory(Timeout);
301  if (!LastDataSaveDirectory.empty() && std::filesystem::exists(LastDataSaveDirectory))
302  return LastDataSaveDirectory.string();
303 
304  auto ProjectFilename = GetProjectFilename(Timeout);
305  return ProjectFilename.empty() ? "" : ProjectFilename.parent_path().string();
306  }
307 
308  void DynExpCore::SetDataSaveDirectory(const std::filesystem::path& Directory, const std::chrono::milliseconds Timeout)
309  {
310  GetParams(Timeout)->LastDataSaveDirectory = Directory.parent_path();
311  }
312 
313  bool DynExpCore::OpenProjectSafe(const std::string& Filename) noexcept
314  {
315  if (Filename.empty())
316  return false;
317 
318  std::string ErrorMessage = "";
319  try
320  {
321  OpenProject(Filename);
322  }
323  catch (const std::exception& e)
324  {
325  ErrorMessage = e.what();
326  }
327  catch (...)
328  {
329  ErrorMessage = "Unknown Error";
330  }
331 
332  if (!ErrorMessage.empty())
333  {
334  Util::EventLog().Log("Opening a project from file " + Filename + ", the following error occurred: " + ErrorMessage,
336 
337  try
338  {
339  // If this throws, something went terribly wrong. Terminate application.
340  Reset(true);
341  }
342  catch (...)
343  {
344  Util::EventLog().Log("Error occurred while resetting project. Execution cannot continue.",
346 
347  std::terminate();
348  }
349 
350  return false;
351  }
352 
353  return true;
354  }
355 
357  {
358  return ParamsTypeSyncPtrType(Params.get(), Timeout);
359  }
360 
361  void DynExpCore::UpdateParamsFromWindowStates(const QMainWindow& MainWindow, const QDialog& CircuitDiagramDlg, QSplitter& HSplitter, QSplitter& VSplitter)
362  {
363  {
364  auto Params = GetParams();
365 
366  if (Params->StoreWindowStates != ProjectParams::StoreWindowStatesType::ApplyStoredWindowStates)
367  return;
368 
369  Params->MainWindowStyleParams.FromWidget(MainWindow);
370  Params->CircuitWindowStyleParams.FromWidget(CircuitDiagramDlg);
371  Params->CircuitWindowStyleParams.WindowDockingState = CircuitDiagramDlg.isVisible() ?
372  WindowStyleParamsExtension::WindowDockingStateType::Undocked : WindowStyleParamsExtension::WindowDockingStateType::Docked;
373 
374  const auto HSplitterSizes = HSplitter.sizes().toVector();
375  const auto VSplitterSizes = VSplitter.sizes().toVector();
376  Params->HSplitterWidgetWidths = std::vector<int>(HSplitterSizes.cbegin(), HSplitterSizes.cend());
377  Params->VSplitterWidgetHeights = std::vector<int>(VSplitterSizes.cbegin(), VSplitterSizes.cend());
378  } // Params unlocked here.
379 
381  }
382 }
Defines DynExp's core module as an interface between the UI and DynExp objects.
const std::function< void(Object *const)> FunctionToCallWhenObjectStartedType
Type of a callback function to invoke after a resource has been started in a call to ResourceManagerB...
Definition: Managers.h:65
std::unique_ptr< ProjectParams > Params
Project parameters (configuration) of the current DynExp project. Must never be nullptr.
Definition: DynExpCore.h:465
DynExpCore(HardwareAdapterLibraryVectorType HardwareAdapterLib, InstrumentLibraryVectorType InstrumentLib, ModuleLibraryVectorType ModuleLib, std::string ProjectFileToOpen="")
Constructs a DynExpCore instance.
Definition: DynExpCore.cpp:23
void SaveProject(std::string_view Filename, const QMainWindow &MainWindow, const QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter)
Saves the current DynExp project to an XML project file.
Definition: DynExpCore.cpp:81
void ShutdownProject()
Terminates all running instruments and modules.
Definition: DynExpCore.cpp:184
bool AllInstrumentsInitialized() const
Checks whether all instruments contained in InstrumentMgr have been initialized successfully.
Definition: DynExpCore.cpp:169
auto & GetModuleManager() noexcept
Getter for the module manager.
Definition: DynExpCore.h:293
void OpenProject(std::string_view Filename)
Loads a DynExp project from an XML project file.
Definition: DynExpCore.cpp:114
bool LoadedProjectFromCommandlineParams
This flag will be set to true if DynExpCore has been initialized with a path to a project file to loa...
Definition: DynExpCore.h:460
bool OpenProjectSafe(const std::string &Filename) noexcept
Calls OpenProject() and performs error handling for that function.
Definition: DynExpCore.cpp:313
HardwareAdapterManager HardwareAdapterMgr
Hardware adapter manager owning all instantiated hardware adapters.
Definition: DynExpCore.h:451
const HardwareAdapterLibraryVectorType HardwareAdapterLib
Hardware adapter library vector containing information about all hardware adapters DynExp knows.
Definition: DynExpCore.h:441
auto & GetHardwareAdapterManager() noexcept
Getter for the hardware adapter manager.
Definition: DynExpCore.h:281
void EditProjectSettings(QWidget *const DialogParent)
Opens a settings dialog (ParamsConfigDialog) to let the user configure the parameter values of the cu...
Definition: DynExpCore.cpp:156
void RestoreWindowStatesFromParams(QMainWindow &MainWindow, QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter, bool OnlyMainWindow=false)
Sets module and main windows' positions, sizes and styles according to parameters stored in the curre...
Definition: DynExpCore.cpp:231
QThread WorkerThread
One worker thread runs the Qt event queues for all objects derived from Util::QWorker (e....
Definition: DynExpCore.h:484
auto & GetInstrumentManager() noexcept
Getter for the instrument manager.
Definition: DynExpCore.h:287
void Reset(bool Force=false)
Resets the currently loaded project removing all resources from the resource managers....
Definition: DynExpCore.cpp:58
bool HasLoadedProjectFromCommandlineParams() noexcept
Indicates whether a DynExp project has been loaded from a path specified as a command line argument w...
Definition: DynExpCore.cpp:271
ModuleManager ModuleMgr
Module manager owning all instantiated modules.
Definition: DynExpCore.h:453
const InstrumentLibraryVectorType InstrumentLib
Instrument library vector containing information about all instruments DynExp knows.
Definition: DynExpCore.h:442
void MoveQWorkerToWorkerThread(Util::QWorker &Worker, ItemIDType ID) const
Moves a Util::QWorker instance to WorkerThread to run its Qt event queue there. This method is thread...
Definition: DynExpCore.cpp:290
void SetDataSaveDirectory(const std::filesystem::path &Directory, const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault)
Sets a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to st...
Definition: DynExpCore.cpp:308
const ModuleLibraryVectorType ModuleLib
Module library vector containing information about all modules DynExp knows.
Definition: DynExpCore.h:443
auto GetLastDataSaveDirectory(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Locks Params and returns the path to a directory where modules can save data.
Definition: DynExpCore.h:347
auto GetProjectFilename(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Locks Params and returns the current DynExp project's filename.
Definition: DynExpCore.h:340
void RunModules(CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenModuleStarted=nullptr)
Runs all modules contained in ModuleMgr with RunnableObjectParams::StartupType::OnCreation startup se...
Definition: DynExpCore.cpp:179
ParamsConstTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Locks the mutex of the parameter class instance Params assigned to the current project and returns a ...
Definition: DynExpCore.cpp:285
void UpdateParamsFromWindowStates(const QMainWindow &MainWindow, const QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter)
Retrieves the module and main windows' positions, sizes and styles from the windows and updates the p...
Definition: DynExpCore.cpp:361
InstrumentManager InstrumentMgr
Instrument manager owning all instantiated instruments.
Definition: DynExpCore.h:452
void RunInstruments(CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenInstrumentStarted=nullptr)
Runs all instruments contained in InstrumentMgr with RunnableObjectParams::StartupType::OnCreation st...
Definition: DynExpCore.cpp:174
ItemIDType MakeItem(const LibraryEntry< HardwareAdapterPtrType > &LibEntry, ParamsBasePtrType &&Params)
Creates a DynExp::HardwareAdapterBase instance from a LibraryEntry.
Definition: DynExpCore.cpp:256
bool AllHardwareAdaptersConnected() const
Checks whether all hardware adapters contained in HardwareAdapterMgr have been connected successfully...
Definition: DynExpCore.cpp:164
Util::SynchronizedPointer< const ProjectParams > ParamsConstTypeSyncPtrType
Alias for the return type of DynExpCore::GetParams() const. Parameters wrapped into Util::Synchronize...
Definition: DynExpCore.h:139
void ResetFailedItems(QWidget &ParentWindow)
Calls Object::Reset() and Object::ClearWarning() on all owned DynExp::Object instances which are in a...
Definition: DynExpCore.cpp:190
std::string GetDataSaveDirectory(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Recalls a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to...
Definition: DynExpCore.cpp:298
std::filesystem::path ToAbsolutePath(const std::filesystem::path &Path) const
Transforms the path Path into an absolute path relative to ProjectParams::ProjectFilename.
Definition: DynExpCore.cpp:279
Util::SynchronizedPointer< ProjectParams > ParamsTypeSyncPtrType
Alias for the return type of DynExpCore::GetParams(). Parameters wrapped into Util::SynchronizedPoint...
Definition: DynExpCore.h:133
void Shutdown()
Terminates DynExpCore::WorkerThread and waits until the thread has ended.
Definition: DynExpCore.cpp:50
bool AllConnected() const
Determines whether all hardware adapters managed by this resource manager are connected....
Definition: Managers.cpp:14
bool AllInitialized() const
Determines whether all instruments managed by this resource manager are initialized....
Definition: Managers.cpp:68
void RestoreWindowStatesFromParams() const
Calls ModuleBase::RestoreWindowStatesFromParams() on all modules managed by this resource manager....
Definition: Managers.cpp:114
void UpdateParamsFromWindowStates() const
Calls ModuleBase::UpdateParamsFromWindowStates() on all modules managed by this resource manager....
Definition: Managers.cpp:119
Param< UsageType > Usage
Determines whether an object can be used by only one other ("unique") or by multiple other ("shared")...
Definition: Object.h:1725
static void DisableUserEditable(ParamBase &Param) noexcept
Sets the UserEditable property of the parameter Param to false. Refer to ParamBase::UserEditable.
Definition: Object.cpp:292
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Definition: Object.h:349
Defines a parameter class with parameters common to all DynExp projects.
Definition: DynExpCore.h:25
static Util::TextValueListType< StoreWindowStatesType > AvlblStoreWindowStatesTypeStrList()
Assigns labels to the entries of StoreWindowStatesType.
Definition: DynExpCore.cpp:8
void ConfigureParamsImpl(dispatch_tag< ParamsBase >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition: DynExpCore.cpp:18
void Reset()
Resets the resource manager by calling ResetChild(), by removing all resources from Map and by resett...
Definition: Managers.h:517
void ClearResourcesWarnings() const
Calls Object::ClearWarning() on all resources stored in this resource manager.
Definition: Managers.h:487
void ResetFailedResources() const
Calls Object::Reset() on all resources stored in this resource manager which are in an error state (d...
Definition: Managers.h:508
const PointerType::element_type * GetResource(ItemIDType ID) const
Retrieves a resource specified by its ID from the resource manager.
Definition: Managers.h:394
void MakeEntriesFromXML(const QDomElement &XMLNode, const LibraryVectorT &Library, const DynExpCore &Core)
Creates resources and takes ownership of them according to an XML tree from a DynExp project XML file...
Definition: Managers.h:555
void Shutdown() const
Calls ShutdownChild() to terminate and clean up all resources stored in this resource manager.
Definition: Managers.h:255
void PrepareReset()
Prepares all resources stored in this resource manager for their deletion by e.g. asking them to term...
Definition: Managers.h:283
ItemIDListType GetFailedResourceIDs(bool OnlyResourcesBeingInUse=false) const
Builds and returns a list of the IDs of all resources stored in this resource manager which are in an...
Definition: Managers.h:495
void Startup(FunctionToCallWhenObjectStartedType FunctionToCallWhenObjectStarted) const
Starts all resources owned by the resource manager. For HardwareAdapterBase instances,...
Definition: Managers.h:250
QDomElement EntryConfigsToXML(QDomDocument &Document) const
Creates and returns the XML tree containing the configuration of each resource owned by this resource...
Definition: Managers.h:526
Defines an Object which possesses a thread it runs in. The RunnableObject can be started and stopped ...
Definition: Object.h:2426
void Log(const std::string &Message, const ErrorType Type=ErrorType::Info, const size_t Line=0, const std::string &Function="", const std::string &File="", const int ErrorCode=0, const std::stacktrace &Trace={}) noexcept
Logs an event from information specified manually.
Definition: Util.cpp:309
void OpenLogFile(std::string Filename)
Opens the HTML log file on disk. If it already exists, the file gets overwritten.
Definition: Util.cpp:446
Data to operate on is invalid for a specific purpose. This indicates a corrupted data structure or fu...
Definition: Exception.h:163
Implements a QObject belonging to a hardware adapter (derived from DynExp::HardwareAdapterBase) that ...
Definition: QtUtil.h:327
static const DynExp::DynExpCore & GetDynExpCore(const DynExp::DynExpCore *DynExpCore=nullptr)
Returns the application's DynExp::DynExpCore instance which is globally set in constructor DynExp::Dy...
Definition: QtUtil.cpp:281
void SetOwner(OwnerPtrType Owner) noexcept
Sets the hardware adapter owning this worker instance.
Definition: QtUtil.h:368
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition: Util.h:170
Thrown in a multi-threading context when an answer is expected from another thread an when the commun...
Definition: Exception.h:274
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
std::vector< ItemIDType > ItemIDListType
Type of a list of IDs belonging to objects managed by DynExp.
Definition: Object.h:40
std::vector< LibraryEntry< InstrumentPtrType > > InstrumentLibraryVectorType
Alias for the vector type containing entries of a instrument library.
Definition: Libraries.h:225
std::vector< LibraryEntry< HardwareAdapterPtrType > > HardwareAdapterLibraryVectorType
Alias for the vector type containing entries of a hardware adapter library.
Definition: Libraries.h:204
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Definition: Object.h:1807
size_t ItemIDType
ID type of objects/items managed by DynExp.
std::vector< LibraryEntry< ModulePtrType > > ModuleLibraryVectorType
Alias for the vector type containing entries of a module library.
Definition: Libraries.h:246
constexpr auto DynExpVersion
DynExp's version string
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
Definition: Util.h:625
QDomElement GetSingleChildDOMElement(const QDomElement &Parent, const QString &ChildTagName)
Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element.
Definition: QtUtil.cpp:62
VersionType VersionFromString(std::string_view Str)
Extracts a program version from a string.
Definition: Util.cpp:162
EventLogger & EventLog()
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one...
Definition: Util.cpp:509
std::vector< std::pair< TextType, ValueType > > TextValueListType
Type of a list containing key-value pairs where key is a text of type Util::TextType.
Definition: QtUtil.h:37
std::string GetStringFromDOMAttribute(const QDomElement &Element, const QString &AttributeName)
Behaves like GetDOMAttribute() but returns the text from the attribute.
Definition: QtUtil.cpp:99
Data type describing DynExp's program version in the form Major.Minor.Patch.
Definition: Util.h:859
Accumulates include statements to provide a precompiled header.
Represents an entry in the library.
Definition: Libraries.h:75