2015-09-08 21:52:34 +00:00
|
|
|
#ifndef INTNODE_H
|
|
|
|
#define INTNODE_H
|
|
|
|
|
|
|
|
#include "definition_global.h"
|
|
|
|
|
|
|
|
#include "DefinitionNode.h"
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace definition {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Node with a single integer value, for the definition tree.
|
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class DEFINITIONSHARED_EXPORT IntNode : public DefinitionNode {
|
|
|
|
public:
|
|
|
|
IntNode(DefinitionNode *parent, const std::string &name, int value = 0);
|
2015-09-08 21:52:34 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
inline int getValue() const {
|
|
|
|
return value;
|
|
|
|
}
|
2015-09-08 21:52:34 +00:00
|
|
|
|
|
|
|
virtual std::string toString(int indent) const override;
|
2015-11-09 21:30:46 +00:00
|
|
|
virtual void save(PackStream *stream) const override;
|
|
|
|
virtual void load(PackStream *stream) override;
|
|
|
|
virtual void copy(DefinitionNode *destination) const override;
|
2015-09-08 21:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the int value stored.
|
|
|
|
*
|
|
|
|
* The DiffManager is used as intermediary, so that the change may not happen immediately.
|
|
|
|
*/
|
|
|
|
void setValue(int new_value);
|
|
|
|
const IntDiff *produceDiff(int new_value) const;
|
|
|
|
void generateInitDiffs(std::vector<const DefinitionDiff *> *diffs) const;
|
2015-11-09 21:30:46 +00:00
|
|
|
virtual bool applyDiff(const DefinitionDiff *diff, bool backward = false) override;
|
2015-09-08 21:52:34 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
2015-09-08 21:52:34 +00:00
|
|
|
int value;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // INTNODE_H
|