OpenCPN Partial API docs
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 
35 class OCPNConfigCatalog;
36 class OCPNConfigObject;
37 
38 WX_DECLARE_LIST(OCPNConfigObject, ConfigObjectList);
39 
45 class ConfigMgr {
46 public:
47  static ConfigMgr &Get();
48  static void Shutdown();
49 
50  wxString CreateNamedConfig(const wxString &title, const wxString &description,
51  wxString UUID);
52  bool DeleteConfig(wxString GUID);
53  wxArrayString GetConfigGUIDArray();
54 
55  wxPanel *GetConfigPanel(wxWindow *parent, wxString GUID);
56  wxString GetTemplateTitle(wxString GUID);
57  bool ApplyConfigGUID(wxString GUID);
58  bool CheckTemplateGUID(wxString GUID);
59  arrayofCanvasConfigPtr &GetCanvasConfigArray(){ return g_canvasConfigArray;}
60 
61 private: // private for singleton
62  ConfigMgr();
63  ~ConfigMgr();
64  ConfigMgr(const ConfigMgr &) {}
65  ConfigMgr &operator=(const ConfigMgr &) { return *this; }
66  static ConfigMgr *instance;
67 
68  void Init();
69  bool LoadCatalog();
70  bool SaveCatalog();
71  wxString GetUUID(void);
72  bool SaveTemplate(wxString fileName);
73  wxString GetConfigDir() { return m_configDir; }
74  ConfigObjectList *GetConfigList() { return configList; }
75  OCPNConfigObject *GetConfig(wxString GUID);
76  bool CheckTemplate(wxString fileName);
77 
78  wxString m_configDir;
79  wxString m_configCatalogName;
80  OCPNConfigCatalog *m_configCatalog;
81  ConfigObjectList *configList;
82  arrayofCanvasConfigPtr g_canvasConfigArray;
83 
84 };
85 
86 class ConfigPanel : public wxPanel {
87 public:
88  ConfigPanel(OCPNConfigObject *config, wxWindow *parent,
89  wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition,
90  const wxSize &size = wxDefaultSize);
91  ~ConfigPanel();
92 
93  wxString GetConfigGUID();
94 
95 private:
96  void OnConfigPanelMouseSelected(wxMouseEvent &event);
97  OCPNConfigObject *m_config;
98 };
99 
100 #endif
Manages the user config matrix.
Definition: ConfigMgr.h:45