TextInterfaceTransform.h
1//-*-C++-*-
2
3/***************************************************************************
4 *
5 * Copyright (C) 2022 by Willem van Straten
6 * Licensed under the Academic Free License version 2.1
7 *
8 ***************************************************************************/
9
10// psrchive/psrchive/Util/units/TextInterfaceTransform.h
11
12#ifndef __TextInterfaceTransform_h
13#define __TextInterfaceTransform_h
14
15#include "TextInterfaceAttribute.h"
16
17namespace TextInterface
18{
19
21 template<class C, class Get, class X>
22 class AttributeXformGet : public AttributeGet<C,Get>
23 {
24
25 public:
26
28 AttributeXformGet (const std::string& _name, Get _get, X _xform)
29 : AttributeGet<C,Get> (_name, _get)
30 { xform = _xform; }
31
33 Attribute<C>* clone () const { return new AttributeXformGet(*this); }
34
36 std::string get_value (const C* ptr) const
37 { return tostring( xform( (ptr->*(this->get)) () ) ); }
38
39 protected:
40 X xform;
41 };
42
44
47 template<class C>
49 {
50 public:
51
53 template<class Get, class X>
55 operator () (const std::string& n, Get g, X x)
56 { return new AttributeXformGet<C,Get,X> (n, g, x); }
57
59 template<class Get, class X>
61 operator () (const std::string& n, const std::string& d, Get g, X x)
62 {
64 get->set_description (d); return get;
65 }
66 };
67
68}
69
70#endif
void set_description(const std::string &d)
Get the description of the attribute.
Definition TextInterfaceAttribute.h:206
AttributeGet(const std::string &_name, Get _get)
Constructor.
Definition TextInterfaceAttribute.h:193
Interface to a class attribute with an accessor method, C::Get()
Definition TextInterfaceTransform.h:23
std::string get_value(const C *ptr) const
Get the value of the attribute.
Definition TextInterfaceTransform.h:36
Attribute< C > * clone() const
Return a clone.
Definition TextInterfaceTransform.h:33
AttributeXformGet(const std::string &_name, Get _get, X _xform)
Constructor.
Definition TextInterfaceTransform.h:28
Text interface to a class attribute.
Definition TextInterfaceAttribute.h:23
AttributeXformGet factory.
Definition TextInterfaceTransform.h:49
AttributeXformGet< C, Get, X > * operator()(const std::string &n, Get g, X x)
Generate a new AttributeGet instance.
Definition TextInterfaceTransform.h:55

Generated using doxygen 1.14.0