varconf 1.0.3
Configuration library for the Worldforge system.
dyntypes.h
1/*
2 * dyntypes.h - interface for dynamically derived value container class types
3 * Copyright (C) 2001, Ron Steinke
4 * (C) 2001-2005 Alistair Riddoch
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * Contact: Joseph Zupko
21 * jaz147@psu.edu
22 *
23 * 189 Reese St.
24 * Old Forge, PA 18518
25 */
26
27#ifndef VARCONF_DYNTYPES_H
28#define VARCONF_DYNTYPES_H
29
30#include "variable.h"
31#include "dynbase.h"
32
33#include <string>
34
35namespace varconf {
36namespace dynvar {
37
38class Concat : public Base {
39public:
40 Concat() : Base(), m_v1(0), m_v2(0) {}
41 Concat(const Variable& one, const Variable& two) : Base(), m_v1(one), m_v2(two) {}
42 Concat(const Concat& c) : sigc::trackable(c), Base(c), m_v1(c.m_v1), m_v2(c.m_v2) {}
43
44 ~Concat() override;
45
46 Concat& operator=(const Concat& c);
47
48protected:
49
50 void set_val() override;
51
52private:
53
54 Variable m_v1, m_v2;
55};
56
57class Ternary : public Base {
58public:
59 Ternary() : Base(), m_test(0), m_true(0), m_false(0) {}
60 Ternary(const Variable& test, const Variable& true_val, const Variable& false_val)
61 : Base(), m_test(test), m_true(true_val), m_false(false_val) {}
62 Ternary(const Ternary& t) : sigc::trackable(t), Base(t), m_test(t.m_test), m_true(t.m_true),
63 m_false(t.m_false) {}
64
65 ~Ternary() override;
66
67 Ternary& operator=(const Ternary& t);
68
69protected:
70
71 void set_val() override;
72
73private:
74
75 Variable m_test, m_true, m_false;
76};
77
78class Item : public Base {
79public:
80 Item() : Base(), m_section(""), m_key("") {}
81 Item(const Item& d) : sigc::trackable(d), Base(d), m_section(d.m_section), m_key(d.m_key) {}
82 Item(std::string section, std::string key)
83 : Base(), m_section(std::move(section)), m_key(std::move(key)) {}
84
85 ~Item() override;
86
87 Item& operator=(const Item & i);
88
89 void assign(const Variable & v, Scope scope);
90
91protected:
92
93 void set_val() override;
94
95private:
96
97 std::string m_section, m_key;
98
99};
100
101}} // namespace varconf::dynvar
102
103#endif