diff options
author | Stijn Buys <ingar@osirion.org> | 2009-11-13 22:25:09 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-11-13 22:25:09 +0000 |
commit | a993d31910b63a1f897e470842934e6ffefad32c (patch) | |
tree | fef52482d762acbbd35e97f382b60ff24ce5071f /src/core/label.h | |
parent | 5ddb64795cc959916eeedbec8dc3f65c06f49698 (diff) |
added core::InfoType, refactored game::ShipModel as core::Info subclass, introduced core::Label
Diffstat (limited to 'src/core/label.h')
-rw-r--r-- | src/core/label.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/core/label.h b/src/core/label.h new file mode 100644 index 0000000..e772277 --- /dev/null +++ b/src/core/label.h @@ -0,0 +1,78 @@ +/* + core/label.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_CORE_LABEL_H__ +#define __INCLUDED_CORE_LABEL_H__ + +#include <string> + +#include "auxiliary/functions.h" + +namespace core { + +/** + * @brief baseclass for objects with a name and a label + */ +class Label { +public: + inline Label() { + } + + inline ~Label() { + labelstr.clear(); + namestr.clear(); + } + + /* --- inspectors ------------------------------------------------- */ + + inline const std::string & label() const { + return labelstr; + } + + inline const std::string & name() const { + return namestr; + } + + /* --- mutators --------------------------------------------------- */ + + inline void set_label(const std::string & label) + { + labelstr.assign(label); + aux::to_label(labelstr); + } + + inline void set_label(const char *label) + { + if (label) { + labelstr.assign(label); + aux::to_label(labelstr); + } else { + labelstr.clear(); + } + } + + inline void set_name(const std::string & name) + { + namestr.assign(name); + } + + inline void set_name(const char *name) + { + if (name) + namestr.assign(name); + else + namestr.clear(); + } + +private: + std::string labelstr; + std::string namestr; + +}; // class Label + +} // namespace core + +#endif // __INCLUDED_CORE_LABEL_H__ |