CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Named.hh
Go to the documentation of this file.
1 #ifndef CASM_Named
2 #define CASM_Named
3 
4 #include <string>
5 
7 
8 namespace CASM {
9 class PrimClex;
10 
11 namespace DB {
12 template <typename T>
13 class ValDatabase;
14 
22 template <typename Base>
23 class Named : public Base {
24  public:
25  typedef typename Base::MostDerived MostDerived;
26  using Base::derived;
27 
28  Named();
29 
30  std::string name() const;
31 
34  std::string alias() const;
35 
36  protected:
38  void clear_name() const;
39 
41  void regenerate_name() const;
42 
44  void set_name(std::string _name) const;
45 
46  private:
47  mutable std::string m_name;
48 };
49 
56 template <typename _Base>
57 class Indexed : public Named<_Base> {
58  public:
59  typedef Named<_Base> Base;
60  typedef typename Base::MostDerived MostDerived;
61  using Base::derived;
62 
63  Indexed();
64 
65  // ID for object stored in database. Typically an integer as a string, or
66  // 'none'.
67  std::string id() const;
68 
69  // If 'id' != 'none', just return configname; else regenerate name
70  std::string name() const;
71 
72  protected:
74  void clear_name() const;
75 
81  void set_id(Index _id) const;
82 
88  void set_id(std::string _id) const;
89 
90  private:
92 
93  mutable std::string m_id;
94 };
95 
96 } // namespace DB
97 } // namespace CASM
98 
99 #endif
std::string id() const
Definition: Named_impl.hh:50
Named< _Base > Base
Definition: Named.hh:59
void clear_name() const
Unset "id" and "name", if object is modified.
Definition: Named_impl.hh:65
void set_id(Index _id) const
Set id.
Definition: Named_impl.hh:76
std::string name() const
Definition: Named_impl.hh:56
Base::MostDerived MostDerived
Definition: Named.hh:60
std::string m_id
Definition: Named.hh:93
Base::MostDerived MostDerived
Definition: Named.hh:25
std::string m_name
Definition: Named.hh:47
void regenerate_name() const
Regenerate "name".
Definition: Named_impl.hh:36
std::string alias() const
Return "alias" if object stored in database and alias exists, return empty string otherwise.
Definition: Named_impl.hh:24
void set_name(std::string _name) const
Set "name", explicity.
Definition: Named_impl.hh:42
std::string name() const
Definition: Named_impl.hh:14
void clear_name() const
Unset "name", if object is modified.
Definition: Named_impl.hh:30
Generic interface for database of a particular CASM type.
Definition: Database.hh:221
Main CASM namespace.
Definition: APICommand.hh:8
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39