Identifiable.h
1
2//-*-C++-*-
3/***************************************************************************
4 *
5 * Copyright (C) 2013 by Willem van Straten
6 * Licensed under the Academic Free License version 2.1
7 *
8 ***************************************************************************/
9
10// psrchive/Util/units/Identifiable.h
11
12#ifndef __Identifiable_H
13#define __Identifiable_H
14
15#include "ReferenceTo.h"
16
17class Identifiable : public Reference::Able
18{
19 public:
20
22 virtual bool identify (const std::string& name);
23
25 virtual void set_identity (const std::string&);
26
28 virtual std::string get_identity () const;
29
31 virtual void set_description (const std::string&);
32
34 virtual std::string get_description () const;
35
37 virtual void add_alias (const std::string&);
38
39 class Decorator;
40
41 template<class Parent> class Proxy;
42
43 private:
44
46 std::vector<std::string> identities;
47
49 std::string description;
50
51};
52
53template<class Parent>
54class Identifiable::Proxy : public Parent
55{
56 Reference::To<Identifiable> decorated;
57
58public:
59
60 Proxy (Identifiable* id) { decorated = id; }
61
62 bool identify (const std::string& name)
63 { return decorated->identify(name); }
64
65 std::string get_identity () const
66 { return decorated->get_identity (); }
67
68 std::string get_description () const
69 { return decorated->get_description (); }
70
71};
72
73class Identifiable::Decorator : public Identifiable::Proxy<Identifiable>
74{
75public:
76 Decorator (Identifiable* id) : Proxy<Identifiable> (id) { }
77};
78
79
80#endif
Manages Reference::To references to the instance.
Definition ReferenceAble.h:35

Generated using doxygen 1.14.0