paysages3d/src/definition/Layers.h

78 lines
1.7 KiB
C
Raw Normal View History

2013-10-31 16:59:18 +00:00
#ifndef LAYERS_H
#define LAYERS_H
#include "definition_global.h"
#include "DefinitionNode.h"
2013-10-31 16:59:18 +00:00
namespace paysages {
namespace definition {
2015-12-10 23:36:50 +00:00
typedef DefinitionNode *(*LayerConstructor)(Layers *parent, const string &name);
2013-10-31 16:59:18 +00:00
/**
2016-01-03 18:21:23 +00:00
* Layers of definitions, ideally all of the same type.
2013-10-31 16:59:18 +00:00
*/
class DEFINITIONSHARED_EXPORT Layers : public DefinitionNode {
public:
2015-12-10 23:36:50 +00:00
Layers(DefinitionNode *parent, const string &name, LayerConstructor layer_constructor);
2013-10-31 16:59:18 +00:00
virtual ~Layers();
virtual void save(PackStream *stream) const override;
virtual void load(PackStream *stream) override;
virtual void copy(DefinitionNode *destination) const override;
2013-10-31 16:59:18 +00:00
virtual bool applyDiff(const DefinitionDiff *diff, bool backward = false) override;
2015-12-10 23:36:50 +00:00
virtual void generateInitDiffs(vector<const DefinitionDiff *> *diffs) const override;
/**
* Set the maximal layer count allowed.
*/
2013-10-31 16:59:18 +00:00
void setMaxLayerCount(int max_layer_count);
/**
* Get the current layer count.
*/
int getLayerCount() const;
/**
* Retrieve a layer by its position.
*/
DefinitionNode *getLayer(int position) const;
2013-10-31 16:59:18 +00:00
/**
* Retrieve a layer by its name.
*/
2015-12-10 23:36:50 +00:00
DefinitionNode *getLayer(const string &name) const;
/**
* Add a new empty layer.
*/
2015-12-10 23:36:50 +00:00
void addLayer(const string &name);
/**
* Add a new layer, copying another node into it.
*/
void addLayer(const DefinitionNode &tocopy);
/**
* Remove a layer by its position.
2013-10-31 16:59:18 +00:00
*/
void removeLayer(int position);
/**
* Clear this node of all layers.
*/
void clear();
public:
LayerConstructor layer_constructor;
2013-10-31 16:59:18 +00:00
int max_layer_count;
2015-12-10 23:36:50 +00:00
vector<DefinitionNode *> layers;
DefinitionNode *null_layer;
2013-10-31 16:59:18 +00:00
};
}
}
#endif // LAYERS_H