ICT290 / src / ShaysWorld / PlaneLinkedList.h
PlaneLinkedList.h
Raw
//  PlaneLinkedList.h
//  Header file for the PlaneLinkedList class
//  Linked List used to store nodes (PlaneNode) which contain the co-ordinates
//  of the of each plain used in the program.
//
//	The program will split the world into four quadrants and creates a linked
// list to
//  store the bounding box details for each
//
//  Author:  Shay Leary
//  April 2005
//--------------------------------------------------------------------------------------

#ifndef PLAINLINKED_LIST_H
#define PLAINLINKED_LIST_H

//--------------------------------------------------------------------------------------

#include "PlaneNode.h"

//--------------------------------------------------------------------------------------

class PlaneLinkedList {
   public:
    // constructor creates pointer to first node
    PlaneLinkedList() { m_first = new PlaneNode; }

    virtual ~PlaneLinkedList() { Clear(); }

    // Privatised copy constructor and assignment operator
    PlaneLinkedList(const PlaneLinkedList&) = delete;
    PlaneLinkedList& operator=(const PlaneLinkedList&) = delete;

    //----------------------------------------------------------------------------------

    // clears linked list and frees memory
    void Clear();

    // add a node to the start of the linked list
    bool AddToStart(const int tempType,
                    const GLdouble tempXs,
                    const GLdouble tempXe,
                    const GLdouble tempYs,
                    const GLdouble tempYe,
                    const GLdouble tempZs,
                    const GLdouble tempZe);

    // set the values of the node data
    void SetData(const int& ptrCount,
                 const int tempType,
                 const GLdouble tempXs,
                 const GLdouble tempXe,
                 const GLdouble tempYs,
                 const GLdouble tempYe,
                 const GLdouble tempZs,
                 const GLdouble tempZe);

    //----------------------------------------------------------------------------------
    //  Get Methods
    //----------------------------------------------------------------------------------
    GLdouble GetType(int ptrCount);
    GLdouble GetXstart(int ptrCount);
    GLdouble GetXend(int ptrCount);
    GLdouble GetYstart(int ptrCount);
    GLdouble GetYend(int ptrCount);
    GLdouble GetZstart(int ptrCount);
    GLdouble GetZend(int ptrCount);

    // Return size of list
    int GetListSize();

    // Return the address of the link to the next node in the list
    PlaneNode* GetNext() const { return m_first->GetNext(); }
    // Return the address of the link to the first node in the list
    PlaneNode* GetFirst() const { return m_first; }

    //--------------------------------------------------------------------------------------

   private:
    // pointer to first node in list
    PlaneNode* m_first;

    // used to clear memory
    void Delete(PlaneNode* before);
};

#endif

//--------------------------------------------------------------------------------------