paysages3d/src/definition/Layers.h

63 lines
1.6 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 {
typedef DefinitionNode* (*LayerConstructor)(Layers* parent);
2013-10-31 16:59:18 +00:00
/**
* @brief Layers of definitions, ideally all of the same type.
*/
class DEFINITIONSHARED_EXPORT Layers:public DefinitionNode
2013-10-31 16:59:18 +00:00
{
public:
Layers(DefinitionNode* parent, const std::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;
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;
DefinitionNode* getLayer(int position) const;
int findLayer(DefinitionNode* 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(DefinitionNode *layer);
2013-10-31 16:59:18 +00:00
int addLayer();
void removeLayer(int position);
void removeLayer(DefinitionNode* layer);
2013-10-31 16:59:18 +00:00
void moveLayer(int old_position, int new_position);
void moveLayer(DefinitionNode* layer, int new_position);
2013-10-31 16:59:18 +00:00
void clear();
protected:
virtual DefinitionNode *findChildByName(const std::string name) override;
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<DefinitionNode*> layers;
DefinitionNode* null_layer;
2013-10-31 16:59:18 +00:00
};
}
}
#endif // LAYERS_H