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 
15 namespace 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>
77  class AttributeAdapter
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
Base class of Value adapters.
Definition: TextInterfaceAdapter.h:26
void set_description(const std::string &description)
Set the description of the attribute.
Definition: TextInterfaceAdapter.h:88
virtual void set_description(const std::string &)=0
Set the description of the value.
std::string get_description() const
Get the description of the value.
Definition: TextInterfaceAdapter.h:42
An array of Value interfaces.
Definition: TextInterfaceParser.h:35
Template class manages Reference::Able objects.
Definition: Reference.h:74
std::string get_name() const
Get the name of the value.
Definition: TextInterfaceAdapter.h:38
Reference::To< HasA > value
The nested value.
Definition: TextInterfaceAdapter.h:64
std::string get_detailed_description() const
Set the detailed description of the value.
Definition: TextInterfaceAdapter.h:46
void set_detailed_description(const std::string &description)
Set the detailed description of the attribute.
Definition: TextInterfaceAdapter.h:92
virtual void set_detailed_description(const std::string &)=0
Set the detailed description of the value.

Generated using doxygen 1.8.17