Simulant  21.09-46
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
nameable.h
1 #pragma once
2 
3 #include <string>
4 
5 namespace smlt {
6 
12 class Nameable {
13 public:
14  virtual ~Nameable() {}
15 
16  void set_name(const std::string& name) {
17  name_ = name;
18  }
19 
20  const std::string& name() const {
21  return name_;
22  }
23 
24  bool has_name() const {
25  return !name_.empty();
26  }
27 
28 private:
29  std::string name_;
30 };
31 
32 template<typename T>
34  public virtual Nameable {
35 
36 public:
37  T* set_name_and_get(const std::string& name) {
38  set_name(name);
39  return dynamic_cast<T*>(this);
40  }
41 };
42 
43 }
smlt
Definition: animation.cpp:25
smlt::ChainNameable
Definition: nameable.h:34
smlt::Nameable
The Nameable class.
Definition: nameable.h:12