Skip to content
Snippets Groups Projects
Commit 7bbfad7c authored by t.knopff's avatar t.knopff
Browse files

Merge commit '57dc92e0' into reorg_dirs

parents 7230dc23 57dc92e0
No related branches found
No related tags found
1 merge request!98Reorg dirs: disentangle Models from mainwindow
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/mainwindow/AppSvc.cpp
//! @brief Implements class AppSvc
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/mainwindow/AppSvc.h"
#include "GUI/Models/Error.h"
ProjectManager* AppSvc::projectManager()
{
return instance().this_projectManager();
}
void AppSvc::subscribe(ProjectManager* projectManager)
{
return instance().this_subscribe(projectManager);
}
void AppSvc::unsubscribe(ProjectManager* projectManager)
{
instance().this_unsubscribe(projectManager);
}
MaterialModel* AppSvc::materialModel()
{
return instance().this_materialModel();
}
void AppSvc::subscribe(MaterialModel* materialModel)
{
return instance().this_subscribe(materialModel);
}
void AppSvc::unsubscribe(MaterialModel* materialModel)
{
instance().this_unsubscribe(materialModel);
}
AppSvc::AppSvc() : m_projectManager(nullptr), m_materialModel(nullptr) {}
ProjectManager* AppSvc::this_projectManager()
{
if (!m_projectManager)
throw Error("AppSvc::projectManager() -> Error. Attempt to access "
"non existing ProjectManager.");
return m_projectManager;
}
MaterialModel* AppSvc::this_materialModel()
{
return m_materialModel;
}
void AppSvc::this_subscribe(ProjectManager* projectManager)
{
if (m_projectManager != nullptr)
throw Error("AppSvc::projectManager() -> Error. Attempt to subscribe "
"ProjectManager twice.");
m_projectManager = projectManager;
}
void AppSvc::this_unsubscribe(ProjectManager* projectManager)
{
if (m_projectManager != projectManager)
throw Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe "
"ProjectManager before it was subscribed.");
m_projectManager = nullptr;
}
void AppSvc::this_subscribe(MaterialModel* materialModel)
{
if (m_materialModel)
throw Error("AppSvc::projectManager() -> Error. Attempt to subscribe "
"MaterialModel twice.");
m_materialModel = materialModel;
}
void AppSvc::this_unsubscribe(MaterialModel* materialModel)
{
if (m_materialModel != materialModel)
throw Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe "
"MaterialModel before it was subscribed.");
m_materialModel = nullptr;
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/mainwindow/AppSvc.h
//! @brief Defines class AppSvc
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_MAINWINDOW_APPSVC_H
#define BORNAGAIN_GUI_MAINWINDOW_APPSVC_H
#include "GUI/Models/ISingleton.h"
class ProjectManager;
class MaterialModel;
//! The AppSvc class provides common access for key components of the GUI.
class AppSvc : public ISingleton<AppSvc> {
friend class ISingleton<AppSvc>;
public:
static ProjectManager* projectManager();
static void subscribe(ProjectManager* projectManager);
static void unsubscribe(ProjectManager* projectManager);
static MaterialModel* materialModel();
static void subscribe(MaterialModel* materialModel);
static void unsubscribe(MaterialModel* materialModel);
private:
AppSvc();
ProjectManager* this_projectManager();
MaterialModel* this_materialModel();
void this_subscribe(ProjectManager* projectManager);
void this_unsubscribe(ProjectManager* projectManager);
void this_subscribe(MaterialModel* materialModel);
void this_unsubscribe(MaterialModel* materialModel);
ProjectManager* m_projectManager;
MaterialModel* m_materialModel;
};
#endif // BORNAGAIN_GUI_MAINWINDOW_APPSVC_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment