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#include "CanvasConfig.h"
34
37
38WX_DECLARE_LIST(OCPNConfigObject, ConfigObjectList);
39
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 arrayofCanvasConfigPtr &GetCanvasConfigArray() { return g_canvasConfigArray; }
59
60private: // private for singleton
61 ConfigMgr();
62 ~ConfigMgr();
63 ConfigMgr(const ConfigMgr &) {}
64 ConfigMgr &operator=(const ConfigMgr &) { return *this; }
65 static ConfigMgr *instance;
66
67 void Init();
68 bool LoadCatalog();
69 bool SaveCatalog();
70 wxString GetUUID(void);
71 bool SaveTemplate(wxString fileName);
72 wxString GetConfigDir() { return m_configDir; }
73 ConfigObjectList *GetConfigList() { return configList; }
74 OCPNConfigObject *GetConfig(wxString GUID);
75 bool CheckTemplate(wxString fileName);
76
77 wxString m_configDir;
78 wxString m_configCatalogName;
79 OCPNConfigCatalog *m_configCatalog;
80 ConfigObjectList *configList;
81 arrayofCanvasConfigPtr g_canvasConfigArray;
82};
83
89class ConfigPanel : public wxPanel {
90public:
91 ConfigPanel(OCPNConfigObject *config, wxWindow *parent,
92 wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition,
93 const wxSize &size = wxDefaultSize);
95
96 wxString GetConfigGUID();
97
98private:
99 void OnConfigPanelMouseSelected(wxMouseEvent &event);
100 OCPNConfigObject *m_config;
101};
102
103#endif
Manages the user configuration matrix.
Definition ConfigMgr.h:44
Represents a panel for displaying and editing a configuration.
Definition ConfigMgr.h:89