2013-10-31 16:59:18 +00:00
|
|
|
#ifndef LAYERS_H
|
|
|
|
#define LAYERS_H
|
|
|
|
|
|
|
|
#include "definition_global.h"
|
2013-11-16 18:12:42 +00:00
|
|
|
|
2013-10-31 16:59:18 +00:00
|
|
|
#include "BaseDefinition.h"
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace definition {
|
|
|
|
|
|
|
|
typedef BaseDefinition* (*LayerConstructor)(Layers* parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Layers of definitions, ideally all of the same type.
|
|
|
|
*/
|
|
|
|
class DEFINITIONSHARED_EXPORT Layers:public BaseDefinition
|
|
|
|
{
|
|
|
|
public:
|
2013-11-16 18:12:42 +00:00
|
|
|
Layers(BaseDefinition* parent, LayerConstructor layer_constructor);
|
2013-10-31 16:59:18 +00:00
|
|
|
virtual ~Layers();
|
|
|
|
|
2013-11-13 19:07:35 +00:00
|
|
|
virtual void copy(BaseDefinition* destination) const override;
|
2013-11-16 18:12:42 +00:00
|
|
|
Layers* newCopy() const;
|
2013-10-31 16:59:18 +00:00
|
|
|
|
|
|
|
void setMaxLayerCount(int max_layer_count);
|
|
|
|
|
2013-11-15 22:26:44 +00:00
|
|
|
int count() const;
|
|
|
|
BaseDefinition* getLayer(int position) const;
|
|
|
|
int findLayer(BaseDefinition* layer) const;
|
2013-10-31 16:59:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Add a new layer
|
|
|
|
*
|
|
|
|
* This method takes ownership of the layer definition. In any case, it will be deleted by
|
|
|
|
* this object (even if the layer could not be added).
|
|
|
|
* @return The position of the new layer, -1 if it couldn't be added.
|
|
|
|
*/
|
2013-11-16 18:12:42 +00:00
|
|
|
int addLayer(BaseDefinition *layer);
|
2013-10-31 16:59:18 +00:00
|
|
|
int addLayer();
|
|
|
|
void removeLayer(int position);
|
|
|
|
void removeLayer(BaseDefinition* layer);
|
|
|
|
void moveLayer(int old_position, int new_position);
|
|
|
|
void moveLayer(BaseDefinition* layer, int new_position);
|
|
|
|
void clear();
|
|
|
|
|
2013-11-15 22:26:44 +00:00
|
|
|
public:
|
2013-11-16 18:12:42 +00:00
|
|
|
LayerConstructor layer_constructor;
|
2013-10-31 16:59:18 +00:00
|
|
|
int max_layer_count;
|
2013-12-10 21:32:58 +00:00
|
|
|
std::vector<BaseDefinition*> layers;
|
2013-10-31 16:59:18 +00:00
|
|
|
BaseDefinition* null_layer;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // LAYERS_H
|