subsector Class Reference

#include <subsector.hpp>

Inheritance diagram for subsector:

Inheritance graph
[legend]
Collaboration diagram for subsector:

Collaboration graph
[legend]
List of all members.

Detailed Description

A subsector is a grid or parsecs 8 wide by 10 deep. Not all are occupied.

See also:
sparseArray

Definition at line 41 of file subsector.hpp.

Public Member Functions

 subsector ()
 subsector (int position)
void setDensity (int d)
int getDensity ()
void addParsec (parsec *p)
void addParsec (int row, int column, parsec *p)
void addParsec (int row, int column)
char * asText ()


Constructor & Destructor Documentation

subsector::subsector (  ) 

A non-parametized constructor for generating subsectors of the book 3 nature.

Definition at line 43 of file subsector.cpp.

References parsecCoordinate::column, and parsecCoordinate::row.

00043                     {
00044         density=DENSITY_NORMAL; // This is the default from book 3
00045         
00046         parsecStart.row=1;
00047         parsecStart.column=1;
00048         parsecEnd.row=10;
00049         parsecEnd.column=8;
00050         
00051         this->populateGrid();
00052         
00053 }

subsector::subsector ( int  position  ) 

Generic constructor

Parameters:
position -- Integer offset into the sector this subsector belongs to

Definition at line 55 of file subsector.cpp.

References parsecCoordinate::column, and parsecCoordinate::row.

00055                                  : sparseArray() {
00056         int row;
00057         int column;
00058         
00059         density=DENSITY_NORMAL;
00060         
00061         parsecStart = markers[position-1];
00062         parsecEnd.row=parsecStart.row+9;
00063         parsecEnd.column=parsecStart.column+7;
00064         
00065         this->populateGrid();
00066         
00067         
00068 }


Member Function Documentation

void subsector::addParsec ( int  row,
int  column 
)

Last form of this: add a parsec to the place given, but generate a new parsec from within the method.

Parameters:
row integer value of the row
column integer value of the column

Definition at line 89 of file subsector.cpp.

References sparseArray::addAt().

00089                                            {
00090         parsec *p = new parsec();
00091         
00092         this->addAt(row,column,p);
00093 }

Here is the call graph for this function:

void subsector::addParsec ( int  row,
int  column,
parsec p 
)

Add parsec at the location provided, set the parsec's row and column accoridingly.

Parameters:
row integer value for the row
column integer value for the column
p pointer to a parsec object.

Definition at line 95 of file subsector.cpp.

References sparseArray::addAt().

00095                                                      {
00096         this->addAt(row,column,p);
00097 }

Here is the call graph for this function:

void subsector::addParsec ( parsec p  ) 

Add a new parsec to this subsector. The row and column in this case being used for placement is embedded in the parsec object itself.

Parameters:
p pointer to a parsec to add

Definition at line 81 of file subsector.cpp.

References sparseArray::addAt(), sparseArrayNode::getColumn(), and sparseArrayNode::getRow().

00081                                    {
00082         int row = p->getRow();
00083         int column = p->getColumn();
00084         
00085         this->addAt(row,column,p);
00086         
00087 }

Here is the call graph for this function:

char * subsector::asText (  ) 

Create one very large array of characters representing the subsector (in a book 3 layout) and return a pointer to it.

Returns:
pointer to array of characters representing the subsector.

Definition at line 120 of file subsector.cpp.

References parsec::asText(), parsecCoordinate::column, and parsecCoordinate::row.

00120                        {
00121         int row;
00122         int column;
00123         char *buffer;
00124         
00125         buffer = (char*) malloc(128);
00126         buffer[0]='\0';
00127         sprintf(buffer,"%s\n\n","********** Subsector Listing ***************");
00128         
00129         
00130         for(row=parsecStart.row;row<=parsecEnd.row;row++){
00131                 for(column=parsecStart.column;column<=parsecEnd.column;column++){
00132                         parsec* p = (parsec *)this->findAt(row,column);
00133                         if ( p!= 0 ) {
00134                                 char *newtext = p->asText();
00135                                 char *newBuffer = (char*) malloc(strlen(newtext)+strlen(buffer)+10);
00136                                 newBuffer[0]='\0';
00137                                 sprintf(newBuffer,"%s%s\n",buffer,newtext);
00138                                 free(buffer);
00139                                 buffer=newBuffer;
00140                         }
00141                 }
00142         }
00143         return buffer;
00144 }

Here is the call graph for this function:

int subsector::getDensity (  ) 

get the density attribute

Returns:
integer value for the density attribute

Definition at line 71 of file subsector.cpp.

00071                           {
00072         return density;
00073 }

void subsector::setDensity ( int  d  ) 

set the density attribute

Parameters:
d integer value for density

Definition at line 75 of file subsector.cpp.

00075                                {
00076         density=d;
00077         this->populateGrid();
00078         
00079 }


The documentation for this class was generated from the following files:
Generated on Fri Mar 7 16:43:21 2008 for frpuniverse by  doxygen 1.4.7