Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members

gutk::Region Class Reference

#include <region.h>

Collaboration diagram for gutk::Region:

Collaboration graph
[legend]
List of all members.

Detailed Description

Class Region encapsulates a group of points as belonging to one entity, the region.

Any set of objects of class Point can form a region. Internally this class is implemented as a doubly-linked list.


Public Member Functions

 Region (void)
 Default constructor.

 Region (const Region &r)
 Copy constructor.

 ~Region ()
 Destroyer If the region has only one reference, then destroyer deletes the region memory is.

void addPoint (const gutk::Point &p)
 Adds a Point to the Region.

void addPoint (double n, double m)
 Adds a Point (n, m) to the Region.

void pop (void)
 Pops a point from the list.

gutk::Point getPoint (void)
 Returns the current Point of the list.

void refresh (void)
 Sets the current-point pointer of the list to the first-point pointer in the list.

int getSize (void)
 Returns the size of the list.

gutk::Point getLastPoint (void)
 Returns the last Point object in the list.

void destroy (void)
 Destroys the current object.

void operator= (const Region &r)
 Overloaded assignment operator.


Constructor & Destructor Documentation

gutk::Region::Region void   ) 
 

Default constructor.

Does nothing and only the skeletal memory is initialised.

gutk::Region::Region const Region r  ) 
 

Copy constructor.

This is leads to an initialisation only by reference. The original object and the new object share the same data. But the user should keep in mind that passing an empty object to a function would result in a call by value, where as passing a non-empty object would result in call by reference.

The user should also keep in mind that empty objects will not be copied by reference. i.e. copy construction using an empty object followed by data creation would lead to objects have different data-space in memory.

Region r1;
Region r2(r1);
r1.addPoint(Point(x, y));

After the above code snippet is executed, size of r1 is 1, where as size of r2 is still 0.

gutk::Region::~Region  ) 
 

Destroyer If the region has only one reference, then destroyer deletes the region memory is.

If the region has more than one reference, then the destroyer just decrements the reference count by 1.


Member Function Documentation

void gutk::Region::addPoint double  n,
double  m
 

Adds a Point (n, m) to the Region.

The pointed added is pushed on the list. i.e, the point added to a list of size 'n' will be the '(n+1)th' point in the list.

void gutk::Region::addPoint const gutk::Point p  ) 
 

Adds a Point to the Region.

The pointed added is pushed on the list. i.e, the point added to a list of size 'n' will be the '(n+1)th' point in the list.

void gutk::Region::destroy void   ) 
 

Destroys the current object.


Destroys all the memory associated with the object by repetitive calls to the pop member function. In case of an object with multiple references is destroyed to empty-ness, then the multiple references would no longer hold. Each individual object would have its own data in memory on subsequent refilling of the object.

gutk::Point gutk::Region::getLastPoint void   ) 
 

Returns the last Point object in the list.


Returns gutk::Point(0, 0) if the list is empty.

gutk::Point gutk::Region::getPoint void   ) 
 

Returns the current Point of the list.

Returns (0, 0) if the list is empty or if the current-point pointer has reached the end of the list.

int gutk::Region::getSize void   ) 
 

Returns the size of the list.


This function helps is checking the bounds of list access.

void gutk::Region::operator= const Region r  ) 
 

Overloaded assignment operator.

It is only a reference copier. i.e., the lvalue and the rvalue of the assignment operator will share the same data in memory.

void gutk::Region::pop void   ) 
 

Pops a point from the list.

This function does nothing if the list is empty.
In case of an object with multiple references is pop-ed out to empty-ness, then the multiple references would no longer hold. Each individual object would have its own data in memory on subsequent refilling of the object.

void gutk::Region::refresh void   ) 
 

Sets the current-point pointer of the list to the first-point pointer in the list.

The current-point pointer will point to NULL if the list is empty.


The documentation for this class was generated from the following file:
Generated on Mon Nov 22 11:12:41 2004 for ImprolaLib by doxygen 1.3.7