00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <iostream>
00020 #include <string>
00021
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025
00026 using namespace std;
00027
00028 #include "project.h"
00029 #include "projectFile.h"
00030 #include "vacation.h"
00031
00033 int Project::do_match(const char *str, const char *regexp, int case_sig)
00034 {
00035 const char * p;
00036
00037 for ( p = regexp ; *p && *str ; )
00038 {
00039 switch ( *p )
00040 {
00041 case '?':
00042 str++;
00043 p++;
00044 break;
00045
00046 case '*':
00047
00048
00049 p++;
00050 if (!*p)
00051 return 1;
00052
00053 while(*str)
00054 {
00055 while ( *str && (case_sig ? (*p != *str) : (toupper(*p)!=toupper(*str))))
00056 str++;
00057 if (do_match(str, p, case_sig))
00058 return 1;
00059 if (!*str)
00060 return 0;
00061 else
00062 str++;
00063 }
00064
00065 return 0;
00066
00067 default:
00068 if (case_sig)
00069 {
00070 if (*str != *p)
00071 return 0;
00072 }
00073 else
00074 {
00075 if (toupper(*str) != toupper(*p))
00076 return 0;
00077 }
00078
00079 str++, p++;
00080 break;
00081 }
00082 }
00083
00084 if ( !*p && !*str )
00085 return 1;
00086
00087 if ( ( !*p && str[0] == '.' ) && ( str[1] == 0 ) )
00088 return(1);
00089
00090 if (!*str && *p == '?')
00091 {
00092 while (*p == '?')
00093 p++;
00094 return !*p;
00095 }
00096
00097 if (!*str && (*p == '*' && p[1] == '\0'))
00098 return 1;
00099
00100 return 0;
00101 }
00102
00103
00104
00105 TASK *Project::FindTask(const char *id)
00106 {
00107 for ( TPLCI pt = mTaskList.begin() ;
00108 pt != mTaskList.end() ;
00109 pt++ )
00110 {
00111 if ( (*pt) == NULL )
00112 Error("Empty list entry found in FindTask()");
00113 if ( (*pt)->id() == NULL )
00114 Error("Task with no id found in FindTask()");
00115 if ( strcasecmp((*pt)->id(),id) == 0 )
00116 return *pt;
00117 }
00118
00119 return NULL;
00120 }
00121
00122 MILESTONE *Project::FindMilestone(char *id)
00123 {
00124 for ( MPLCI pm = mMilestoneList.begin() ; pm != mMilestoneList.end() ; pm++ )
00125 {
00126 if ( (*pm)->id() == NULL )
00127 Error("Milestone with no id found in FindMilestone()");
00128 if ( strcasecmp((*pm)->id(),id) == 0 )
00129 return *pm;
00130 }
00131
00132 return NULL;
00133 }
00134
00135 void Project::DaysDone(char *taskid, int days)
00136 {
00137 TASK *task;
00138
00139 if ( ( task = FindTask(taskid) ) == NULL )
00140 Error("Invalid task id %s", taskid);
00141
00142 task->setDaysDone( days );
00143 }
00144
00145
00146 void ProjectFile::AddTaskGraph( char *d1name, char *d2name, char *fname )
00147 {
00148 int d1, d2;
00149
00150 d1 = mProject.FindDay(d1name);
00151 if ( d1 == -1 )
00152 Error("Invalid day name %s", d1name);
00153
00154 d2 = mProject.FindDay(d2name);
00155 if ( d2 == -1 )
00156 Error("Invalid day name %s", d2name);
00157
00158 mReporter.AddTaskGraph(d1, d2, fname);
00159 }
00160
00161
00162 void Reporter::AddTaskGraph( int d1, int d2, char *fname )
00163 {
00164 string fn = fname;
00165 TASKGRAPH * tg = new TASKGRAPH( d1, d2, fn );
00166 mTaskGraphs.push_back(tg);
00167 }
00168
00169
00170 void Reporter::AddNetworkDiagram(int c1, int c2, char *fname)
00171 {
00172 if ( c1 < 0 )
00173 Error("Invalid first column '%d'", c1 );
00174 if( c2 < c1 )
00175 Error("Invalid second column '%d'", c2 );
00176
00177 string fn = fname;
00178 TASKNET * tn = new TASKNET( c1, c2, fn );
00179 mTaskNets.push_back(tn);
00180 }
00181
00182
00183 void Project::AddNetworkX(char *taskid, char *xstr)
00184 {
00185 TASK *task;
00186
00187 if ( ( task = FindTask(taskid) ) == NULL )
00188 Error("Invalid task id %s", taskid);
00189
00190 task->nx = atoi(xstr);
00191 }
00192
00193
00194
00195
00196 void Project::AddNetworkY(char *taskid, char *ystr)
00197 {
00198 TASK *task;
00199
00200 if ( ( task = FindTask(taskid) ) == NULL )
00201 Error("Invalid task id %s", taskid);
00202
00203 task->ny = atoi(ystr);
00204 }
00205
00206
00207 void Project::AddStartNetworkY(char *ystr)
00208 {
00209 pc_start_ny = atoi(ystr);
00210 }
00211
00212
00213 void Project::AddFinishNetworkY(char *ystr)
00214 {
00215 pc_finish_ny = atoi(ystr);
00216 }
00217
00218
00219 RESOURCE *Project::FindResource(const char *id)
00220 {
00221 for ( RPLCI rl = mResourceList.begin() ; rl != mResourceList.end() ; rl++ )
00222 {
00223 if ( (*rl)->id() == NULL )
00224 Error("Resource ID == NULL in FindResource");
00225 if( strcasecmp((*rl)->id(),id)==0 )
00226 return *rl;
00227 }
00228
00229 return NULL;
00230 }
00231
00232
00233 void Project::AddResource(char *id, char *name)
00234 {
00235
00236 if ( FindResource(id) != NULL )
00237 Error("Duplicate resource definition for %s", id);
00238
00239 RESOURCE * r = new RESOURCE( id, name );
00240
00241 mResourceList.push_back(r);
00242 }
00243
00244
00245 void Project::SetEfficiency(char *id, double e)
00246 {
00247 RESOURCE *r;
00248
00249 if ( ( r = FindResource(id) ) == NULL )
00250 Error("Invalid resource id %s", id);
00251 r->setEfficiency(e);
00252 }
00253
00254
00255 void Project::AddGroup(char *id, char **members, int Nmembers)
00256 {
00257 if ( FindResource(id) != NULL )
00258 Error("There is already a resource called %s", id);
00259 AddResource(id, "Resource group");
00260 RESOURCE * r = FindResource(id);
00261 r->is_group = 1;
00262 for ( int i = 0; i < Nmembers; ++i )
00263 {
00264 RESOURCE * m = FindResource(members[i]);
00265 if ( m == NULL )
00266 Error("Invalid group member %s", members[i]);
00267 r->contains.push_back( m );
00268 m->belongs_to.push_back( r );
00269 }
00270 }
00271
00272
00273 void Project::AddTask(TASK *task)
00274 {
00275 if ( FindTask(task->id()) != NULL )
00276 Error("Duplicate task %s", task->id());
00277 if ( task->duration() <= 0 )
00278 Error("Invalid duration '%d'", task->duration());
00279
00280 mTaskList.push_back(task);
00281 }
00282
00283 void Project::AddTask(char *id, char *name, int duration)
00284 {
00285 if ( id == NULL )
00286 Error("NULL task id");
00287
00288 TASK * t = new TASK(id, name, duration);
00289 AddTask(t);
00290 }
00291
00292 void Project::Blockify(char *id)
00293 {
00294 TASK *t;
00295
00296 if ( ( t = FindTask(id) ) == NULL )
00297 Error("Invalid task %s", id);
00298
00299 t->Blockify();
00300 }
00301
00302
00303 void Project::AddDescription(char *id, char *desc)
00304 {
00305 TASK *t;
00306 t = FindTask(id);
00307 if( t==NULL )
00308 Error("Invalid task id %s",id);
00309 t->setDesc(desc);
00310 }
00311
00312
00313 void Project::SetCompletion(char *task, char *complete)
00314 {
00315 TASK * t = FindTask(task);
00316 if ( t == NULL )
00317 Error("Invalid task id %s",task);
00318 double c = atof(complete);
00319 t->setPercentComplete(c);
00320 }
00321
00322
00323 void ProjectFile::AddCandidates(char *taskid, char **resources, int Nresources)
00324 {
00325 for ( int i = 0; i < Nresources; ++i )
00326 {
00327 mProject.AddCandidate(taskid, resources[i]);
00328 }
00329 }
00330
00331 void Project::AddCandidate(const char *taskid, const char *resid)
00332 {
00333 TASK *task;
00334 RESOURCE *res;
00335
00336 if ( ( task = FindTask(taskid) ) == NULL )
00337 Error("Invalid task id %s", taskid);
00338
00339 if ( (res = FindResource(resid) ) == NULL )
00340 Error("Invalid resource id %s", resid);
00341
00342 task->addCandidate(res);
00343 }
00344
00345 void Project::TaskNote(char *taskid, char *text)
00346 {
00347 TASK *t;
00348 t = FindTask(taskid);
00349 if( t==NULL )
00350 Error("Invalid task ID '%s'", taskid);
00351 t->AddNote(text);
00352 }
00353
00354
00355 void Project::ResourceNote(char *resid, char *text)
00356 {
00357 RESOURCE * r = FindResource(resid);
00358 if( r==NULL )
00359 Error("Invalid resource ID '%s'", resid);
00360 r->AddNote(text);
00361 }
00362
00363
00364 void Project::AddDependencies(char *taskid, char **tasks, int Ntasks)
00365 {
00366 TASK *task = FindTask(taskid);
00367
00368 if ( task == NULL )
00369 Error("Invalid task id %s", taskid);
00370
00371 for ( int i = 0; i < Ntasks; ++i )
00372 {
00373 TASK *reqtask = FindTask(tasks[i]);
00374
00375 if ( reqtask == NULL )
00376 Error("Invalid task id %s", tasks[i]);
00377
00378
00379 task->addDepends(reqtask);
00380
00381
00382 reqtask->addFollows(task);
00383 }
00384 }
00385
00386
00387 void ProjectFile::checkComplete()
00388 {
00389 mProject.checkComplete();
00390 mReporter.checkComplete();
00391 }
00392
00393
00394 void Reporter::checkComplete()
00395 {
00396 return;
00397 }
00398
00399 void Project::SetDateFormat( char * format )
00400 {
00401 if ( date_format != NULL )
00402 Error("Duplicate date format specifier");
00403 date_format = strdup(format);
00404 }
00405
00406
00407 void Project::checkComplete()
00408 {
00409 if ( date_format == NULL )
00410 Error("No date format specified");
00411 if ( strcasecmp(date_format,"raw")==0 )
00412 ;
00413 else if( strcasecmp(date_format,"count")==0 )
00414 ;
00415 else if( strcasecmp(date_format,"calendar")==0 )
00416 ;
00417 else if( strcasecmp(date_format,"iso")==0 )
00418 ;
00419 else
00420 Error("Date_format must be raw/count/calendar/iso");
00421
00422
00423 for ( TPLCI pt = mTaskList.begin() ;
00424 pt != mTaskList.end() ;
00425 pt++ )
00426 {
00427 if ( (*pt)->numCandidates() == 0 )
00428 {
00429 Error("Task %s has no resources",(*pt)->id());
00430 }
00431 }
00432
00433
00434 if ( startTime == 0 )
00435 {
00436 Error("You must specify a start time");
00437 }
00438 }
00439
00440
00441 void Project::StartTask(char *taskid, char *dayname, int type)
00442 {
00443 TASK * t = FindTask(taskid);
00444 if ( t == NULL )
00445 Error("Can't find task %s", taskid);
00446
00447 int d = FindDay(dayname);
00448 if ( d == -1 )
00449 Error("Can't find day %s", dayname);
00450
00451 StartTask(t, d, type);
00452 }
00453
00454
00455 void Project::FinishTask(char *taskid, char *dayname, int type)
00456 {
00457 TASK * t = FindTask(taskid);
00458 if ( t == NULL )
00459 Error("Can't find task %s", taskid);
00460
00461 int d = FindDay(dayname);
00462 if( d == -1 )
00463 Error("Can't find day %s", dayname);
00464
00465 FinishTask(t, d, type);
00466 }
00467
00468 void ProjectFile::WorkBlock(const char *taskid, const char *resid,
00469 char *day1, char *day2, TimeBlock::Type type)
00470 {
00471 int d1 = mProject.FindDay(day1);
00472 if ( d1 == -1 )
00473 Error("Can't find day %s", day1);
00474
00475 int d2 = mProject.FindDay(day2);
00476 if ( d2 == -1 )
00477 Error("Can't find day %s", day2);
00478
00479 mProject.WorkBlock(taskid, resid, d1, d2, type);
00480 }
00481
00482
00483 void Project::WorkBlock(const char *taskid, const char *resid,
00484 int d1, int d2, TimeBlock::Type type)
00485 {
00486 TASK * t = FindTask(taskid);
00487 if ( t == NULL )
00488 Error("Can't find task %s", taskid);
00489
00490 RESOURCE * r = FindResource(resid);
00491 if ( r == NULL )
00492 Error("Can't find resource %s", resid);
00493
00494 if ( d2 < d1 )
00495 Error("Finish date %d before start date %d", d1, d2);
00496
00497
00498 WorkBlock( t, r, d1, d2, type);
00499 }
00500
00502 void ProjectFile::Vacation(char *resid, char *d1name, char *d2name)
00503 {
00504 int d1, d2;
00505
00506 d1 = mProject.FindDay(d1name);
00507 if ( d1 == -1 )
00508 Error("Can't find day %s", d1name);
00509 if ( d2name == NULL )
00510 d2 = d1;
00511 else
00512 {
00513 d2 = mProject.FindDay(d2name);
00514 if ( d2 == -1 )
00515 Error("Can't find day %s", d2name);
00516 }
00517
00518 mProject.Vacation(resid, d1, d2);
00519 }
00520
00521
00522 void Project::Vacation(char *resid, int d1, int d2)
00523 {
00524 int found_resource = 0;
00525
00526 if ( d2 < d1 )
00527 Error("Invalid vacation. Start after finish?");
00528
00529 for ( RPLCI rl = mResourceList.begin() ; rl != mResourceList.end() ; rl++ )
00530 {
00531 RESOURCE * r = *rl;
00532 if ( r->is_group )
00533 continue;
00534 if ( do_match(r->id(), resid, 0) == 0 )
00535 continue;
00536
00537 found_resource = 1;
00538
00539
00540 VACATION *vacation = new VACATION(1);
00541 AddTask(vacation);
00542 AddCandidate(vacation->id(), r->id());
00543 WorkBlock(vacation->id(), r->id(), d1, d2, TimeBlock::MANUAL_SCHEDULE);
00544
00545 }
00546
00547 if ( found_resource == 0 )
00548 Error("Could not find resources matching %s", resid);
00549 }
00550
00551 void Project::AddMilestone(char *id, char *name)
00552 {
00553 if ( FindMilestone(id) != NULL )
00554 Error("Duplicate milestone %s", id);
00555
00556 MILESTONE *m = new MILESTONE(id, name);
00557
00558 mMilestoneList.push_back( m );
00559 }
00560
00561
00562 void Project::AddAfter(char *msid, char **tasks, int Ntasks)
00563 {
00564 MILESTONE *milestone = FindMilestone(msid);
00565 if ( milestone == NULL )
00566 Error("Invalid milestone id %s", msid);
00567
00568 for ( int i = 0; i < Ntasks; ++i )
00569 {
00570 TASK *reqtask = FindTask(tasks[i]);
00571 if ( reqtask == NULL )
00572 Error("Invalid task id %s", tasks[i]);
00573
00574 milestone->addDepends(reqtask);
00575 }
00576 }
00577
00578
00579 void Project::SetResourceRate(char *resid, char *camount)
00580 {
00581 RESOURCE *r;
00582
00583 r = FindResource(resid);
00584 if ( r == NULL )
00585 Error("Can't find resource %s", resid);
00586
00587 r->setRate(atof(camount));
00588 }
00589
00590
00591 void Project::AddTaskItem(char *taskid, char *camount, char *desc)
00592 {
00593 TASK * t = FindTask(taskid);
00594 if ( t == NULL )
00595 Error("Can't find task %s", taskid);
00596
00597 ITEM * item = new ITEM(desc, atof(camount));
00598 t->addItem(item);
00599 }
00600
00601
00602 void Project::SetProjectRate(char *camount)
00603 {
00604 if ( RESOURCE::defaultRate() != -1.0 )
00605 Error("Duplicate definition of project rate");
00606
00607 RESOURCE::setDefaultRate(atof(camount));
00608 }
00609
00610
00611 void Project::AddProjectItem(char *camount, char *desc)
00612 {
00613 ITEM *item = new ITEM(desc, atof(camount));
00614
00615 mItems.push_back(item);
00616 }
00617
00618
00619 void Project::SetFinishDate(char *dayname)
00620 {
00621 int d;
00622
00623 d = FindDay(dayname);
00624 if( d == -1 )
00625 Error("Can't find day %s", dayname);
00626
00627 finishDay = d;
00628 }
00629
00630
00631 void Project::SetStartTime(const char *year,
00632 const char *month,
00633 const char *mday)
00634 {
00635 struct tm t;
00636 t.tm_year = atoi(year)-1900;
00637 t.tm_mon = atoi(month)-1;
00638 t.tm_mday = atoi(mday);
00639 t.tm_sec = 0;
00640 t.tm_min = 0;
00641 t.tm_hour = 0;
00642 t.tm_wday = 0;
00643 t.tm_yday = 0;
00644
00645
00646 time_t startTime = mktime(&t);
00647
00648 SetStartTime(startTime);
00649 }
00650
00651 void Project::SetStartTime( time_t when )
00652 {
00653 startTime = when;
00654 }
00655
00656
00657 void ProjectFile::Load(const char *name)
00658 {
00659 FILE *f;
00660 char buf[BUFLEN], **words;
00661 int Nwords;
00662 int lineno = 0;
00663 int invalid_lines = 0;
00664
00665 f = fopen(name, "r");
00666 if ( f == NULL )
00667 Error("Cannot open data file %s", name);
00668
00669 while ( buf == fgets(buf,BUFLEN,f) )
00670 {
00671 try
00672 {
00673 ++lineno;
00674 Debug("Parsing %s:%d", name, lineno);
00675 Nwords = ParseLine( buf, &words );
00676 if ( Nwords==0 || words[0]==NULL || *words[0]==0 || *words[0]=='#' )
00677 continue;
00678
00679
00680
00681
00682
00683 if ( ( strcasecmp(words[0],"include") == 0 ) && ( Nwords == 2 ) )
00684 {
00685 int old_lineno = lineno;
00686 lineno = 1;
00687 cout << "Loading " << words[1] << endl;
00688 Load(words[1]);
00689 lineno = old_lineno;
00690 }
00691 else if ( ( strcasecmp(words[0],"resource") == 0 ) && ( Nwords == 3 ) )
00692 mProject.AddResource( words[1], words[2] );
00693 else if ( ( strcasecmp(words[0],"resource_note") == 0 ) && ( Nwords == 3 ) )
00694 mProject.ResourceNote(words[1], words[2]);
00695 else if ( ( strcasecmp(words[0],"efficiency") == 0 ) && ( Nwords == 3 ) )
00696 mProject.SetEfficiency(words[1],atof(words[2]));
00697 else if ( ( strcasecmp(words[0],"task") == 0 ) && ( Nwords == 4 ) )
00698 mProject.AddTask(words[1], words[2], atoi(words[3]));
00699 else if ( ( strcasecmp(words[0],"milestone") == 0 ) && ( Nwords == 3 ) )
00700 mProject.AddMilestone(words[1],words[2]);
00701 else if ( ( strcasecmp(words[0],"task_note") == 0 ) && ( Nwords == 3 ) )
00702 mProject.TaskNote(words[1],words[2]);
00703 else if ( ( strcasecmp(words[0],"block") == 0 ) && ( Nwords == 2 ) )
00704 mProject.Blockify(words[1]);
00705 else if ( ( strcasecmp(words[0],"describe") == 0 ) && ( Nwords == 3 ) )
00706 mProject.AddDescription(words[1], words[2]);
00707 else if ( ( strcasecmp(words[0],"group") == 0 ) && ( Nwords>=3 ) )
00708 mProject.AddGroup(words[1],words+2,Nwords-2);
00709 else if ( ( strcasecmp(words[0],"candidate") == 0 ) && ( Nwords>=3 ) )
00710 AddCandidates(words[1], words+2, Nwords-2);
00711 else if ( ( strcasecmp(words[0],"depends") == 0 ) && ( Nwords>=3 ) )
00712 mProject.AddDependencies(words[1],words+2,Nwords-2);
00713 else if ( ( strcasecmp(words[0],"after") == 0 ) && ( Nwords>=3 ) )
00714 mProject.AddAfter(words[1],words+2,Nwords-2);
00715 else if ( ( strcasecmp(words[0],"complete") == 0 ) && ( Nwords == 3 ) )
00716 mProject.SetCompletion(words[1],words[2]);
00717 else if ( ( strcasecmp(words[0],"complete") == 0 ) && ( Nwords == 2 ) )
00718 mProject.SetCompletion(words[1],"100");
00719 else if ( ( strcasecmp(words[0],"start") == 0 ) && ( Nwords == 3 ) )
00720 mProject.StartTask(words[1],words[2],TNORM);
00721 else if ( ( strcasecmp(words[0],"astart") == 0 ) && ( Nwords == 3 ) )
00722 mProject.StartTask(words[1],words[2],TACTUAL);
00723 else if ( ( strcasecmp(words[0],"bstart") == 0 ) && ( Nwords == 3 ) )
00724 mProject.StartTask(words[1],words[2],TBASE);
00725 else if ( ( strcasecmp(words[0],"finish") == 0 ) && ( Nwords == 3 ) )
00726 mProject.FinishTask(words[1],words[2],TNORM);
00727 else if ( ( strcasecmp(words[0],"afinish") == 0 ) && ( Nwords == 3 ) )
00728 mProject.FinishTask(words[1],words[2],TACTUAL);
00729 else if ( ( strcasecmp(words[0],"bfinish") == 0 ) && ( Nwords == 3 ) )
00730 mProject.FinishTask(words[1],words[2],TBASE);
00731 else if ( ( strcasecmp(words[0],"future") == 0 ) && ( Nwords == 5 ) )
00732 {
00733 WorkBlock(words[1], words[2], words[3], words[4],
00734 TimeBlock::MANUAL_SCHEDULE);
00735 }
00736 else if ( ( strcasecmp(words[0],"past") == 0 ) && ( Nwords == 5 ) )
00737 {
00738 WorkBlock(words[1], words[2], words[3], words[4],
00739 TimeBlock::WORK_DONE);
00740 }
00741 else if ( ( strcasecmp(words[0],"done") == 0 ) && ( Nwords == 3 ) )
00742 mProject.DaysDone(words[1], atoi(words[2]));
00743 else if ( ( strcasecmp(words[0],"vacation") == 0 ) && ( Nwords == 3 ) )
00744 Vacation(words[1], words[2], words[2]);
00745 else if ( ( strcasecmp(words[0],"vacation") == 0 ) && ( Nwords == 4 ) )
00746 Vacation(words[1], words[2], words[3]);
00747 else if ( ( strcasecmp(words[0],"rate") == 0 ) && ( Nwords == 3 ) )
00748 mProject.SetResourceRate(words[1],words[2]);
00749 else if ( ( strcasecmp(words[0],"item") == 0 ) && ( Nwords == 4 ) )
00750 mProject.AddTaskItem(words[1],words[2],words[3]);
00751 else if ( ( strcasecmp(words[0],"prate") == 0 ) && ( Nwords == 2 ) )
00752 mProject.SetProjectRate(words[1]);
00753 else if ( ( strcasecmp(words[0],"pitem") == 0 ) && ( Nwords == 3 ) )
00754 mProject.AddProjectItem(words[1], words[2]);
00755 else if ( ( strcasecmp(words[0],"startdate") == 0 ) && ( Nwords == 4 ) )
00756 mProject.SetStartTime(words[1], words[2], words[3]);
00757 else if ( ( strcasecmp(words[0], "finishdate") == 0 ) && ( Nwords == 2 ) )
00758 mProject.SetFinishDate(words[1]);
00759 else if ( ( strcasecmp(words[0],"textreport") == 0 ) && ( Nwords == 2 ) )
00760 mReporter.text_report = strdup(words[1]);
00761 else if ( ( strcasecmp(words[0],"xmlreport") == 0 ) && ( Nwords == 2 ) )
00762 mReporter.xml_report = strdup(words[1]);
00763 else if ( ( strcasecmp(words[0],"texreport") == 0 ) && ( Nwords == 2 ) )
00764 mReporter.tex_report = strdup(words[1]);
00765 else if ( ( strcasecmp(words[0],"htmlreport") == 0 ) && ( Nwords == 2 ) )
00766 mReporter.html_report = strdup(words[1]);
00767 else if ( ( strcasecmp(words[0], "show_dependencies") == 0 )
00768 && ( Nwords == 1 ) )
00769 mReporter.dependencies = 1;
00770 else if ( ( strcasecmp(words[0], "show_vacations") == 0 )
00771 && ( Nwords == 1 ) )
00772 mReporter.vacations = 1;
00773 else if ( ( strcasecmp(words[0], "show_resource_notes") == 0 )
00774 && ( Nwords == 1 ) )
00775 mReporter.resource_notes = 1;
00776 else if ( ( strcasecmp(words[0],"show_task_notes") == 0 ) && ( Nwords == 1 ) )
00777 mReporter.task_notes = 1;
00778 else if ( ( strcasecmp(words[0],"show_task_ids") == 0 ) && ( Nwords == 1 ) )
00779 mReporter.task_ids = 1;
00780 else if ( ( strcasecmp(words[0],"show_milestone_ids") == 0 ) && ( Nwords == 1 ) )
00781 mReporter.milestone_ids = 1;
00782 else if ( ( strcasecmp(words[0],"weekly_tex") == 0 ) && ( Nwords == 2 ) )
00783 mReporter.weekly_tex_report = strdup(words[1]);
00784 else if ( ( strcasecmp(words[0],"weekly_html") == 0 ) && ( Nwords == 2 ) )
00785 mReporter.weekly_html_report = strdup(words[1]);
00786 else if ( ( strcasecmp(words[0],"weekly_txt") == 0 ) && ( Nwords == 2 ) )
00787 mReporter.weekly_txt_report = strdup(words[1]);
00788 else if ( ( strcasecmp(words[0],"slippage_tex") == 0 ) && ( Nwords == 2 ) )
00789 mReporter.slippage_tex_report = strdup(words[1]);
00790 else if ( ( strcasecmp(words[0],"slippage_html") == 0 ) && ( Nwords == 2 ) )
00791 mReporter.slippage_html_report = strdup(words[1]);
00792 else if ( ( strcasecmp(words[0],"slippage_txt") == 0 ) && ( Nwords == 2 ) )
00793 mReporter.slippage_txt_report = strdup(words[1]);
00794 else if ( ( strcasecmp(words[0],"monthly_tex") == 0 ) && ( Nwords == 2 ) )
00795 mReporter.monthly_tex_report = strdup(words[1]);
00796 else if ( ( strcasecmp(words[0],"monthly_html") == 0 ) && ( Nwords == 2 ) )
00797 mReporter.monthly_html_report = strdup(words[1]);
00798 else if ( ( strcasecmp(words[0],"monthly_txt") == 0 ) && ( Nwords == 2 ) )
00799 mReporter.monthly_txt_report = strdup(words[1]);
00800 else if ( ( strcasecmp(words[0],"printtaskdays") == 0 ) && ( Nwords == 1 ) )
00801 mReporter.print_task_days = 1;
00802 else if ( ( strcasecmp(words[0],"utilgraph") == 0 ) && ( Nwords == 2 ) )
00803 mReporter.util_graph = strdup(words[1]);
00804 else if ( ( strcasecmp(words[0],"hardschedule") == 0 ) && ( Nwords == 2 ) )
00805 mReporter.hard_schedule = strdup(words[1]);
00806 else if ( ( strcasecmp(words[0],"taskgraph") == 0 ) && ( Nwords == 4 ) )
00807 AddTaskGraph(words[1], words[2], words[3]);
00808 else if ( ( strcasecmp(words[0],"network") == 0 ) && ( Nwords == 4 ) )
00809 mReporter.AddNetworkDiagram(atoi(words[1]), atoi(words[2]),
00810 words[3]);
00811 else if ( ( strcasecmp(words[0],"netx") == 0 ) && ( Nwords == 3 ) )
00812 mProject.AddNetworkX(words[1], words[2]);
00813 else if ( ( strcasecmp(words[0],"nety") == 0 ) && ( Nwords == 3 ) )
00814 mProject.AddNetworkY(words[1], words[2]);
00815 else if ( ( strcasecmp(words[0],"start_nety") == 0 ) && ( Nwords == 2 ) )
00816 mProject.AddStartNetworkY(words[1]);
00817 else if ( ( strcasecmp(words[0],"finish_nety") == 0 ) && ( Nwords == 2 ) )
00818 mProject.AddFinishNetworkY(words[1]);
00819 else if ( ( strcasecmp(words[0],"cost_html") == 0 ) && ( Nwords == 2 ) )
00820 mReporter.html_cost_report = strdup(words[1]);
00821 else if ( ( strcasecmp(words[0],"cost_tex") == 0 ) && ( Nwords == 2 ) )
00822 mReporter.tex_cost_report = strdup(words[1]);
00823 else if ( ( strcasecmp(words[0],"dateformat") == 0 ) && ( Nwords == 2 ) )
00824 mProject.SetDateFormat(words[1]);
00825 else if ( ( strcasecmp(words[0],"tg_tasklabel") == 0 ) && ( Nwords == 2 ) )
00826 mReporter.tg_tasklabel = atoi(words[1]);
00827 else if ( ( strcasecmp(words[0],"tg_left") == 0 ) && ( Nwords == 2 ) )
00828 mReporter.tg_left = atoi(words[1]);
00829 else if ( ( strcasecmp(words[0],"tg_width") == 0 ) && ( Nwords == 2 ) )
00830 mReporter.tg_width = atoi(words[1]);
00831 else if ( ( strcasecmp(words[0],"tg_top") == 0 ) && ( Nwords == 2 ) )
00832 mReporter.tg_top = atoi(words[1]);
00833 else if ( ( strcasecmp(words[0],"tg_height") == 0 ) && ( Nwords == 2 ) )
00834 mReporter.tg_height = atoi(words[1]);
00835 else if ( ( strcasecmp(words[0],"tg_space") == 0 ) && ( Nwords == 2 ) )
00836 mReporter.tg_space = atoi(words[1]);
00837 else if ( ( strcasecmp(words[0],"tg_gray") == 0 ) && ( Nwords == 2 ) )
00838 mReporter.tg_gray = atof(words[1]);
00839 else if ( ( strcasecmp(words[0],"tg_lightgray") == 0 ) && ( Nwords == 2 ) )
00840 mReporter.tg_lightgray = atof(words[1]);
00841 else if ( ( strcasecmp(words[0],"tg_white") == 0 ) && ( Nwords == 2 ) )
00842 mReporter.tg_white = atof(words[1]);
00843 else if ( ( strcasecmp(words[0],"tg_fontname1") == 0 ) && ( Nwords == 2 ) )
00844 mReporter.tg_fontname1 = strdup(words[1]);
00845 else if ( ( strcasecmp(words[0],"tg_fontsize1") == 0 ) && ( Nwords == 2 ) )
00846 mReporter.tg_fontsize1 = atof(words[1]);
00847 else if ( ( strcasecmp(words[0],"tg_fontname2") == 0 ) && ( Nwords == 2 ) )
00848 mReporter.tg_fontname2 = strdup(words[1]);
00849 else if ( ( strcasecmp(words[0],"tg_fontsize2") == 0 ) && ( Nwords == 2 ) )
00850 mReporter.tg_fontsize2 = atof(words[1]);
00851 else if ( ( strcasecmp(words[0],"tg_fontname3") == 0 ) && ( Nwords == 2 ) )
00852 mReporter.tg_fontname3 = strdup(words[1]);
00853 else if ( ( strcasecmp(words[0],"tg_fontsize3") == 0 ) && ( Nwords == 2 ) )
00854 mReporter.tg_fontsize3 = atof(words[1]);
00855 else if ( ( strcasecmp(words[0],"tg_textup") == 0 ) && ( Nwords == 2 ) )
00856 mReporter.tg_textup = atoi(words[1]);
00857 else if ( ( strcasecmp(words[0],"tg_mlgray") == 0 ) && ( Nwords == 2 ) )
00858 mReporter.tg_mlgray = atof(words[1]);
00859 else if ( ( strcasecmp(words[0],"tg_xborder") == 0 ) && ( Nwords == 2 ) )
00860 mReporter.tg_xborder = atoi(words[1]);
00861 else if ( ( strcasecmp(words[0],"tg_yborder") == 0 ) && ( Nwords == 2 ) )
00862 mReporter.tg_yborder = atoi(words[1]);
00863 else if ( ( strcasecmp(words[0],"tg_nodays") == 0 ) && ( Nwords == 1 ) )
00864 mReporter.tg_nodays = 1;
00865 else if ( ( strcasecmp(words[0],"tg_daysofmonth") == 0 ) && ( Nwords == 1 ) )
00866 mReporter.tg_daysofmonth = 1;
00867 else if ( ( strcasecmp(words[0],"tg_sortbyresource") == 0 ) && ( Nwords == 1 ) )
00868 mReporter.tg_sortbyresource = true;
00869 else if ( ( strcasecmp(words[0],"tg_showpast") == 0 ) && ( Nwords == 1 ) )
00870 mReporter.tg_showpast = true;
00871 else if ( ( strcasecmp(words[0],"tg_pastgray") == 0 ) && ( Nwords == 2 ) )
00872 mReporter.tg_pastgray = atof(words[1]);
00873 else if ( ( strcasecmp(words[0],"tg_showvacation") == 0 ) && ( Nwords == 1 ) )
00874 mReporter.tg_showvacation = true;
00875 else if ( ( strcasecmp(words[0],"tg_vacationgray") == 0 ) && ( Nwords == 2 ) )
00876 mReporter.tg_vacationgray = atof(words[1]);
00877 else if ( ( strcasecmp(words[0], "pc_width") == 0 ) && ( Nwords == 2 ) )
00878 mReporter.pc_width = atoi(words[1]);
00879 else if ( ( strcasecmp(words[0], "pc_height") == 0 ) && ( Nwords == 2 ) )
00880 mReporter.pc_height = atoi(words[1]);
00881 else if ( ( strcasecmp(words[0], "pc_space") == 0 ) && ( Nwords == 2 ) )
00882 mReporter.pc_space = atoi(words[1]);
00883 else if ( ( strcasecmp(words[0], "pc_textin") == 0 ) && ( Nwords == 2 ) )
00884 mReporter.pc_textin = atoi(words[1]);
00885 else if ( ( strcasecmp(words[0], "pc_textup") == 0 ) && ( Nwords == 2 ) )
00886 mReporter.pc_textup = atoi(words[1]);
00887 else if ( ( strcasecmp(words[0], "pc_fontname1") == 0 ) && ( Nwords == 2 ) )
00888 mReporter.pc_fontname1 = strdup(words[1]);
00889 else if ( ( strcasecmp(words[0], "pc_fontsize1") == 0 ) && ( Nwords == 2 ) )
00890 mReporter.pc_fontsize1 = atoi(words[1]);
00891 else
00892 {
00893 cerr << name << ":" << lineno << ": warning: Invalid Line `"
00894 << buf << "'\n";
00895 ++invalid_lines;
00896 }
00897 }
00898 catch ( ProjectException & e )
00899 {
00900 cerr << name << ":" << lineno << ": " << e.what() << endl;
00901 ++invalid_lines;
00902 }
00903 catch ( ProjectFileException & e )
00904 {
00905 cerr << name << ":" << lineno << ": " << e.what() << endl;
00906 ++invalid_lines;
00907 }
00908
00909 }
00910
00911
00912
00913 fclose(f);
00914
00915 if ( invalid_lines )
00916 Error("There were %d errors parsing %s", invalid_lines, name);
00917 }
00918
00919 void Project::PrintFile()
00920 {
00921 printf("# Resources:\n");
00922 for ( RPLCI rl = mResourceList.begin() ; rl != mResourceList.end() ; rl++ )
00923 printf("resource %s \"%s\"\n", (*rl)->id(), (*rl)->name());
00924
00925 printf("\n# Tasks:\n");
00926 for ( TPLCI pt = mTaskList.begin() ; pt != mTaskList.end() ; pt++ )
00927 printf("task %s \"%s\" %d\n",(*pt)->id(),(*pt)->name(),(*pt)->duration());
00928
00929 printf("\n# Candidates:\n");
00930 for ( TPLCI pt = mTaskList.begin() ; pt != mTaskList.end() ; pt++ )
00931 for ( RPLCI rl = (*pt)->begin_cando(); rl != (*pt)->end_cando(); rl++ )
00932 printf("candidate %s %s\n",(*pt)->id(), (*rl)->id());
00933
00934 printf("\n# Dependencies:\n");
00935 for ( TPLCI pt = mTaskList.begin() ; pt != mTaskList.end() ; pt++ )
00936 for ( TPLCI tpl = (*pt)->begin_depends(); tpl != (*pt)->end_depends(); tpl++ )
00937 printf("depends %s %s\n", (*pt)->id(), (*tpl)->id());
00938 }
00939
00940