| Line | |
|---|
| 1 | /*! |
|---|
| 2 | * @file gui_saveable.h |
|---|
| 3 | * @brief Definition of ... |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #ifndef _GUI_SAVEABLE_H |
|---|
| 7 | #define _GUI_SAVEABLE_H |
|---|
| 8 | |
|---|
| 9 | #include "base_object.h" |
|---|
| 10 | #include "lib/util/multi_type.h" |
|---|
| 11 | #include <vector> |
|---|
| 12 | |
|---|
| 13 | // FORWARD DECLARATION |
|---|
| 14 | namespace OrxGui |
|---|
| 15 | { |
|---|
| 16 | class Gui; |
|---|
| 17 | class SaveableGroup; |
|---|
| 18 | |
|---|
| 19 | //! A class for Elements in the Gui that are Saveable. |
|---|
| 20 | class Saveable : public BaseObject |
|---|
| 21 | { |
|---|
| 22 | public: |
|---|
| 23 | virtual ~Saveable(); |
|---|
| 24 | |
|---|
| 25 | void makeSaveable(); |
|---|
| 26 | |
|---|
| 27 | virtual void load(); |
|---|
| 28 | virtual void save(); |
|---|
| 29 | |
|---|
| 30 | MultiType& value() { return this->_value; }; |
|---|
| 31 | const MultiType& value() const { return this->_value; }; |
|---|
| 32 | MultiType& defaultValue() { return this->_defaultValue; }; |
|---|
| 33 | const MultiType& defaultValue() const { return this->_defaultValue; }; |
|---|
| 34 | bool isSaveable() const { return this->bSaveable; }; |
|---|
| 35 | |
|---|
| 36 | protected: |
|---|
| 37 | Saveable(const std::string& optionName, SaveableGroup* group, const MultiType& defaultValue); |
|---|
| 38 | virtual void makingElementSaveable() {}; |
|---|
| 39 | |
|---|
| 40 | private: |
|---|
| 41 | SaveableGroup* group; |
|---|
| 42 | MultiType _value; |
|---|
| 43 | MultiType _defaultValue; |
|---|
| 44 | bool bSaveable; |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | class SaveableGroup : public BaseObject |
|---|
| 50 | { |
|---|
| 51 | public: |
|---|
| 52 | virtual ~SaveableGroup(); |
|---|
| 53 | |
|---|
| 54 | void addSaveable(Saveable* saveable); |
|---|
| 55 | void removeSaveable(Saveable* saveable); |
|---|
| 56 | |
|---|
| 57 | virtual void load(); |
|---|
| 58 | virtual void save(); |
|---|
| 59 | |
|---|
| 60 | protected: |
|---|
| 61 | SaveableGroup(const std::string& name, OrxGui::Gui* gui); |
|---|
| 62 | |
|---|
| 63 | private: |
|---|
| 64 | OrxGui::Gui* gui; |
|---|
| 65 | std::vector<Saveable*> saveables; |
|---|
| 66 | }; |
|---|
| 67 | |
|---|
| 68 | } |
|---|
| 69 | #endif /* _GUI_SAVEABLE_H */ |
|---|
Note: See
TracBrowser
for help on using the repository browser.