From a993d31910b63a1f897e470842934e6ffefad32c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 13 Nov 2009 22:25:09 +0000 Subject: added core::InfoType, refactored game::ShipModel as core::Info subclass, introduced core::Label --- src/core/label.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/core/label.h (limited to 'src/core/label.h') 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 + +#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__ -- cgit v1.2.3