2015-08-16 22:29:54 +00:00
|
|
|
#ifndef DEFINITIONWATCHER_H
|
|
|
|
#define DEFINITIONWATCHER_H
|
|
|
|
|
|
|
|
#include "definition_global.h"
|
|
|
|
|
2015-12-29 23:43:35 +00:00
|
|
|
#include <string>
|
|
|
|
|
2015-08-16 22:29:54 +00:00
|
|
|
namespace paysages {
|
|
|
|
namespace definition {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for watchers of the definition tree.
|
|
|
|
*
|
|
|
|
* Watchers will be registered in DiffManager to receive DefinitionDiff objects.
|
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class DEFINITIONSHARED_EXPORT DefinitionWatcher {
|
|
|
|
public:
|
2015-08-16 22:29:54 +00:00
|
|
|
DefinitionWatcher();
|
2015-12-30 19:14:16 +00:00
|
|
|
virtual ~DefinitionWatcher();
|
2015-08-17 20:55:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract method called when a node changed.
|
2016-01-16 15:21:02 +00:00
|
|
|
*
|
|
|
|
* *parent* is the node that is watched (useful if *node* is a sub-node).
|
2015-08-17 20:55:30 +00:00
|
|
|
*/
|
2016-01-16 15:21:02 +00:00
|
|
|
virtual void nodeChanged(const DefinitionNode *node, const DefinitionDiff *diff, const DefinitionNode *parent);
|
2015-12-13 18:56:00 +00:00
|
|
|
|
2015-12-17 18:29:04 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Start watching a path in a definition tree.
|
|
|
|
*/
|
|
|
|
void startWatching(const DefinitionNode *root, const string &path, bool init_diff = true);
|
|
|
|
|
2016-01-18 22:06:50 +00:00
|
|
|
/**
|
|
|
|
* Start watching a node.
|
|
|
|
*
|
|
|
|
* Overloaded for convenience.
|
|
|
|
*/
|
|
|
|
void startWatching(const DefinitionNode *node, bool init_diff = true);
|
|
|
|
|
2015-12-13 18:56:00 +00:00
|
|
|
/**
|
|
|
|
* Abstract convenience to receive integer node changes.
|
|
|
|
*/
|
|
|
|
virtual void intNodeChanged(const string &path, int new_value, int old_value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract convenience to receive float node changes.
|
|
|
|
*/
|
|
|
|
virtual void floatNodeChanged(const string &path, double new_value, double old_value);
|
2015-08-16 22:29:54 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DEFINITIONWATCHER_H
|