TextInterfaceAdapter.h
1//-*-C++-*-
2
3/***************************************************************************
4 *
5 * Copyright (C) 2016 by Willem van Straten
6 * Licensed under the Academic Free License version 2.1
7 *
8 ***************************************************************************/
9
10// psrchive/Util/units/TextInterfaceAdapter.h
11
12#ifndef __TextInterfaceAdapter_h
13#define __TextInterfaceAdapter_h
14
15namespace TextInterface
16{
18
20 template<class IsA, class HasA = IsA>
21 class AdapterBase : public IsA
22 {
23 public:
24
25 AdapterBase (HasA* _value = 0) { value = _value; }
26
28 std::string get_name () const
29 { return value->get_name(); }
30
32 std::string get_description () const
33 { return value->get_description(); }
34
36 std::string get_detailed_description () const
37 { return value->get_detailed_description (); }
38
39 bool matches (const std::string& name) const
40 { return value->matches (name); }
41
42 void set_parent (Parser* p)
43 { IsA::set_parent(p); value->set_parent(p); }
44
45 void set_modifiers (const std::string& mods) const
46 { value->set_modifiers (mods); }
47
48 void reset_modifiers () const
49 { value->reset_modifiers(); }
50
51 protected:
52
55
56 };
57
58
59 template<class IsA, class HasA = IsA>
60 class ValueAdapter : public AdapterBase<IsA,HasA>
61 {
62 public:
63
64 ValueAdapter (HasA* _value = 0) : AdapterBase<IsA,HasA> (_value) { }
65
67 std::string get_value () const
68 { return this->value->get_value (); }
69
71 void set_value (const std::string& val)
72 { this->value->set_value (val); }
73 };
74
76 template<class IsA, class HasA = IsA>
78 : public AdapterBase< Attribute<IsA>, Attribute<HasA> >
79 {
80 public:
81
83 void set_description (const std::string& description)
84 { this->value->set_description (description); }
85
87 void set_detailed_description (const std::string& description)
88 { this->value->set_detailed_description (description); }
89 };
90
91}
92
93#endif
Template class manages Reference::Able objects.
Definition ReferenceTo.h:25
Base class of Value adapters.
Definition TextInterfaceAdapter.h:22
std::string get_detailed_description() const
Set the detailed description of the value.
Definition TextInterfaceAdapter.h:36
std::string get_description() const
Get the description of the value.
Definition TextInterfaceAdapter.h:32
Reference::To< HasA > value
The nested value.
Definition TextInterfaceAdapter.h:54
std::string get_name() const
Get the name of the value.
Definition TextInterfaceAdapter.h:28
Can be used as an Adapter (IsA != HasA) or a Decorator (IsA == HasA)
Definition TextInterfaceAdapter.h:79
void set_detailed_description(const std::string &description)
Set the detailed description of the attribute.
Definition TextInterfaceAdapter.h:87
void set_description(const std::string &description)
Set the description of the attribute.
Definition TextInterfaceAdapter.h:83

Generated using doxygen 1.14.0