OpenCPN Partial API docs
Loading...
Searching...
No Matches
ConfigMgr.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 *
5 ***************************************************************************
6 * Copyright (C) 2018 by David S. Register *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 **************************************************************************/
23
24#ifndef __CONFIGMGR_H__
25#define __CONFIGMGR_H__
26
27#include "wx/wxprec.h"
28#ifndef WX_PRECOMP
29#include "wx/wx.h"
30#endif // precompiled headers
31
32#include "pugixml.hpp"
33
36
37WX_DECLARE_LIST(OCPNConfigObject, ConfigObjectList);
38
44class ConfigMgr {
45public:
46 static ConfigMgr &Get();
47 static void Shutdown();
48
49 wxString CreateNamedConfig(const wxString &title, const wxString &description,
50 wxString UUID);
51 bool DeleteConfig(wxString GUID);
52 wxArrayString GetConfigGUIDArray();
53
54 wxPanel *GetConfigPanel(wxWindow *parent, wxString GUID);
55 wxString GetTemplateTitle(wxString GUID);
56 bool ApplyConfigGUID(wxString GUID);
57 bool CheckTemplateGUID(wxString GUID);
58
59private: // private for singleton
60 ConfigMgr();
61 ~ConfigMgr();
62 ConfigMgr(const ConfigMgr &) {}
63 ConfigMgr &operator=(const ConfigMgr &) { return *this; }
64 static ConfigMgr *instance;
65
66 void Init();
67 bool LoadCatalog();
68 bool SaveCatalog();
69 wxString GetUUID(void);
70 bool SaveTemplate(wxString fileName);
71 wxString GetConfigDir() { return m_configDir; }
72 ConfigObjectList *GetConfigList() { return configList; }
73 OCPNConfigObject *GetConfig(wxString GUID);
74 bool CheckTemplate(wxString fileName);
75
76 wxString m_configDir;
77 wxString m_configCatalogName;
78 OCPNConfigCatalog *m_configCatalog;
79 ConfigObjectList *configList;
80};
81
82class ConfigPanel : public wxPanel {
83public:
84 ConfigPanel(OCPNConfigObject *config, wxWindow *parent,
85 wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition,
86 const wxSize &size = wxDefaultSize);
88
89 wxString GetConfigGUID();
90
91private:
92 void OnConfigPanelMouseSelected(wxMouseEvent &event);
93 OCPNConfigObject *m_config;
94};
95
96#endif
Manages the user config matrix.
Definition: ConfigMgr.h:44