2015-08-12 20:21:10 +00:00
|
|
|
#ifndef DEFINITIONNODE_H
|
|
|
|
#define DEFINITIONNODE_H
|
2013-10-30 11:46:18 +00:00
|
|
|
|
|
|
|
#include "definition_global.h"
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace definition {
|
|
|
|
|
|
|
|
/**
|
2015-08-12 20:21:10 +00:00
|
|
|
* Base class for all nodes of the definition tree.
|
2013-10-30 11:46:18 +00:00
|
|
|
*/
|
2015-08-12 20:21:10 +00:00
|
|
|
class DEFINITIONSHARED_EXPORT DefinitionNode
|
2013-10-30 11:46:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-08-12 20:21:10 +00:00
|
|
|
DefinitionNode(DefinitionNode* parent, const std::string &name);
|
|
|
|
virtual ~DefinitionNode();
|
2013-10-30 11:46:18 +00:00
|
|
|
|
2013-11-15 23:27:40 +00:00
|
|
|
virtual void save(PackStream* stream) const;
|
|
|
|
virtual void load(PackStream* stream);
|
2013-10-30 11:46:18 +00:00
|
|
|
|
2015-08-12 20:21:10 +00:00
|
|
|
virtual void copy(DefinitionNode* destination) const;
|
2013-10-31 16:59:18 +00:00
|
|
|
virtual void validate();
|
|
|
|
|
2013-12-10 21:32:58 +00:00
|
|
|
inline const std::string &getName() const {return name;}
|
|
|
|
virtual void setName(const std::string &name);
|
2013-10-31 16:59:18 +00:00
|
|
|
|
2013-11-17 21:36:18 +00:00
|
|
|
virtual Scenery* getScenery();
|
|
|
|
|
2015-08-12 20:21:10 +00:00
|
|
|
inline const DefinitionNode* getParent() const {return parent;}
|
|
|
|
inline const DefinitionNode* getRoot() const {return root;}
|
2015-08-12 17:29:28 +00:00
|
|
|
inline int getChildrenCount() const {return children.size();}
|
2013-10-31 21:53:22 +00:00
|
|
|
|
2015-08-12 15:02:27 +00:00
|
|
|
/**
|
|
|
|
* Return a string representation of the tree (mainly for debugging purposes).
|
|
|
|
*/
|
|
|
|
virtual std::string toString(int indent = 0) const;
|
|
|
|
|
2013-10-30 14:39:56 +00:00
|
|
|
protected:
|
2015-08-12 20:21:10 +00:00
|
|
|
void addChild(DefinitionNode* child);
|
|
|
|
void removeChild(DefinitionNode* child);
|
2013-10-30 14:39:56 +00:00
|
|
|
|
2013-10-30 11:46:18 +00:00
|
|
|
private:
|
2015-08-12 20:21:10 +00:00
|
|
|
DefinitionNode* parent;
|
|
|
|
DefinitionNode* root;
|
2013-12-10 21:32:58 +00:00
|
|
|
std::string name;
|
2015-08-12 20:21:10 +00:00
|
|
|
std::vector<DefinitionNode*> children;
|
2013-10-30 11:46:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-12 20:21:10 +00:00
|
|
|
#endif // DEFINITIONNODE_H
|