#include <ponder/classbuilder.hpp>
#include <iostream>
static void declare();
enum class ShapeType
{
Circle,
Rectangle
};
struct Vec2
{
Vec2(float x_, float y_) : x(x_), y(y_) {}
float x,y;
};
class Shape
{
public:
virtual ~Shape() {}
ShapeType getType() const { return m_type; }
protected:
Shape(ShapeType shape) : m_type(shape) {}
private:
ShapeType m_type;
};
class Circle : public Shape
{
public:
Circle(Vec2 pos, float radius)
: Shape(ShapeType::Circle)
, m_pos(pos)
, m_radius(radius)
{}
float getRadius() const { return m_radius; }
private:
Vec2 m_pos;
float m_radius;
};
static void declare()
{
ponder::Enum::declare<ShapeType>()
;
ponder::Class::declare<Vec2>()
.constructor<float,float>()
.property("x", &Vec2::x)
.property("y", &Vec2::y)
;
ponder::Class::declare<Shape>()
.property("type", &Shape::getType)
;
ponder::Class::declare<Circle>()
.base<Shape>()
.property("type", &Shape::getType)
.property("radius", &Circle::getRadius)
;
}