BWAPI
Public Member Functions | Private Attributes
TaskPump Class Reference

#include <TaskPump.h>

Collaboration diagram for TaskPump:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TaskPump (BWAPI::UnitType type, TaskType taskType, BuildingLocation location=BuildingLocation::Base)
void update ()
void changeTargetQuantity (int iQuantity)

Private Attributes

BWAPI::UnitType mType
TaskType mTaskType
BuildingLocation mLocation
int mTargetQuantity
std::list< TaskPointermQueuedItems

Detailed Description

Definition at line 8 of file TaskPump.h.


Constructor & Destructor Documentation

Definition at line 5 of file TaskPump.cpp.

        : mType(type)
        , mTaskType(taskType)
        , mLocation(location)
        , mTargetQuantity(0)
{
}

Member Function Documentation

void TaskPump::changeTargetQuantity ( int  iQuantity) [inline]

Definition at line 15 of file TaskPump.h.

References mTargetQuantity.

Referenced by ResourceManagerClass::update().

{ mTargetQuantity = iQuantity; }

Here is the caller graph for this function:

void TaskPump::update ( )

Definition at line 13 of file TaskPump.cpp.

References Singleton< T >::Instance(), mLocation, mQueuedItems, mTargetQuantity, mTaskType, and mType.

Referenced by ResourceManagerClass::update().

{
        for(std::list<TaskPointer>::iterator it = mQueuedItems.begin(); it != mQueuedItems.end();)
        {
                if((*it)->hasEnded())
                        mQueuedItems.erase(it++);
                else
                        ++it;
        }

        int currentTotal = mQueuedItems.size();
        for(std::list<TaskPointer>::iterator it2 = mQueuedItems.begin(); it2 != mQueuedItems.end();)
        {
                if(currentTotal > mTargetQuantity && !(*it2)->inProgress())
                {
                        (*it2)->cancel();
                        mQueuedItems.erase(it2++);
                        --currentTotal;
                }
                else
                        ++it2;
        }

        while(currentTotal > mTargetQuantity && !mQueuedItems.empty())
        {
                (*mQueuedItems.rbegin())->cancel();
                mQueuedItems.pop_back();
                --currentTotal;
        }

        while(currentTotal < mTargetQuantity)
        {
                TaskPointer tempPtr = TaskManager::Instance().build(mType, mTaskType, mLocation);

                mQueuedItems.push_back(tempPtr);

                ++currentTotal;
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 20 of file TaskPump.h.

Referenced by update().

std::list<TaskPointer> TaskPump::mQueuedItems [private]

Definition at line 24 of file TaskPump.h.

Referenced by update().

Definition at line 22 of file TaskPump.h.

Referenced by changeTargetQuantity(), and update().

Definition at line 19 of file TaskPump.h.

Referenced by update().

Definition at line 18 of file TaskPump.h.

Referenced by update().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines