paysages3d/src/definition/Layers.h

57 lines
1.4 KiB
C
Raw Normal View History

2013-10-31 16:59:18 +00:00
#ifndef LAYERS_H
#define LAYERS_H
#include "definition_global.h"
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:
Layers(BaseDefinition* parent, const std::string &name, 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;
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.
*/
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:
LayerConstructor layer_constructor;
2013-10-31 16:59:18 +00:00
int max_layer_count;
std::vector<BaseDefinition*> layers;
2013-10-31 16:59:18 +00:00
BaseDefinition* null_layer;
};
}
}
#endif // LAYERS_H