Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

project.h

Go to the documentation of this file.
00001 // -*- C++ -*- 
00002 /*
00003 ** Copyright (C) 2000 Alan McIvor <alan@mcivor.gen.nz>
00004 **  
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 ** 
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 ** 
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software 
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 #ifndef PROJECT_H
00020 #define PROJECT_H
00021 
00022 #include <cstdio>
00023 #include <string>
00024 #include <time.h>
00025 
00026 #ifdef __EMX__
00027 #define strcasecmp(s1,s2) stricmp((s1),(s2))
00028 #define strncasecmp(s1,s2,l) strnicmp((s1),(s2),(l))
00029 #endif
00030 
00031 #include "task.h"
00032 #include "resource.h"
00033 #include "milestone.h"
00034 #include "projectExceptions.h"
00035 
00036 /* Constants */
00037 
00038 /* these are used to load different start and finish times from the file */
00039 #define TNORM 0
00040 #define TACTUAL 1
00041 #define TBASE 2
00042 
00043 #ifdef VARIABLE
00044 #  undef VARIABLE
00045 #endif
00046 
00047 typedef struct dayname
00048 {
00049     time_t t;
00050     char *s;
00051     int  num;
00052 }
00053 DAYNAME;
00054 
00055 class Project
00056 {
00057 
00058 public:
00059 
00060     typedef TASK::PTRLIST::const_iterator TPLCI;
00061     typedef RESOURCE::PTRLIST::const_iterator RPLCI;
00062     typedef MILESTONE::PTRLIST::const_iterator MPLCI;
00063     typedef ITEM::PTRLIST::const_iterator IPLCI;
00064 
00065     Project();
00066     ~Project();
00067 
00068     void checkComplete();
00069     void DoScheduling();
00070     void PrintFile();
00071 
00072     int ResListPosition(const char *id);        // for qsort
00073     RESOURCE *FindResource(const char *id);
00074     void AddResource(char *id, char *name);
00075     void SetEfficiency(char *id, double d);
00076     TASK *FindTask(const char *id);
00077     void AddTask(TASK *task);
00078     void AddTask(char *id, char *name, int duration);
00079     int FindDay(char *name);
00080     void Vacation(char *resid, int d1, int d2);
00081     void AddCandidate(const char *taskid, const char *resid);
00082     void BookResource( TASK *t, RESOURCE *parent, RESOURCE *r,
00083                        int tstart, int tfinish, TimeBlock::Type type );
00084     void WorkBlock(const char *taskid, const char *resid,
00085                    int d1, int d2, TimeBlock::Type type);
00086     void WorkBlock( TASK *t, RESOURCE * r, 
00087                     int d1, int d2, TimeBlock::Type type);
00088     void AddMilestone(char *id, char *name);
00089     MILESTONE * FindMilestone(char *id);
00090     void TaskNote(char *taskid, char *text);
00091     void ResourceNote(char *resid, char *text);
00092     void Blockify(char *id);
00093     void AddDescription(char *id, char *desc);
00094     void AddGroup(char *id, char **members, int Nmembers);
00095     void AddDependencies(char *taskid, char **tasks, int Ntasks);
00096     void AddAfter(char *msid, char **tasks, int Ntasks);
00097     void SetCompletion(char *task, char *complete);
00098     void StartTask(char *taskid, char *dayname, int type);
00099     void FinishTask(char *taskid, char *dayname, int type);
00100     void StartTask(TASK *t, int  d, int type);
00101     void FinishTask(TASK *t, int d, int type);
00102     void DaysDone(char *taskid, int days);
00103     void SetResourceRate(char *resid, char *camount);
00104     void AddTaskItem(char *taskid, char *camount, char *desc);
00105     void SetProjectRate(char *camount);
00106     void AddProjectItem(char *camount, char *desc);
00107     void SetStartTime(const char *year, const char *month, const char *mday);
00108     void SetStartTime(time_t when);
00109     void SetFinishDate(char *dayname);
00110     void AddNetworkX(char *taskid, char *xstr);
00111     void AddNetworkY(char *taskid, char *ystr);
00112     void AddStartNetworkY(char *ystr);
00113     void AddFinishNetworkY(char *ystr);
00114     void SetDateFormat( char * format );
00115     void SortTasks(bool tg_sortbyresource);
00116 
00117     char *sStartDay() { return days[0].s; };
00118     char *sFinishDay() { return days[finishDay].s; };
00119     int  nTasks() { return mTaskList.size(); };
00120     TASK *sortedTask(int i) { return mSortedTaskList[i]; };
00121     char *sDays(int i) { return days[i].s; };
00122     void SortMilestones();
00123     int nMilestones() { return mMilestoneList.size(); };
00124     MILESTONE *sortedMilestone(int i);
00125     TPLCI beginTaskList() { return mTaskList.begin(); };
00126     TPLCI endTaskList() { return mTaskList.end(); };
00127     int nDays(int i) { return days[i].num; };
00128     int tDays(int i) { return days[i].t; };
00129     int networkStartY() { return pc_start_ny; };
00130     int networkFinishY() { return pc_finish_ny; };
00131 
00132     MPLCI beginMilestoneList() { return mMilestoneList.begin(); };
00133     MPLCI endMilestoneList() { return mMilestoneList.end(); };
00134 
00135     RPLCI beginResourceList() { return mResourceList.begin(); };
00136     RPLCI endResourceList() { return mResourceList.end(); };
00137 
00138     double itemCost();
00139     int numItems() { return mItems.size(); };
00140     IPLCI begin_items() { return mItems.begin(); };
00141     IPLCI end_items() { return mItems.end(); };
00142 
00143 
00144     // utils
00145     int ResourceIsUsedForTask( RESOURCE *r, TASK *t, int dayNo );
00146     char *dayNames[8];
00147     void Error(char *fmt, ...);
00148 
00149 # define VARIABLE(AA,BB,CC) AA BB;
00150 #include "globals.i"
00151 
00152 private:
00153 
00154     DAYNAME  days[MAX_TIME];
00155 
00156     TASK::PTRLIST mTaskList;
00157     TASK::PTRLIST mSortedTaskList;
00158     MILESTONE::PTRLIST mMilestoneList;
00159     MILESTONE::PTRLIST mSortedMilestoneList;
00160     RESOURCE::PTRLIST mResourceList;
00161 
00162     void LoadDays();
00163 
00164     void ReverseBookResource( TASK *t, RESOURCE *parent, RESOURCE *r,
00165                               int tstart, int tfinish, TimeBlock::Type type );
00166     void AssignResource(TASK *t, RESOURCE *r, int tstart);
00167     int do_match(const char *str, const char *regexp, int case_sig);
00168 
00169     int FirstFreeTime(TASK *task, RESOURCE *r, int earliest, int duration);
00170     void ReverseAssignResource(TASK *t, RESOURCE *r, int tfinish);
00171     RESOURCE *FindEarliestResource(TASK *t, int t_earliest);
00172     void AssignTask(TASK *t);
00173     void ReverseAssignTask(TASK *t);
00174     void PredictOverruns();
00175     void ReverseScheduleTasks();
00176     void ScheduleMilestones();
00177     void ScheduleTasks();
00178     void printTaskList();
00179 
00180     char *monthNames[13];
00181 
00182     void Debug(char *fmt, ...);
00183     void Warning(char *fmt, ...);
00184 
00185     vector<ITEM *> mItems;
00186 
00187 };
00188 
00189 
00190 #endif
00191 
00192 

Generated on Wed Feb 18 22:23:54 2004 for Opensched by doxygen1.2.15