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
68template <typename T = std::string>
69class ConfigVar : public Observable {
70public:
72 ConfigVar(const std::string& section_, const std::string& key_,
73 wxConfigBase* cb);
74
76 void Set(const T& arg);
77
82 const T Get(const T& default_val);
83
84private:
85 ConfigVar(); // not implemented
86
87 const std::string section;
88 const std::string key;
89 wxConfigBase* const config;
90};
91
92#endif // OBSERVABLE_CONFVAR_H
Wrapper for configuration variables which lives in a wxBaseConfig object.
const T Get(const T &default_val)
Get current value.
void Set(const T &arg)
Set value to given argument and notify listeners.
The observable notify/listen basic nuts and bolts.
Definition: observable.h:83