// Interface for the road chunk class - base for Intersection and RoadSegment - // and for the class RoadChunkList: a linked list of RoadChunks. // CSE143 Spring '01 // Homework 6 #ifndef _ROAD_CHUNK_LIST_H #define _ROAD_CHUNK_LIST_H #include "sim_object.h" #include "road_chunk.h" // RoadChunkList: a linked list of RoadChunk objects (i.e. pointers to objects // of classes derived from RoadChunk). // The list exposes the SimObject interface, and performs each SimObject // operation on all RoadChunk objects that it contains. In addition, it cleans // up dynamic memory by deleting all contained objects upon destruction. class RoadChunkList : public SimObject { public: // Construct an empty list RoadChunkList(); // Destructor: delete all contained road chunk objects virtual ~RoadChunkList(); // Draw all contained objects. virtual void draw(GP142Display& gp); // Update all contained objects. virtual void tick(); // Prepend a new road chunk object to the list; the object must have been // allocated using "new", and will be deleted when the destructor for this // object is called. virtual void addRoadChunk(RoadChunk *newChunk); private: // Node: one link in the list. struct Node { RoadChunk *chunk; Node *next; }; Node *head; // Head of the list }; #endif