oop_in_c/Rhomb.h

77 lines
1.5 KiB
C
Raw Normal View History

2012-05-02 18:25:52 +04:00
#ifndef __RHOMB_H__
#define __RHOMB_H__
#include "Polygon.h"
typedef struct Rhomb
{
struct Rhomb_vtable
{
/* derived from Object */
const char* (*type) ();
struct Rhomb* (*clone) (const struct Rhomb *this);
void (*destroy) (struct Rhomb *this);
/* derived from Figure */
void (*draw) (const struct Rhomb *this);
double (*area) (const struct Rhomb *this);
/* derived from Polygon */
double (*max_diag) (const struct Rhomb *this);
/* Rhomb virtual methods */
int (*is_square) (const struct Rhomb *this);
} *vtable;
/* derived from Polygon */
size_t npoints;
2012-05-02 19:55:53 +04:00
struct point *points;
2012-05-02 18:25:52 +04:00
} Rhomb;
Rhomb* Rhomb_new (const struct point *points);
2012-05-02 18:25:52 +04:00
static inline const char* Rhomb_type (const Rhomb *this)
{
return this->vtable->type ();
}
static inline Rhomb* Rhomb_clone (const Rhomb *this)
{
return this->vtable->clone (this);
}
static inline void Rhomb_destroy (Rhomb *this)
{
this->vtable->destroy (this);
}
static inline void Rhomb_draw (const Rhomb *this)
{
this->vtable->draw (this);
}
static inline double Rhomb_area (const Rhomb *this)
2012-05-02 18:25:52 +04:00
{
return this->vtable->area (this);
2012-05-02 18:25:52 +04:00
}
static inline double Rhomb_max_diag (const Rhomb *this)
{
return this->vtable->max_diag (this);
2012-05-02 18:25:52 +04:00
}
static inline int Rhomb_is_square (const Rhomb *this)
{
return this->vtable->is_square (this);
}
2012-05-02 18:25:52 +04:00
/* considered to be protected */
void Rhomb_constructor (Rhomb *this, const struct point *points);
2012-05-02 18:25:52 +04:00
void Rhomb_destructor (Rhomb *this);
void Rhomb_copy (Rhomb *dest, const Rhomb *src);
#endif // __RHOMB_H__