OpenCPN Partial API docs
Loading...
Searching...
No Matches
observable_confvar.h
1/*************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Notify/listen config var wrapper
5 *
6 * Copyright (C) 2022 Alec Leamas
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 OBSERVABLE_CONFVAR_H
25#define OBSERVABLE_CONFVAR_H
26
27#include <memory>
28#include <string>
29#include <vector>
30
31#include <wx/config.h>
32
33#include "observable.h"
34
66template <typename T = std::string>
67class ConfigVar : public Observable {
68public:
69 ConfigVar(const std::string& section_, const std::string& key_,
70 wxConfigBase* cb);
71
72 void Set(const T& arg);
73
74 const T Get(const T& default_val);
75
76private:
77 ConfigVar(); // not implemented
78
79 const std::string section;
80 const std::string key;
81 wxConfigBase* const config;
82};
83
84#endif // OBSERVABLE_CONFVAR_H
Wrapper for configuration variables which lives in a wxBaseConfig object.
The observable notify/listen basic nuts and bolts.
Definition observable.h:81