BWAPI
UAlbertaBot_src/Projects/UAlbertaBot/Source/base/BuildOrderQueue.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "Common.h"
00004 #include <BWTA.h>
00005 #include "MetaType.h"
00006 
00007 #define PRIORITY_TYPE int
00008 
00009 template <class T>
00010 class BuildOrderItem {
00011 
00012 public:
00013 
00014         MetaType                        metaType;               // the thing we want to 'build'
00015         T                                       priority;       // the priority at which to place it in the queue
00016         bool                            blocking;       // whether or not we block further items
00017 
00018         BuildOrderItem(MetaType m, T p, bool b) : metaType(m), priority(p), blocking(b) {}
00019 
00020         bool operator<(const BuildOrderItem<T> &x) const
00021         {
00022                 return priority < x.priority;
00023         }
00024 };
00025 
00026 class BuildOrderQueue {
00027 
00028         std::deque< BuildOrderItem<PRIORITY_TYPE> >                     queue;
00029 
00030         PRIORITY_TYPE lowestPriority;           
00031         PRIORITY_TYPE highestPriority;
00032         PRIORITY_TYPE defaultPrioritySpacing;
00033 
00034         int numSkippedItems;
00035 
00036 public:
00037 
00038         BuildOrderQueue();
00039 
00040         void clearAll();                                                                                        // clears the entire build order queue
00041         void skipItem();                                                                                        // increments skippedItems
00042         void queueAsHighestPriority(MetaType m, bool blocking);         // queues something at the highest priority
00043         void queueAsLowestPriority(MetaType m, bool blocking);          // queues something at the lowest priority
00044         void queueItem(BuildOrderItem<PRIORITY_TYPE> b);                        // queues something with a given priority
00045         void removeHighestPriorityItem();                                                               // removes the highest priority item
00046         void removeCurrentHighestPriorityItem();
00047 
00048         int getHighestPriorityValue();                                                          // returns the highest priority value
00049         int     getLowestPriorityValue();                                                               // returns the lowest priority value
00050         size_t size();                                                                                                  // returns the size of the queue
00051 
00052         bool isEmpty();
00053 
00054         void removeAll(MetaType m);                                                                     // removes all matching meta types from queue
00055 
00056         BuildOrderItem<PRIORITY_TYPE> & getHighestPriorityItem();       // returns the highest priority item
00057         BuildOrderItem<PRIORITY_TYPE> & getNextHighestPriorityItem();   // returns the highest priority item
00058 
00059         bool canSkipItem();
00060         bool hasNextHighestPriorityItem();                                                              // returns the highest priority item
00061 
00062         void drawQueueInformation(int x, int y, int index);
00063 
00064         // overload the bracket operator for ease of use
00065         BuildOrderItem<PRIORITY_TYPE> operator [] (int i); 
00066 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines