diff --git a/src/libs/kernel/kptschedulerplugin_macros.h b/src/libs/kernel/kptschedulerplugin_macros.h index dfb4e3ae..05443231 100644 --- a/src/libs/kernel/kptschedulerplugin_macros.h +++ b/src/libs/kernel/kptschedulerplugin_macros.h @@ -1,28 +1,28 @@ /* This file is part of the KDE project Copyright (C) 2009 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPTSCHEDULERPLUGIN_MACROS_H #define KPTSCHEDULERPLUGIN_MACROS_H #include #include -#define KPLATO_SCHEDULERPLUGIN_EXPORT( c, json ) \ +#define PLAN_SCHEDULERPLUGIN_EXPORT( c, json ) \ K_PLUGIN_FACTORY_WITH_JSON( SchedulerFactory, json, registerPlugin< c >(); ) #endif diff --git a/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.cpp b/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.cpp index 5d49d973..2a9cefea 100644 --- a/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.cpp +++ b/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.cpp @@ -1,166 +1,166 @@ /* This file is part of the KDE project * Copyright (C) 2009, 2012 Dag Andersen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KPlatoRCPSPlugin.h" #include "kptschedulerplugin_macros.h" #include "kptdebug.h" #include "KPlatoRCPSScheduler.h" #include "kptproject.h" #include "kptschedule.h" #include #include #include #include #ifndef PLAN_NOPLUGIN -KPLATO_SCHEDULERPLUGIN_EXPORT(KPlatoRCPSPlugin, "planrcpsscheduler.json") +PLAN_SCHEDULERPLUGIN_EXPORT(KPlatoRCPSPlugin, "planrcpsscheduler.json") #endif using namespace KPlato; KPlatoRCPSPlugin::KPlatoRCPSPlugin( QObject * parent, const QVariantList & ) : KPlato::SchedulerPlugin(parent) { debugPlan<RCPS Scheduler" "The Resource Constrained Project Scheduler (RCPS) focuses on scheduling" " the project to avoid overbooking resources." " It still respects task dependencies and also tries to fulfill time constraints." " However, time constraints can make it very difficult to find a good solution," " so it may be preferable to use a different scheduler in these cases." ); } int KPlatoRCPSPlugin::capabilities() const { return SchedulerPlugin::AvoidOverbooking | SchedulerPlugin::ScheduleForward | SchedulerPlugin::ScheduleBackward; } ulong KPlatoRCPSPlugin::currentGranularity() const { ulong v = m_granularities.value( m_granularity ); return qMax( v, (ulong)60000 ); // minimum 1 min } void KPlatoRCPSPlugin::calculate( KPlato::Project &project, KPlato::ScheduleManager *sm, bool nothread ) { foreach ( SchedulerThread *j, m_jobs ) { if ( j->manager() == sm ) { return; } } sm->setScheduling( true ); KPlatoRCPSScheduler *job = new KPlatoRCPSScheduler( &project, sm, currentGranularity() ); m_jobs << job; connect(job, SIGNAL(jobFinished(SchedulerThread*)), SLOT(slotFinished(SchedulerThread*))); project.changed( sm ); // connect(this, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*)), &project, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*))); // connect(this, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*)), &project, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*))); connect(job, SIGNAL(maxProgressChanged(int)), sm, SLOT(setMaxProgress(int))); connect(job, SIGNAL(progressChanged(int)), sm, SLOT(setProgress(int))); if ( nothread ) { job->doRun(); } else { job->start(); } } void KPlatoRCPSPlugin::stopAllCalculations() { foreach ( SchedulerThread *s, m_jobs ) { stopCalculation( s ); } } void KPlatoRCPSPlugin::stopCalculation( SchedulerThread *sch ) { if ( sch ) { //FIXME: this should just call stopScheduling() and let the job finish "normally" disconnect( sch, SIGNAL(jobFinished(KPlatoRCPSScheduler*)), this, SLOT(slotFinished(KPlatoRCPSScheduler*)) ); sch->stopScheduling(); // wait max 20 seconds. sch->mainManager()->setCalculationResult( ScheduleManager::CalculationStopped ); if ( ! sch->wait( 20000 ) ) { sch->deleteLater(); m_jobs.removeAt( m_jobs.indexOf( sch ) ); } else { slotFinished( sch ); } } } void KPlatoRCPSPlugin::slotStarted( SchedulerThread */*job*/ ) { // debugPlan<<"KPlatoRCPSPlugin::slotStarted:"; } void KPlatoRCPSPlugin::slotFinished( SchedulerThread *j ) { KPlatoRCPSScheduler *job = static_cast( j ); Project *mp = job->mainProject(); ScheduleManager *sm = job->mainManager(); //debugPlan<<"KPlatoRCPSPlugin::slotFinished:"<isStopped(); if ( job->isStopped() ) { sm->setCalculationResult( ScheduleManager::CalculationCanceled ); } else { updateLog( job ); Project *tp = job->project(); ScheduleManager *tm = job->manager(); updateProject( tp, tm, mp, sm ); sm->setCalculationResult( ScheduleManager::CalculationDone ); } sm->setScheduling( false ); m_jobs.removeAt( m_jobs.indexOf( job ) ); if ( m_jobs.isEmpty() ) { m_synctimer.stop(); } emit sigCalculationFinished( mp, sm ); disconnect(this, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*)), mp, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*))); disconnect(this, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*)), mp, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*))); job->deleteLater(); } #include "KPlatoRCPSPlugin.moc" diff --git a/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.h b/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.h index af85b5c9..6b7919d5 100644 --- a/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.h +++ b/src/plugins/schedulers/rcps/KPlatoRCPSPlugin.h @@ -1,67 +1,67 @@ /* This file is part of the KDE project * Copyright (C) 2009 Dag Andersen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#ifndef KPLATORCPSPLUGIN_H -#define KPLATORCPSPLUGIN_H +#ifndef PLANRCPSPLUGIN_H +#define PLANRCPSPLUGIN_H #include "kptschedulerplugin.h" #include namespace KPlato { class Project; class ScheduleManager; class Schedule; } using namespace KPlato; class KPlatoRCPSPlugin : public SchedulerPlugin { Q_OBJECT public: KPlatoRCPSPlugin( QObject * parent, const QVariantList & ); ~KPlatoRCPSPlugin(); virtual QString description() const; virtual int capabilities() const; /// Calculate the project virtual void calculate( Project &project, ScheduleManager *sm, bool nothread = false ); /// Return the scheduling granularity in milliseconds ulong currentGranularity() const; Q_SIGNALS: void sigCalculationStarted(Project*, ScheduleManager*); void sigCalculationFinished(Project*, ScheduleManager*); public Q_SLOTS: void stopAllCalculations(); void stopCalculation( SchedulerThread *sch ); protected Q_SLOTS: void slotStarted( SchedulerThread *job ); void slotFinished( SchedulerThread *job ); }; -#endif // KPLATORCPSPLUGIN_H +#endif // PLANRCPSPLUGIN_H diff --git a/src/plugins/schedulers/rcps/KPlatoRCPSScheduler.h b/src/plugins/schedulers/rcps/KPlatoRCPSScheduler.h index 663f5055..5f66c882 100644 --- a/src/plugins/schedulers/rcps/KPlatoRCPSScheduler.h +++ b/src/plugins/schedulers/rcps/KPlatoRCPSScheduler.h @@ -1,169 +1,169 @@ /* This file is part of the KDE project * Copyright (C) 2009 Dag Andersen * Copyright (C) 2011 Dag Andersen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#ifndef KPLATORCPSSCHEDULER_H -#define KPLATORCPSSCHEDULER_H +#ifndef PLANRCPSSCHEDULER_H +#define PLANRCPSSCHEDULER_H #include "kptschedulerplugin.h" #include "kptdatetime.h" #include #include #include #include class ProgressInfo; struct rcps_fitness; namespace KPlato { class Project; class ScheduleManager; class Schedule; class MainSchedule; class Resource; class ResourceRequest; class Task; class Node; } using namespace KPlato; class KPlatoRCPSScheduler : public KPlato::SchedulerThread { Q_OBJECT private: struct duration_info { KPlatoRCPSScheduler *self; Task *task; Duration estimate; int estimatetype; QList requests; // QPair< time, direction >, duration QMap, int> cache; qint64 calls; }; struct weight_info { KPlatoRCPSScheduler *self; Task *task; int targettime; bool isEndJob; int finish; }; struct fitness_info { KPlatoRCPSScheduler *self; QMultiMap > map; QList jobs; }; public: KPlatoRCPSScheduler( Project *project, ScheduleManager *sm, ulong granularity, QObject *parent = 0 ); ~KPlatoRCPSScheduler(); int check(); int result; static int progress_callback( int generations, struct rcps_fitness fitness, void* arg ); static int duration_callback( int direction, int time, int nominal_duration, void *arg ); static int weight_callback( int time, int duration, struct rcps_fitness *nominal_weight, void* weight_arg, void* fitness_arg ); static void *fitness_callback_init( void *arg ); static int fitness_callback_result( struct rcps_fitness *fitness, void *arg ); int progress( int generations, struct rcps_fitness fitness ); int duration( int direction, int time, int nominal_duration, duration_info *info ); int weight( int time, int duration, struct rcps_fitness *nominal_weight, KPlatoRCPSScheduler::weight_info* info, KPlatoRCPSScheduler::fitness_info *finfo ); int fitness( struct rcps_fitness *fit, KPlatoRCPSScheduler::fitness_info *info ); /// Fill project data into RCPS structure int kplatoToRCPS(); /// Fetch project data from RCPS structure void kplatoFromRCPS(); Q_SIGNALS: void sigCalculationStarted( Project*, ScheduleManager* ); void sigCalculationFinished( Project*, ScheduleManager* ); public Q_SLOTS: void solve(); protected: void run(); void kplatoFromRCPSForward(); void kplatoFromRCPSBackward(); void taskFromRCPSForward( struct rcps_job *job, Task *task, QMap > &resourcemap ); void taskFromRCPSBackward( struct rcps_job *job, Task *task, QMap > &resourcemap ); // Real durations for early-/late start/finish not calculated so values are approximate void calculatePertValues( const QMap > &map ); Duration calculateLateStuff( const QMap > &map, Task *task ); Duration calculateEarlyStuff( const QMap > &map, Task *task ); void adjustSummaryTasks( const QList &nodes ); void addResources(); struct rcps_resource *addResource( KPlato::Resource *resource ); void addTasks(); struct rcps_job *addTask( KPlato::Task *task ); struct rcps_job *addJob( const QString &name, int duration ); void addDependencies(); void addDependenciesForward( struct rcps_job *job, Task *task ); void addDependenciesBackward( struct rcps_job *job, Task *task ); void addRequests(); void addRequest( struct rcps_job *job, Task *task ); void setConstraints(); void setWeights(); private: int toRcpsTime( const DateTime &time ) const; DateTime fromRcpsTime( int time ) const; private: MainSchedule *m_schedule; bool m_recalculate; bool m_usePert; bool m_backward; struct rcps_problem *m_problem; DateTime m_starttime; DateTime m_targettime; qint64 m_timeunit; uint m_offsetFromTime_t; QMap m_resourcemap; QMap m_requestmap; QMap m_taskmap; struct rcps_job *m_jobstart, *m_jobend; QMap m_duration_info_list; QMap m_weight_info_list; ProgressInfo *m_progressinfo; struct fitness_info fitness_init_arg; }; -#endif // KPLATORCPSPSCHEDULER_H +#endif // PLANRCPSPSCHEDULER_H diff --git a/src/plugins/schedulers/rcps/planrcpsscheduler.desktop b/src/plugins/schedulers/rcps/planrcpsscheduler.desktop index cd374e3e..0757836c 100644 --- a/src/plugins/schedulers/rcps/planrcpsscheduler.desktop +++ b/src/plugins/schedulers/rcps/planrcpsscheduler.desktop @@ -1,7 +1,7 @@ [Desktop Entry] X-KDE-ServiceTypes=Plan/SchedulerPlugin Type=Service -X-KDE-Library=kplatorcpsscheduler +X-KDE-Library=planrcpsscheduler Name=RCPS Scheduler Comment=Genetics based Resource Constrained Project Scheduler diff --git a/src/plugins/schedulers/tj/CMakeLists.txt b/src/plugins/schedulers/tj/CMakeLists.txt index 3d1101b7..db1b72c2 100644 --- a/src/plugins/schedulers/tj/CMakeLists.txt +++ b/src/plugins/schedulers/tj/CMakeLists.txt @@ -1,61 +1,61 @@ add_definitions(-DTRANSLATION_DOMAIN=\"calligraplan_scheduler_tj\") set(LIBTJ_INCLUDE_DIR taskjuggler) include_directories(${LIBTJ_INCLUDE_DIR} ${PLANODF_INCLUDES} ${PLANKERNEL_INCLUDES}) #add_subdirectory( taskjuggler ) if(BUILD_TESTING) add_subdirectory( tests ) endif() set ( TJScheduler_SRCS PlanTJPlugin.cpp PlanTJScheduler.cpp taskjuggler/Allocation.cpp taskjuggler/CoreAttributes.cpp taskjuggler/CoreAttributesList.cpp taskjuggler/Project.cpp taskjuggler/Task.cpp taskjuggler/TaskDependency.cpp taskjuggler/TaskList.cpp taskjuggler/TaskScenario.cpp taskjuggler/Resource.cpp taskjuggler/ResourceList.cpp taskjuggler/Scenario.cpp taskjuggler/ScenarioList.cpp taskjuggler/Shift.cpp taskjuggler/ShiftList.cpp taskjuggler/ShiftSelection.cpp taskjuggler/ShiftSelectionList.cpp taskjuggler/VacationList.cpp taskjuggler/TjMessageHandler.cpp taskjuggler/Utility.cpp # taskjuggler/XMLFile.cpp # taskjuggler/ParserElement.cpp # taskjuggler/ParserNode.cpp # taskjuggler/ParserTreeContext.cpp taskjuggler/Interval.cpp ) # TODO: plugin should not be SHARED, but MODULE. Needs to be SHARED because tests link to it -> fix with util lib/objects add_library(plantjscheduler SHARED ${TJScheduler_SRCS} ) # calligraplan_scheduler_desktop_to_json(plantjscheduler plantjscheduler.desktop) if(${KF5_VERSION} VERSION_LESS "5.16.0") kcoreaddons_desktop_to_json(plantjscheduler plantjscheduler.desktop) else() kcoreaddons_desktop_to_json(plantjscheduler plantjscheduler.desktop SERVICE_TYPES ${PLAN_SOURCE_DIR}/libs/kernel/plan_schedulerplugin.desktop ) endif() # TODO: only export symbols for tests, not release -generate_export_header(plantjscheduler BASE_NAME kplatotj) +generate_export_header(plantjscheduler BASE_NAME plantj) add_definitions(-Dplantjscheduler_EXPORTS) target_link_libraries( plantjscheduler plankernel ) set_target_properties( plantjscheduler PROPERTIES DEFINE_SYMBOL MAKE_PLANTJ_LIB ) install( TARGETS plantjscheduler DESTINATION ${PLUGIN_INSTALL_DIR}/calligraplan/schedulers ) diff --git a/src/plugins/schedulers/tj/PlanTJPlugin.cpp b/src/plugins/schedulers/tj/PlanTJPlugin.cpp index 1d8bfa0d..5cb69b17 100644 --- a/src/plugins/schedulers/tj/PlanTJPlugin.cpp +++ b/src/plugins/schedulers/tj/PlanTJPlugin.cpp @@ -1,164 +1,166 @@ /* This file is part of the KDE project * Copyright (C) 2009, 2011 Dag Andersen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "PlanTJPlugin.h" #include "kptschedulerplugin_macros.h" #include "PlanTJScheduler.h" #include "kptproject.h" #include "kptschedule.h" #include "kptdebug.h" #include #include -KPLATO_SCHEDULERPLUGIN_EXPORT(PlanTJPlugin, "plantjscheduler.json") +#ifndef PLAN_NOPLUGIN +PLAN_SCHEDULERPLUGIN_EXPORT(PlanTJPlugin, "plantjscheduler.json") +#endif using namespace KPlato; PlanTJPlugin::PlanTJPlugin( QObject * parent, const QVariantList & ) : KPlato::SchedulerPlugin(parent) { m_granularities << (long unsigned int) 5 * 60 * 1000 << (long unsigned int) 15 * 60 * 1000 << (long unsigned int) 30 * 60 * 1000 << (long unsigned int) 60 * 60 * 1000; } PlanTJPlugin::~PlanTJPlugin() { } QString PlanTJPlugin::description() const { return i18nc( "@info:whatsthis", "TaskJuggler Scheduler" "This is a slightly modified version of the scheduler used in TaskJuggler." " It has been enhanced to handle resource units." "Scheduling backwards is simulated by scheduling all tasks as late as possible." "Plan does not utilize all of its functionality." ); } int PlanTJPlugin::capabilities() const { return SchedulerPlugin::AvoidOverbooking | SchedulerPlugin::ScheduleForward | SchedulerPlugin::ScheduleBackward; } ulong PlanTJPlugin::currentGranularity() const { ulong v = m_granularities.value( m_granularity ); return qMax( v, (ulong)300000 ); // minimum 5 min } void PlanTJPlugin::calculate( KPlato::Project &project, KPlato::ScheduleManager *sm, bool nothread ) { foreach ( SchedulerThread *j, m_jobs ) { if ( j->manager() == sm ) { return; } } sm->setScheduling( true ); PlanTJScheduler *job = new PlanTJScheduler( &project, sm, currentGranularity() ); m_jobs << job; connect(job, SIGNAL(jobFinished(SchedulerThread*)), SLOT(slotFinished(SchedulerThread*))); project.changed( sm ); // connect(this, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*)), &project, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*))); // connect(this, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*)), &project, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*))); connect(job, SIGNAL(maxProgressChanged(int)), sm, SLOT(setMaxProgress(int))); connect(job, SIGNAL(progressChanged(int)), sm, SLOT(setProgress(int))); if ( nothread ) { job->doRun(); } else { job->start(); } } void PlanTJPlugin::stopAllCalculations() { foreach ( SchedulerThread *s, m_jobs ) { stopCalculation( s ); } } void PlanTJPlugin::stopCalculation( SchedulerThread *sch ) { if ( sch ) { //FIXME: this should just call stopScheduling() and let the job finish "normally" disconnect( sch, SIGNAL(jobFinished(PlanTJScheduler*)), this, SLOT(slotFinished(PlanTJScheduler*)) ); sch->stopScheduling(); // wait max 20 seconds. sch->mainManager()->setCalculationResult( ScheduleManager::CalculationStopped ); if ( ! sch->wait( 20000 ) ) { sch->deleteLater(); m_jobs.removeAt( m_jobs.indexOf( sch ) ); } else { slotFinished( sch ); } } } void PlanTJPlugin::slotStarted( SchedulerThread */*job*/ ) { // debugPlan<<"PlanTJPlugin::slotStarted:"; } void PlanTJPlugin::slotFinished( SchedulerThread *j ) { PlanTJScheduler *job = static_cast( j ); Project *mp = job->mainProject(); ScheduleManager *sm = job->mainManager(); //debugPlan<<"PlanTJPlugin::slotFinished:"<isStopped(); if ( job->isStopped() ) { sm->setCalculationResult( ScheduleManager::CalculationCanceled ); } else { updateLog( job ); if ( job->result > 0 ) { sm->setCalculationResult( ScheduleManager::CalculationError ); } else { Project *tp = job->project(); ScheduleManager *tm = job->manager(); updateProject( tp, tm, mp, sm ); sm->setCalculationResult( ScheduleManager::CalculationDone ); } } sm->setScheduling( false ); m_jobs.removeAt( m_jobs.indexOf( job ) ); if ( m_jobs.isEmpty() ) { m_synctimer.stop(); } emit sigCalculationFinished( mp, sm ); disconnect(this, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*)), mp, SIGNAL(sigCalculationStarted(Project*,ScheduleManager*))); disconnect(this, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*)), mp, SIGNAL(sigCalculationFinished(Project*,ScheduleManager*))); job->deleteLater(); } #include "PlanTJPlugin.moc" diff --git a/src/plugins/schedulers/tj/PlanTJPlugin.h b/src/plugins/schedulers/tj/PlanTJPlugin.h index 7d98e79e..cbedf502 100644 --- a/src/plugins/schedulers/tj/PlanTJPlugin.h +++ b/src/plugins/schedulers/tj/PlanTJPlugin.h @@ -1,70 +1,70 @@ /* This file is part of the KDE project * Copyright (C) 2009 Dag Andersen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef PLANTJPLUGIN_H #define PLANTJPLUGIN_H -#include "kplatotj_export.h" +#include "plantj_export.h" #include "kptschedulerplugin.h" #include namespace KPlato { class Project; class ScheduleManager; class Schedule; } using namespace KPlato; -class KPLATOTJ_EXPORT PlanTJPlugin : public SchedulerPlugin +class PLANTJ_EXPORT PlanTJPlugin : public SchedulerPlugin { Q_OBJECT public: PlanTJPlugin( QObject * parent, const QVariantList & ); ~PlanTJPlugin(); virtual QString description() const; virtual int capabilities() const; /// Calculate the project virtual void calculate( Project &project, ScheduleManager *sm, bool nothread = false ); /// Return the scheduling granularity in milliseconds ulong currentGranularity() const; Q_SIGNALS: void sigCalculationStarted(Project*, ScheduleManager*); void sigCalculationFinished(Project*, ScheduleManager*); public Q_SLOTS: void stopAllCalculations(); void stopCalculation( SchedulerThread *sch ); protected Q_SLOTS: void slotStarted( SchedulerThread *job ); void slotFinished( SchedulerThread *job ); }; #endif // PLANTJPLUGIN_H diff --git a/src/plugins/schedulers/tj/PlanTJScheduler.h b/src/plugins/schedulers/tj/PlanTJScheduler.h index 359bf7b6..fcf8d2a0 100644 --- a/src/plugins/schedulers/tj/PlanTJScheduler.h +++ b/src/plugins/schedulers/tj/PlanTJScheduler.h @@ -1,138 +1,138 @@ /* This file is part of the KDE project * Copyright (C) 2009 Dag Andersen * Copyright (C) 2011 Dag Andersen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef PLANTJSCHEDULER_H #define PLANTJSCHEDULER_H -#include "kplatotj_export.h" +#include "plantj_export.h" #include "kptschedulerplugin.h" #include "kptdatetime.h" #include #include #include #include class QDateTime; namespace TJ { class Project; class Task; class Resource; class Interval; class CoreAttributes; } namespace KPlato { class Project; class ScheduleManager; class Schedule; class MainSchedule; class Resource; class Task; class Node; class Relation; } using namespace KPlato; class PlanTJScheduler : public KPlato::SchedulerThread { Q_OBJECT private: public: PlanTJScheduler( Project *project, ScheduleManager *sm, ulong granularity, QObject *parent = 0 ); ~PlanTJScheduler(); bool check(); bool solve(); int result; /// Fill project data into TJ structure bool kplatoToTJ(); /// Fetch project data from TJ structure bool kplatoFromTJ(); Q_SIGNALS: void sigCalculationStarted( Project*, ScheduleManager* ); void sigCalculationFinished( Project*, ScheduleManager* ); const char* taskname(); public Q_SLOTS: void slotMessage( int type, const QString &msg, TJ::CoreAttributes *object ); protected: void run(); void adjustSummaryTasks( const QList &nodes ); TJ::Resource *addResource( KPlato::Resource *resource ); void addTasks(); void addWorkingTime( KPlato::Task *task, TJ::Task *job ); TJ::Task *addTask( KPlato::Task *task , TJ::Task *parent = 0 ); void addDependencies(); void addPrecedes( const Relation *rel ); void addDepends( const Relation *rel ); void addDependencies( Task *task ); void setConstraints(); void setConstraint( TJ::Task *job, KPlato::Task *task ); TJ::Task *addStartNotEarlier( Node *task ); TJ::Task *addFinishNotLater( Node *task ); void addRequests(); void addRequest( TJ::Task *job, Task *task ); void addStartEndJob(); bool taskFromTJ( TJ::Task *job, Task *task ); void calcPertValues( Task *task ); Duration calcPositiveFloat( Task *task ); static bool exists( QList &lst, CalendarDay *day ); static int toTJDayOfWeek( int day ); static DateTime fromTime_t( time_t, const QTimeZone &tz ); static time_t toTJTime_t( const QDateTime &dt, ulong granularity ); AppointmentInterval fromTJInterval( const TJ::Interval &tji, const QTimeZone &tz ); static TJ::Interval toTJInterval( const QDateTime &start, const QDateTime &end, ulong tjGranularity ); static TJ::Interval toTJInterval( const QTime &start, const QTime &end, ulong tjGranularity ); private: ulong tjGranularity() const; private: MainSchedule *m_schedule; bool m_recalculate; bool m_usePert; bool m_backward; TJ::Project *m_tjProject; // Task *m_backwardTask; QMap m_taskmap; QMap m_resourcemap; ulong m_granularity; }; #endif // PLANTJSCHEDULER_H diff --git a/src/plugins/schedulers/tj/taskjuggler/Allocation.h b/src/plugins/schedulers/tj/taskjuggler/Allocation.h index 81bfe659..236e1bef 100644 --- a/src/plugins/schedulers/tj/taskjuggler/Allocation.h +++ b/src/plugins/schedulers/tj/taskjuggler/Allocation.h @@ -1,136 +1,136 @@ /* * Allocation.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004, 2005 by Chris Schlaeger * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _Allocation_h_ #define _Allocation_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include #include "ShiftSelectionList.h" namespace TJ { class Resource; class UsageLimits; -class KPLATOTJ_EXPORT Allocation +class PLANTJ_EXPORT Allocation { public: Allocation(); Allocation(const Allocation& a); ~Allocation(); void setLimits(UsageLimits* l); const UsageLimits* getLimits() const { return limits; } void setPersistent(bool p) { persistent = p; } bool isPersistent() const { return persistent; } void setMandatory(bool m) { mandatory = m; } bool isMandatory() const { return mandatory; } void setLockedResource(Resource* r) { lockedResource = r; } Resource* getLockedResource() const { return lockedResource; } void addCandidate(Resource* r) { candidates.append(r); } QListIterator getCandidatesIterator() const { return QListIterator (candidates); } QList getCandidates() const { return candidates; } /// Return the list of required resources for @p resource QList getRequiredResources(Resource *r) const { return requiredResources.value(r); } /// Add the @p required resource for @p resource void addRequiredResource(Resource *resource, Resource *required) { requiredResources[resource].append(required); } bool hasRequiredResources(Resource *resource) const { return requiredResources.contains(resource); } bool addShift(const Interval& i, Shift* s) { return shifts.insert(new ShiftSelection(i, s)); } bool isOnShift(const Interval& i) { return shifts.isOnShift(i); } bool isWorker() const; enum SelectionModeType { order, minAllocationProbability, minLoaded, maxLoaded, random }; void setSelectionMode(SelectionModeType smt) { selectionMode = smt; } bool setSelectionMode(const QString& smt); SelectionModeType getSelectionMode() const { return selectionMode; } QDomElement xmlElement(QDomDocument& doc); void setConflictStart(time_t cs) { conflictStart = cs; } time_t getConflictStart() const { return conflictStart; } void init() { lockedResource = 0; conflictStart = 0; } private: /** * Limit values that regulate how many allocations can be made per * day/week/month. */ UsageLimits* limits; /// The shifts that can limit the allocation to certain intervals. ShiftSelectionList shifts; /** * True if the allocation should be persistent over the whole task. * If set the first selection will not be changed even if there is an * available alternative. */ bool persistent; /** * True if the resource is mandatory. This means, that only if this * allocation can be made, all other allocations will be made. If this * allocation cannot be made for a time slot, no other allocations will be * made for the task. */ bool mandatory; /// The persistent resource picked by the scheduler. Resource* lockedResource; /// Start of a resource conflict. Used during scheduling only. time_t conflictStart; /// List of potential resources. QList candidates; /// Map of required resources QMap > requiredResources; /* The selection mode determines how the resource is selected from * the candidate list. */ SelectionModeType selectionMode; } ; } // namespace TJ #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/CoreAttributes.h b/src/plugins/schedulers/tj/taskjuggler/CoreAttributes.h index 9524fd62..cda18d3f 100644 --- a/src/plugins/schedulers/tj/taskjuggler/CoreAttributes.h +++ b/src/plugins/schedulers/tj/taskjuggler/CoreAttributes.h @@ -1,163 +1,163 @@ /* * CoreAttributes.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004, 2005 by Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _CoreAttributes_h_ #define _CoreAttributes_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include #include #include "FlagList.h" #include "CustomAttribute.h" namespace TJ { class Project; class CoreAttributes; class CoreAttributesList; class CoreAttributesListIterator; class CustomAttributeDefinition; /** * @short This class is the base class for all attribute classes. * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT CoreAttributes +class PLANTJ_EXPORT CoreAttributes { public: CoreAttributes(Project* p, const QString& i, const QString& n, CoreAttributes* parent_, const QString& df = QString(), uint dl = 0); virtual ~CoreAttributes(); virtual CAType getType() const { return CA_Undefined; } const QString& getId() const { return id; } QString getFullId() const; const QString& getDefinitionFile() const { return definitionFile; } uint getDefinitionLine() const { return definitionLine; } void setIndex(int idx) { index = idx; } int getIndex() const { return index; } void setSequenceNo(uint no) { sequenceNo = no; } uint getSequenceNo() const { return sequenceNo; } void setHierarchNo(uint no); QString getHierarchNo() const; void setHierarchIndex(uint no); QString getHierarchIndex() const; QString getHierarchLevel() const; Project* getProject() const { return project; } void setName(const QString& n) { name = n; } const QString& getName() const { return name; } void getFullName(QString& fullName) const; CoreAttributes* getParent() const { return parent; } uint treeLevel() const; CoreAttributesList getSubList() const; CoreAttributesListIterator getSubListIterator() const; bool hasSubs() const; void addFlag(QString flag) { flags.addFlag(flag); } void purgeFlags() { flags.clear(); } void clearFlag(const QString& flag) { flags.clearFlag(flag); } bool hasFlag(const QString& flag) { return flags.hasFlag(flag); } FlagList getFlagList() const { return flags; } bool hasSameAncestor(const CoreAttributes* c) const; bool isDescendantOf(const CoreAttributes* c) const; bool isParentOf(const CoreAttributes* c) const; bool isRoot() const { return parent == 0; } bool isLeaf() const; void addCustomAttribute(const QString& id, CustomAttribute* ca); const CustomAttribute* getCustomAttribute(const QString& id) const; const QMap& getCustomAttributeDict() const { return customAttributes; } void inheritCustomAttributes (const QMap& dict); protected: /// A pointer to access information that are global to the project. Project* project; /// An ID that must be unique within the attribute class. QString id; /// A short description of the attribute. QString name; /// Pointer to parent. If there is no parent the pointer is 0. CoreAttributes* parent; /* Name of the tjp file that caused the creation of this CoreAttribute. It * may be empty if it was not created from a .tjp file. */ const QString definitionFile; /* Line in the .tjp file that caused the createtion of this Core * Attribute. It may be 0 if it was not created from a .tjp file. */ uint definitionLine; /** * The index of the attribute declaration within the project files. Each * attribute lists has it's own indices. */ uint sequenceNo; /** * The index of the attribute declaration within it's parents children. */ uint hierarchNo; /** * The index of the attributes in a logical order that takes the tree * structure and the start and end date into account. Each attribute list * has it's own indices. */ int index; /** * The index of the attributes of the same parent in a logical order that * takes the tree structure and the start and end date into account. Each * attribute list has it's own indices. */ uint hierarchIndex; /// List of child attributes. CoreAttributesList* sub; /// List of flags set for this attribute. FlagList flags; /// User defined, optional attributes. QMap customAttributes; } ; } // namespace TJ -KPLATOTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::CoreAttributes* t ); -KPLATOTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::CoreAttributes& t ); +PLANTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::CoreAttributes* t ); +PLANTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::CoreAttributes& t ); #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/CoreAttributesList.h b/src/plugins/schedulers/tj/taskjuggler/CoreAttributesList.h index de7f1326..dcbd79b8 100644 --- a/src/plugins/schedulers/tj/taskjuggler/CoreAttributesList.h +++ b/src/plugins/schedulers/tj/taskjuggler/CoreAttributesList.h @@ -1,155 +1,155 @@ /* * CoreAttributesList.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _CoreAttributesList_h_ #define _CoreAttributesList_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include #include "CoreAttributes.h" class QString; namespace TJ { /** * @short The class stores a list of CoreAttributes. * @see CoreAttributes * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT CoreAttributesList : public QList +class PLANTJ_EXPORT CoreAttributesList : public QList { public: CoreAttributesList() : m_autodelete(false) { for (int i = 0; i < maxSortingLevel; i++) sorting[i] = SequenceUp; } CoreAttributesList(const CoreAttributesList& l) : QList(l), m_autodelete(false) { for (int i = 0; i < maxSortingLevel; i++) sorting[i] = l.sorting[i]; } virtual ~CoreAttributesList(); void setAutoDelete(bool on); bool autoDelete() const; void deleteContents(); enum SortCriteria { SequenceUp = 0, SequenceDown, TreeMode, NameUp, NameDown, FullNameUp, FullNameDown, IdUp, IdDown, IndexUp, IndexDown, StatusUp, StatusDown, CompletedUp, CompletedDown, PrioUp, PrioDown, ResponsibleUp, ResponsibleDown, MinEffortUp, MinEffortDown, MaxEffortUp, MaxEffortDown, RateUp, RateDown, StartUp, StartDown, EndUp, EndDown, CriticalnessUp, CriticalnessDown, PathCriticalnessUp, PathCriticalnessDown }; static const int maxSortingLevel = 3; void setSorting(int s, int level); int getSorting(int level) const { return level < maxSortingLevel ? sorting[ level ] : 0; } void sort(); void createIndex(bool initial = false); int getIndex(const QString& id) const; uint maxDepth() const; static bool isSupportedSortingCriteria(int sc); virtual int compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2, int level); int inSort(CoreAttributes *attr); static QStringList getSortCriteria(); protected: virtual int compareItems(CoreAttributes* c1, CoreAttributes* c2); bool m_autodelete; int sorting[maxSortingLevel]; } ; /** * @short Iterator for CoreAttributesList objects. * @author Chris Schlaeger */ class CoreAttributesListIterator : public QListIterator { public: explicit CoreAttributesListIterator(const CoreAttributesList& l) : QListIterator(l) { } virtual ~CoreAttributesListIterator() { } void operator++() { if (hasNext()) next(); } CoreAttributes *operator*() { return hasNext() ? peekNext() : 0; } } ; template int compareTreeItemsT(TL* list, T* c1, T* c2) { if (c1 == c2) return 0; QList cl1, cl2; int res1 = 0; for ( ; c1 || c2; ) { if (c1) { cl1.prepend(c1); c1 = c1->getParent(); } else res1 = -1; if (c2) { cl2.prepend(c2); c2 = c2->getParent(); } else res1 = 1; } QListIterator cal1(cl1); QListIterator cal2(cl2); while (cal1.hasNext() && cal2.hasNext()) { CoreAttributes *a1 = cal1.next(); CoreAttributes *a2 = cal2.next(); int res; for (int j = 1; j < CoreAttributesList::maxSortingLevel; ++j) { if ((res = list->compareItemsLevel(a1, a2, j)) != 0) return res; } if ((res = a1->getSequenceNo() - a2->getSequenceNo()) != 0) return res < 0 ? -1 : 1; } return res1; } } // namespace TJ -KPLATOTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::CoreAttributesList& lst ); +PLANTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::CoreAttributesList& lst ); #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/Interval.h b/src/plugins/schedulers/tj/taskjuggler/Interval.h index 25690c8f..4f0fea31 100644 --- a/src/plugins/schedulers/tj/taskjuggler/Interval.h +++ b/src/plugins/schedulers/tj/taskjuggler/Interval.h @@ -1,163 +1,163 @@ /* * Interval.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _XInterval_h_ #define _XInterval_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include #include "Utility.h" #include #include namespace TJ { -class KPLATOTJ_EXPORT Interval +class PLANTJ_EXPORT Interval { public: Interval(time_t s, time_t e) : start(s), end(e) { } Interval(time_t s) : start(s), end(s) { } Interval() : start(0), end(0) { } Interval(const Interval& iv) : start(iv.start), end(iv.end) { } virtual ~Interval() { } bool isNull() const { return !(start < end); } bool contains(time_t date) const { return (start <= date) && (date <= end); } bool contains(const Interval& i) const { return (start <= i.start) && (i.end <= end); } bool overlap(const Interval& i) { // Sets the interval to the overlapping interval. if (end <= i.start || start >= i.end) { // Intervals do not overlap. end = start - 1; return false; } if (start < i.start) start = i.start; if (end > i.end) end = i.end; return true; } bool overlaps(const Interval& i) const { return (start <= end && i.start <= i.end && ((start <= i.start && i.start <= end) || (i.start <= start && start <= i.end))); } bool prepend(const Interval& i) { if (((i.end + 1) == start) && (i.start < start)) { start = i.start; return true; } return false; } bool append(const Interval& i) { if (((end + 1) == i.start) && ((end + 1) <= i.end)) { end = i.end; return true; } return false; } int compare(const Interval& i) const { if (end < i.start) return -1; // interval is below i else if (i.end < start) return 1; // interval above below i else return 0; // interval overlap } bool operator==(const Interval& i) const { return start == i.start && end == i.end; } bool operator!=(const Interval& i) const { return start != i.start || end != i.end; } time_t getStart() const { return start; } void setStart(time_t s) { start = s; } time_t getEnd() const { return end; } void setEnd(time_t e) { end = e; } time_t getDuration() const { return end >= start ? end - start + 1: 0; } const Interval& firstDay() { start = midnight(start); end = sameTimeNextDay(start) - 1; return *this; } const Interval& firstWeek(bool weekStartsMonday) { start = beginOfWeek(start, weekStartsMonday); end = sameTimeNextWeek(start) - 1; return *this; } const Interval& firstMonth() { start = beginOfMonth(start); end = sameTimeNextMonth(start) - 1; return *this; } const Interval& firstQuarter() { start = beginOfQuarter(start); end = sameTimeNextQuarter(start) - 1; return *this; } const Interval& firstYear() { start = beginOfYear(start); end = sameTimeNextYear(start) - 1; return *this; } protected: /// The start of the time interval. time_t start; /// The end of the time interval. This value is part of the interval. time_t end; } ; } // namespace TJ Q_DECLARE_TYPEINFO( TJ::Interval, Q_MOVABLE_TYPE ); Q_DECLARE_METATYPE( TJ::Interval ) -KPLATOTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Interval *i ); -KPLATOTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Interval &i ); +PLANTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Interval *i ); +PLANTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Interval &i ); #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/Project.h b/src/plugins/schedulers/tj/taskjuggler/Project.h index c49a6d33..6c62610f 100644 --- a/src/plugins/schedulers/tj/taskjuggler/Project.h +++ b/src/plugins/schedulers/tj/taskjuggler/Project.h @@ -1,946 +1,946 @@ /* * Project.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 * by Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _Project_h_ #define _Project_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include #include #include "VacationList.h" #include "ScenarioList.h" #include "TaskList.h" #include "ShiftList.h" #include "ResourceList.h" // #include "AccountList.h" // #include "QtReport.h" // #include "Journal.h" class QStringList; namespace TJ { // class ReportXML; // class Report; class CustomAttributeDefinition; class VacationInterval; class UsageLimits; /** * The Project class is the root of the data tree of the application. * Applications can use multiple Project objects. This is e. g. needed when * the application needs to preserve the state prior to a scheduler run. The * scheduler calculates the data in place, adding the calculated values to the * existing data structures. Since the original data cannot be identified * anymore the applications needs to make a copy of the project before calling * the scheduler. For that purpose Project and all related sub-classes provide * a copy constructor. * * @short The root class of all project related information. * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT Project : public QObject +class PLANTJ_EXPORT Project : public QObject { Q_OBJECT public: Project(); ~Project(); /* void addSourceFile(const QString& f); QStringList getSourceFiles() const;*/ // Called to emit a signal with the currently processed file. void setProgressInfo(const QString& i); // Called to emit a signal with the current process of the scheduler. void setProgressBar(int i, int of); /** * Projects have at least one ID, but can have multiple IDs. This usually * happens when projects are composed of several sub-projects. Each sub * projects brings its own unique ID. Each ID must be registered with the * project by calling addId(). The most recently added ID is also the * current ID. All subsequently added tasks are associtated with this * project ID. So, you have to add at least one ID before you add any * tasks. */ bool addId(const QString& i, bool changeCurrentId = true); /** * Returns the first (default) ID of the project. */ QString getId() const { return projectIDs.isEmpty() ? QString() : projectIDs.first(); } /** * Returns the current project ID. If the project ID list is empty * an empty QString is returned. */ QString getCurrentId() const { return currentId; } /** * Returns a list of all registered project IDs. */ QStringList getProjectIdList() const { return projectIDs; } /** * Returns true if the passed ID is a registered project ID. */ bool isValidId(const QString& i) const { return projectIDs.indexOf(i) != -1; } /** * Returns a string ID of the index of the passed ID in the project ID. * The first ID in the list is returned as "A", the second as "B". The * 27th is "AA" and so on. */ QString getIdIndex(const QString& i) const; /** * Returns the number of supported scenarios. */ int getMaxScenarios() const { return scenarioList.count(); } /** * Returns a pointer to the scenario. * @param sc Index of the scenario in the project scenario list. */ Scenario* getScenario(int sc) const; /** * Returns a pointer to the scenario with index sc. * @param sc Index of the scenario in the project scenario list. */ QString getScenarioId(int sc) const; /** * Returns the name of a scenario. * @param sc Index of the scenario in the project scenario list. */ QString getScenarioName(int sc) const; /** * Returns the index of the scenario. The index of the first item in the * list is 1, not 0! If the scenario is unknown -1 is returned. * @param id the ID of the scenario. */ int getScenarioIndex(const QString& id) const; /** * Returns an interator for the list of defined scenarios. */ ScenarioListIterator getScenarioIterator() const { return ScenarioListIterator(scenarioList); } /** * Set the name of the project. The project name is mainly used for the * reports. */ void setName(const QString& n) { name = n; } /** * Returns the name of the project. */ const QString& getName() const { return name; } /** * Set the version number of the project. This version is mainly used for * reports. */ void setVersion(const QString& v) { version = v; } /** * Returns the version number of the project. */ const QString& getVersion() const { return version; } /** * Set the copyright information. This is a default text used for all * reports. */ void setCopyright(const QString& c) { copyright = c; } /** * Returns the copyright information of the project. */ const QString& getCopyright() const { return copyright; } /** * Set the customer information for this project. */ void setCustomer(const QString& c) { customer = c; } /** * Returns the customer information of the project. */ const QString& getCustomer() const { return customer; } /** * Set the default priority for all top-level tasks. Normally this value * is 500. */ void setPriority(int p) { priority = p; } /** * Returns the default priority for all top-level tasks. */ int getPriority() const { return priority; } /** * Set the start time of the project. */ void setStart(time_t s) { start = s; } /** * Get the start time of the project. */ time_t getStart() const { return start; } /** * Set the end time of the project. The specified second is still * considered as within the project time frame. */ void setEnd(time_t e) { end = e; } /** * Get the end time of the project. */ time_t getEnd() const { return end; } /** * Set the date that TaskJuggler uses as current date for all * computations. This mainly affects status reporting and the computation * of the completion degree of tasks. */ void setNow(time_t n); /** * Get the date that TaskJuggler uses as current date. */ time_t getNow() const { return now; } /** * Specifies whether TaskJuggler uses Sunday or Monday as first day of the * week. Besides the calendar views this mainly affects the numbering of * weeks. ISO 8601:1988 requires the week to start on Monday as most * European countries use, but other Countries like the US use Sunday as * first day of the week. */ void setWeekStartsMonday(bool wsm) { weekStartsMonday = wsm; } /** * Get the setting for the first day of the week. * @return true of weeks should start on Monday. */ bool getWeekStartsMonday() const { return weekStartsMonday; } /** * Decides if containers which subtasks are all hidden should be * drawn as normal tasks or not. */ void setDrawEmptyContainersAsTasks(bool decat) { drawEmptyContainerAsTasks = decat; } /** * @return true if containers which subtasks are all hidden should be * drawn as normal tasks */ bool getDrawEmptyContainersAsTasks() const { return drawEmptyContainerAsTasks; } /** * Set the working hours of the specified weekday. * @param day The day of the week. Independently of the weekStartsMonday * setting TaskJuggler uses 0 for Sunday, 1 for Monday and so on. * @param l The list of working intervals. The interval use seconds since * midnight. As with all TaskJuggler intervals, the specified end value is * not part of the interval. The interval ends one seconds earlier. */ void setWorkingHours(int day, const QList& l); /** * Returns a constant list of working intervals for all week days. */ const QList* const * getWorkingHours() const { return static_cast* const*> (workingHours); } /** * Returns the list of working intervals for the specified weekday. * @param day Day of the week. 0 for Sunday, 1 for Monday and so on. */ QList* getWorkingHours(int day) const { if (day < 0 || day > 6) qFatal("day out of range"); return workingHours[day]; } /** * Returns an interator for the list of working intervals for the * specified weekday. * @param day Day of the week. 0 for Sunday, 1 for Monday and so on. */ QListIterator getWorkingHoursIterator(int day) const { return QListIterator(*workingHours[day]); } /** * If there is a working interval defined for this weekday and the * day is not registered as a vacation day then it is a workday. */ bool isWorkingDay(time_t d) const; /** * If date is contained in a vacation day or the date is outside * of the defined working hours, false is returned. Otherwise true. */ bool isWorkingTime(time_t d) const; /** * If the interval overlaps with a vacation day or the interval is outside * of the defined working hours, false is returned. Otherwise true. */ bool isWorkingTime(const Interval& iv) const; /** * Returns the number of working days that overlap with the specified * interval. */ int calcWorkingDays(const Interval& iv) const; /** * The daily working hours value is used to convert working hours into * working days. It should be an avarage value of the specified * workingHours for each week day. With this function you can set the * value for the project. */ void setDailyWorkingHours(double h) { dailyWorkingHours = h; } /** * Returns the specified daily working hours. */ double getDailyWorkingHours() const { return dailyWorkingHours; } /** * The weekly working days value is used to convert working days into * working weeks. It should match the number of working days specified * with the workingHours. The value is derived from the yearlyWorkingDays * setting. This function returns the value. */ double getWeeklyWorkingDays() const { return yearlyWorkingDays / 52.1429; } /** * The monthly working days value is used to convert working days into * working month. It should reflect the workingHours settings and the * vacation settings. The value is derived from the yearlyWorkingDays * setting. This function returns the value. */ double getMonthlyWorkingDays() const { return yearlyWorkingDays / 12; } /** * The yearly working days value is used to convert working days into * working years. The value should reflect the workingHours settings and * the vacation settings. This function sets the value which also affects * the monthly working days and the weekly working days. */ void setYearlyWorkingDays(double wd) { yearlyWorkingDays = wd; } /** * Returns the specified number of working days per year. */ double getYearlyWorkingDays() const { return yearlyWorkingDays; } void setScheduleGranularity(ulong s) { scheduleGranularity = s; } ulong getScheduleGranularity() const { return scheduleGranularity; } void setAllowRedefinitions(bool ar) { allowRedefinitions = ar; } bool getAllowRedefinitions() const { return allowRedefinitions; } /** * Add a vacation interval to the vacation list. These global vacations * are meant for events like Christmas, Eastern or corporate holidays. * A day that overlaps any of the intervals in the list is considered to * not be a working day. Vacation intervals may not overlap. * @param n Name of the vacation. * @param i The time interval the vacation lasts. */ void addVacation(const QString& n, const Interval& i) { vacationList.add(n, i); } void addVacation(VacationInterval* vi) { vacationList.add(vi); } /** * Returns true if the passed moment falls within any of the vacation * intervals. */ bool isVacation(time_t vd) const { return vacationList.isVacation(vd); } /** * Returns the name of the first vacation that the given date falls into. * If no vacation is found QString::Null is returned. */ QString vacationName(time_t vd) const { return vacationList.vacationName(vd); } /** * Returns an iterator for the vacation list. */ VacationList::Iterator getVacationListIterator() const { return VacationList::Iterator(vacationList); } /** * This function is for library internal use only. Creating a Scenario * object with the project as parameter will automatically add it to the * scenario list of the project. */ void addScenario(Scenario* r); /** * This function is for library internal use only. Deleting a Scenario * will automatically delete it from the respective list of the * project. */ void deleteScenario(Scenario* s); /** * This function is for library internal use only. Creating a Task object * with the project as parameter will automatically add it to the Task * list of the project. */ void addTask(Task* t); /** * This function is for library internal use only. Deleting a Task * will automatically delete it from the respective list of the * project. */ void deleteTask(Task* t); /** * Returns a pointer to the Task with the specified ID. The ID must be an * absolute ID of the form "foo.bar". If no Task with the ID exists 0 is * returned. */ Task* getTask(const QString& id) const { return taskList.getTask(id); } /** * Returns the number of tasks of the project. */ uint taskCount() const { return taskList.count(); } /** * Returns a copy of the Task list of the project. */ TaskList getTaskList() const { return taskList; } /** * Returns an iterator that can be used to traverse the Task list. The * Task list is a flat list of all tasks. */ TaskListIterator getTaskListIterator() const { return TaskListIterator(taskList); } /** * This function adds a new, user-defined attribute to the Task * attributes. The @param id must be unique within the Task attributes * namespace. @param cad is a pointer to the CustomAttributeDefinition * object. */ bool addTaskAttribute(const QString& id, CustomAttributeDefinition* cad); /** * Returns a pointer to the custom attribute object identified by @param id. * If no attributes with the id exists, 0 is returned. */ const CustomAttributeDefinition* getTaskAttribute(const QString& id) const; /** * Returns a read-only pointer to the dictionary that holds the pointers * to user-defined attributes of Tasks. */ const QMap& getTaskAttributeDict() const { return taskAttributes; } /** * This function is for library internal use only. Creating a Resource * object with the project as parameter will automatically add it to the * resource list of the project. */ void addResource(Resource* r); /** * This function is for library internal use only. Deleting a Resource * will automatically delete it from the respective list of the * project. */ void deleteResource(Resource* r); /** * Returns a pointer to the Resource with the specified ID. The ID must * not be an absolute ID since the Resource list has a flat namespace. If * no Resource with the ID exists 0 is returned. */ Resource* getResource(const QString& id) const { return resourceList.getResource(id); } /** * Returns the number of resources in the Resource list. */ uint resourceCount() const { return resourceList.count(); } /** * Returns a copy of the Resource list. */ ResourceList getResourceList() const { return resourceList; } /** * Returns an iterator that can be used to traverse the Resource list. The * Resource list is a flat list of all resources. */ ResourceListIterator getResourceListIterator() const { return ResourceListIterator(resourceList); } /** * This function adds a new, user-defined attribute to the Resource * attributes. The @param id must be unique within the Resource attributes * namespace. @param cad is a pointer to the CustomAttributeDefinition * object. */ bool addResourceAttribute(const QString& name, CustomAttributeDefinition* cad); /** * Returns a pointer to the custom attribute object identified by @param id. * If no attributes with the id exists, 0 is returned. */ const CustomAttributeDefinition* getResourceAttribute(const QString& id) const; /** * Returns a read-only pointer to the dictionary that holds the pointers * to user-defined attributes of Resources. */ const QMap& getResourceAttributeDict() const { return resourceAttributes; } /** * This function is for library internal use only. Creating an Account * object with the project as parameter will automatically add it to the * Account list of the project. */ // void addAccount(Account* a); /** * This function is for library internal use only. Deleting a Account * will automatically delete it from the respective list of the * project. */ // void deleteAccount(Account* a); /** * Returns a pointer to the Account with the specified ID. The ID may * not be an absolute ID since the account list has a flat namespace. If * no Account with the ID exists 0 is returned. */ /* Account* getAccount(const QString& id) const { return accountList.getAccount(id); }*/ /** * Returns the number of accounts in the Account list. */ // uint accountCount() const { return accountList.count(); } /** * Returns a copy of the Account list. */ // AccountList getAccountList() const { return accountList; } /** * Returns an iterator that can be used to traverse the Account list. The * Account list is a flat list of all accounts. */ /* AccountListIterator getAccountListIterator() const { return AccountListIterator(accountList); }*/ /** * This function adds a new, user-defined attribute to the Account * attributes. The @param id must be unique within the Account attributes * namespace. @param cad is a pointer to the CustomAttributeDefinition * object. */ /* bool addAccountAttribute(const QString& name, CustomAttributeDefinition* cad);*/ /** * Returns a pointer to the custom attribute object identified by @param id. * If no attributes with the id exists, 0 is returned. */ /* const CustomAttributeDefinition* getAccountAttribute(const QString& id) const;*/ /** * Returns a read-only pointer to the dictionary that holds the pointers * to user-defined attributes of Accounts. */ // const QList& // getAccountAttributeDict() const // { // return accountAttributes; // } /** * This function is for library internal use only. Creating a Shift * object with the project as parameter will automatically add it to the * Shift list of the project. */ void addShift(Shift* s); /** * This function is for library internal use only. Deleting a Shift * will automatically delete it from the respective list of the * project. */ void deleteShift(Shift* s); /** * Returns a pointer to the Shift with the specified ID. The ID may * not be an absolute ID since the Shift list has a flat namespace. If * no Shift with the ID exists 0 is returned. */ Shift* getShift(const QString& id) const { return shiftList.getShift(id); } /** * Returns the number of shifts in the shift list. */ uint shiftCount() const { return shiftList.count(); } /** * Returns a copy of the Shift list. */ ShiftList getShiftList() const { return shiftList; } /** * Returns an iterator that can be used to traverse the Shift list. The * Shift list is a flat list of all accounts. */ ShiftListIterator getShiftListIterator() const { return ShiftListIterator(shiftList); } /** * Set the minimum daily effort for resources. This value is not used for * resource allocation. It is currently not used at all. In future * versions TaskJuggler might spit out warnings for all resources that are * not loaded to at least this value each day. The value is inherited by * all resources that are created subsequent to this function call. */ void setMinEffort(double m) { minEffort = m; } /** * Returns the default minimum effort value. */ double getMinEffort() const { return minEffort; } /** * Set the maximum efforts for resources. This is the default value * inherited by all resources created subsequent to this function call. A * resource is never loaded more each day, week, month etc. than the * maximum effort value specified for the resource. */ void setResourceLimits(UsageLimits* l); /** * Returns the default effort limits for resources. */ const UsageLimits* getResourceLimits() const { return resourceLimits; } /** * Set the default daily cost rate for resources. This value is inherited * by all resources created subsequent to this function call. */ // void setRate(double r) { rate = r; } /** * Return the default daily cost rate for resources. */ // double getRate() const { return rate; } /** * Set the currency unit for the project. */ // void setCurrency(const QString& s) { currency = s; } /** * Returns the currency unit setting. */ // const QString& getCurrency() const { return currency; } /** * Sets the number of decimal digits used for all currency values of the * project. */ // void setCurrencyDigits(uint cd) { currencyFormat.setFracDigits(cd); } /** * Sets the default number format for load and other values. */ // void setNumberFormat(const RealFormat& rf) { numberFormat = rf; } /** * Returns the current default number format. */ // const RealFormat& getNumberFormat() const { return numberFormat; } /** * Sets the default currency format. */ // void setCurrencyFormat(const RealFormat& rf) { currencyFormat = rf; } /** * Returns the default currency format. */ // const RealFormat& getCurrencyFormat() const { return currencyFormat; } /** * Set the default time zone for the project. */ bool setTimeZone(const QString& tz); /** * Returns the default time zone of the project; */ const QString& getTimeZone() const { return timeZone; } /** * Sets the format used for timestamps in reports. It will be used as * default for all subsequent report definitions. See the TaskJuggler * manual for the format details. */ void setShortTimeFormat(const QString& tf) { shortTimeFormat = tf; } /** * Returns the format for timestamps in reports. */ const QString& getShortTimeFormat() const { return shortTimeFormat; } /** * Sets the format used for date stamps in reports. It will be used as * default for all subsequent report definitions. See the TaskJuggler * manual for the format details. */ void setTimeFormat(const QString& tf) { timeFormat = tf; } /** * Returns the format for date stamps in reports. */ const QString& getTimeFormat() const { return timeFormat; } // void addXMLReport(ReportXML *r ) { xmlreport = r; } // // void addReport(Report* r) // { // reports.append(r); // } // Report* getReport(uint idx) const; // QPtrListIterator getReportListIterator() const; void addAllowedFlag(QString flag) { if (!isAllowedFlag(flag)) allowedFlags.append(flag); } bool isAllowedFlag(const QString& flag) const { return allowedFlags.contains(flag) > 0; } const QStringList getAllowedFlags() const { return allowedFlags; } /** * Converts working seconds to working days. */ double convertToDailyLoad(long secs) const; void setMaxErrors(int me) { maxErrors = me; } // void addJournalEntry(JournalEntry* entry); // // bool hasJournal() const { return !journal.isEmpty(); } // // Journal::Iterator getJournalIterator() const; /** * Generate cross references between all data structures and run a * consistency check. This function must be called after the project data * tree has been constructed. * @return Only if all tests were successful true is returned. */ bool pass2(bool noDepCheck); bool scheduleScenario(Scenario* sc); void breakScheduling(); void completeBuffersAndIndices(); bool scheduleAllScenarios(); // bool generateReports() const; // bool generateXMLReport() const; Q_SIGNALS: void updateProgressInfo(const QString& i); void updateProgressBar(int i, int of); private: void overlayScenario(int base, int sc); void prepareScenario(int sc); void finishScenario(int sc); TaskList tasksReadyToBeScheduled(int sc, const TaskList &leafTasks); bool schedule(int sc); bool checkSchedule(int sc) const; /// The start date of the project time_t start; /// The end date of the project time_t end; /// The current date used in status calculations and reports. time_t now; bool allowRedefinitions; /// True if week based calculations use Monday as first day of week. bool weekStartsMonday; /// True if containers w/o visible subtask should be drawn as normal tasks bool drawEmptyContainerAsTasks; /// The name of the Project QString name; /// The revision of the project description. QString version; /// Some legal words to please the boss. QString copyright; /// Some information about the customer of this project. QString customer; /// The default timezone of the project. QString timeZone; /** * A format string in strftime(3) format that specifies the default time * format for all time values TaskJuggler generates. */ QString timeFormat; /** * A format string in strftime(3) format that specifies the time format * for all daytime values (e. g. HH:MM). */ QString shortTimeFormat; /// The currency of used for all money values. QString currency; /// The number of fraction digits of all money values. int currencyDigits; // The default format used for printing load values and the like. // RealFormat numberFormat; // The default format used for printing currency values. // RealFormat currencyFormat; /** * The default priority that will be inherited by all tasks. Sub tasks * will inherit the priority of its parent task. */ int priority; /// Default values for Resource variables (TODO: should be obsoleted!) double minEffort; /** * The default resource usage limits. */ UsageLimits* resourceLimits; /** * The default daily cost of a resource. The value is inherited to all * resources but can be overridden. */ double rate; /* The average number of working hours per day. This factor is used * when converting hours in working days. It should match the workingHours * closely. */ double dailyWorkingHours; /* The average number of working days per year. This factor is used when * converting working days into years. It should match the defined working * hours and vacation days. */ double yearlyWorkingDays; /* The list of standard working or opening hours. These values will be * inherited by the resources as default working hours. */ QList* workingHours[7]; /** * The granularity of the scheduler in seconds. No intervals * shorter than this time will be scheduled. */ ulong scheduleGranularity; /** * To avoid difficult to find typos in flag names all flags must * be registered before they can be used. This variable contains * the list of all registered flags. It is legal to declare a flag * twice, so we can merge projects to a larger project. */ QStringList allowedFlags; /** * Each project has a unique ID but can have multiple other IDs as * well. This happens usually when small projects are merged to a * create a big project. Each task can be assigned to a different * project ID but all IDs must be declared before they can be * used. */ QStringList projectIDs; QString currentId; int maxErrors; // Journal journal; VacationList vacationList; ScenarioList scenarioList; TaskList taskList; ResourceList resourceList; // AccountList accountList; ShiftList shiftList; /** * The following lists contain a deep copy of their unscheduled * counterpart. They will be used to initialize the working lists before * an optimizer run. */ TaskList originalTaskList; ResourceList originalResourceList; // AccountList originalAccountList; QMap taskAttributes; QMap resourceAttributes; // QList accountAttributes; /* This is for version 1.0 XML reports and should be removed before the * next major release. */ /* ReportXML* xmlreport; QPtrList reports; QPtrList interactiveReports;*/ QStringList sourceFiles; // This flag is raised to abort the scheduling. bool breakFlag; } ; } // namespace TJ #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/Resource.h b/src/plugins/schedulers/tj/taskjuggler/Resource.h index 25cc70d6..400d66c9 100644 --- a/src/plugins/schedulers/tj/taskjuggler/Resource.h +++ b/src/plugins/schedulers/tj/taskjuggler/Resource.h @@ -1,279 +1,279 @@ /* * Resource.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 * by Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _Resource_h_ #define _Resource_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include "ResourceScenario.h" class QDomDocument; class QDomElement; namespace TJ { class Project; class Shift; class Task; class Booking; class SbBooking; class BookingList; class Interval; class UsageLimits; /** * @short Stores all information about a resource. * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT Resource : public CoreAttributes +class PLANTJ_EXPORT Resource : public CoreAttributes { friend int ResourceList::compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2, int level); public: Resource(Project* p, const QString& i, const QString& n, Resource* pr, const QString& df = QString(), uint dl = 0); virtual ~Resource(); static void deleteStaticData(); virtual CAType getType() const { return CA_Resource; } Resource* getParent() const { return static_cast(parent); } ResourceListIterator getSubListIterator() const { return ResourceListIterator(*sub); } void inheritValues(); bool isGroup() const { return !sub->isEmpty(); } void setMinEffort(double e) { minEffort = e; } double getMinEffort() const { return minEffort; } void setLimits(UsageLimits* l); const UsageLimits* getLimits() const { return limits; } void setEfficiency(double e) { efficiency = e; } double getEfficiency() const { return efficiency; } bool isWorker() const; void setRate(double r) { rate = r; } double getRate() const { return rate; } void addVacation(Interval* i); QListIterator getVacationListIterator() const { return QListIterator(vacations); } bool hasVacationDay(time_t day) const; bool isOnShift(const Interval& slot) const; void setWorkingHours(int day, const QList& l); const QList* const* getWorkingHours() const { return static_cast* const*>(workingHours); } bool addShift(const Interval& i, Shift* s); bool addShift(ShiftSelection* s); const ShiftSelectionList* getShiftList() const { return &shifts; } /** * \retval 0 { resource is available } * \retval 1 { resource is unavailable } * \retval 2 { resource is on vacation } * \retval 3 { undefined } * \retval 4 { resource is allocated to a task } */ int isAvailable(time_t day); bool book(Booking* b); bool bookSlot(uint idx, SbBooking* nb); // bool bookInterval(Booking* b, int sc, int sloppy = 0, int overtime = 0); // bool addBooking(int sc, Booking* b, int sloppy = 0, int overtime = 0); /// Return a list of booked intervals for scenario @p sc and task @p task QVector getBookedIntervals(int sc, const Task* task) const; double getCurrentLoad(const Interval& i, const Task* task = 0) const; /// Get the number of work slots for the day @p date. It includes both free and booked. uint getWorkSlots(time_t date) const; uint getCurrentDaySlots(time_t date, const Task* t); uint getCurrentWeekSlots(time_t date, const Task* t); uint getCurrentMonthSlots(time_t date, const Task* t); /*** * Return the load of the resource (and its children) weighted by their * efficiency. */ double getEffectiveLoad(int sc, const Interval& i, AccountType acctType = AllAccounts, const Task* task = 0) const; double getAllocatedTimeLoad(int sc, const Interval& period, AccountType acctType, const Task* task = 0) const; long getAllocatedTime(int sc, const Interval& period, AccountType acctType, const Task* task = 0) const; /*** * Return the unallocated load of the resource and its children wheighted * by their efficiency. */ double getEffectiveFreeLoad(int sc, const Interval& period); double getAvailableTimeLoad(int sc, const Interval& period); long getAvailableTime(int sc, const Interval& period); double getCredits(int sc, const Interval& i, AccountType acctType, const Task* task = 0) const; QString getProjectIDs(int sc, const Interval& i, const Task* task = 0) const; bool isAllocated(int sc, const Interval& i, const QString& prjId = QString()) const; bool isAllocated(int sc, const Interval& i, const Task* t) const; BookingList getJobs(int sc) const; time_t getStartOfFirstSlot(int sc, const Task* task); time_t getEndOfLastSlot(int sc, const Task* task); QDomElement xmlIDElement( QDomDocument& doc ) const; void copyBookings(int sc, SbBooking*** srd, SbBooking*** dst); void saveSpecifiedBookings(); void prepareScenario(int sc); void finishScenario(int sc); bool bookingsOk(int sc); void resetAllocationProbability(int sc) { allocationProbability[sc] = 0; } void addAllocationProbability(int sc, double ap) { allocationProbability[sc] += ap; } double getAllocationProbability(int sc) const { return allocationProbability[sc]; } TaskListIterator getTaskListIterator(int sc) const { return TaskListIterator(scenarios[sc].allocatedTasks); } // void addJournalEntry(JournalEntry* entry); // bool hasJournal() const { return !journal.isEmpty(); } // Journal::Iterator getJournalIterator() const; private: void getPIDs(int sc, const Interval& period, const Task* task, QStringList& pids) const; void initScoreboard(); long getCurrentLoadSub(uint startIdx, uint endIdx, const Task* task) const; long getAllocatedSlots(int sc, uint startIdx, uint endIdx, AccountType acctType, const Task* task) const; long getAvailableSlots(int sc, uint startIdx, uint endIdx); bool isAllocatedSub(int sc, uint startIdx, uint endIdx, const QString& prjId) const; bool isAllocatedSub(int sc, uint startIdx, uint endIdx, const Task* task) const; void updateSlotMarks(int sc); uint sbIndex(time_t date) const; time_t index2start(uint idx) const; time_t index2end(uint idx) const; /// The minimum effort (in man days) the resource should be used per day. double minEffort; /// List of notes with a date attached. // Journal journal; /// Usage limits of the resource. UsageLimits* limits; /** * The efficiency of the resource. A team of five should have an * efficiency of 5.0 */ double efficiency; /// The daily costs of this resource. double rate; /// The list of standard working or opening hours for the resource. QList* workingHours[7]; /** * In addition to the standard working hours a set of shifts can be * defined. This is useful when the working hours change over time. * A shift is only active in a defined interval. If no interval is * defined for a period of time the standard working hours of the * resource are used. */ ShiftSelectionList shifts; /// List of all intervals the resource is not available. QList vacations; /** * For each time slot (of length scheduling granularity) we store: * A pointer to a booking, or * 0 if the resource is available, * 1 if slot is off-hours, * 2 if slot is during a vacation. */ SbBooking** scoreboard; /// The number of time slots in the project. uint sbSize; SbBooking*** specifiedBookings; SbBooking*** scoreboards; ResourceScenario* scenarios; /** * The allocation probability is calculated prior to scheduling a * scenario. It is the expected average effort the resource has to deliver * based on the assignments to tasks, not taking parallel assignments into * account. */ double* allocationProbability; } ; } // namespace TJ #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/ResourceList.h b/src/plugins/schedulers/tj/taskjuggler/ResourceList.h index b2a3d3d5..c1f9c6fb 100644 --- a/src/plugins/schedulers/tj/taskjuggler/ResourceList.h +++ b/src/plugins/schedulers/tj/taskjuggler/ResourceList.h @@ -1,64 +1,64 @@ /* * ResourceList.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _ResourceList_h_ #define _ResourceList_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include "CoreAttributesList.h" class QString; namespace TJ { class Resource; /** * @short A list of resources. * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT ResourceList : public CoreAttributesList +class PLANTJ_EXPORT ResourceList : public CoreAttributesList { public: ResourceList(); virtual ~ResourceList() { } Resource* getResource(const QString& id) const; static bool isSupportedSortingCriteria(int sc); virtual int compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2, int level); } ; /** * @short Iterator class for ResourceList objects. * @author Chris Schlaeger */ class ResourceListIterator : public virtual CoreAttributesListIterator { public: explicit ResourceListIterator(const CoreAttributesList& l) : CoreAttributesListIterator(l) { } ~ResourceListIterator() { } Resource* operator*(); } ; } // namespace TJ #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/Scenario.h b/src/plugins/schedulers/tj/taskjuggler/Scenario.h index 2e36057c..08d6831d 100644 --- a/src/plugins/schedulers/tj/taskjuggler/Scenario.h +++ b/src/plugins/schedulers/tj/taskjuggler/Scenario.h @@ -1,70 +1,70 @@ /* * Scenario.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _Scenario_h_ #define _Scenario_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include "ScenarioList.h" class QString; namespace TJ { class Project; -class KPLATOTJ_EXPORT Scenario : public CoreAttributes +class PLANTJ_EXPORT Scenario : public CoreAttributes { friend int ScenarioList::compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2, int level); public: Scenario(Project* p, const QString& i, const QString& n, Scenario* s); virtual ~Scenario(); virtual CAType getType() const { return CA_Scenario; } Scenario* getParent() const { return static_cast(parent); } ScenarioListIterator getSubListIterator() const; void setEnabled(bool e) { enabled = e; } bool getEnabled() const { return enabled; } void setProjectionMode(bool p) { projectionMode = p; } bool getProjectionMode() const { return projectionMode; } void setOptimize(bool o) { optimize = o; } bool getOptimize() const { return optimize; } void setStrictBookings(bool s) { strictBookings = s; } bool getStrictBookings() const { return strictBookings; } void setMinSlackRate(double msr) { minSlackRate = msr; } double getMinSlackRate() const { return minSlackRate; } void setMaxPaths(long l) { maxPaths = l; } long getMaxPaths() const { return maxPaths; } private: bool enabled; bool projectionMode; bool strictBookings; bool optimize; double minSlackRate; long maxPaths; } ; } // namespace TJ #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/Task.h b/src/plugins/schedulers/tj/taskjuggler/Task.h index db17e6b6..468713b2 100644 --- a/src/plugins/schedulers/tj/taskjuggler/Task.h +++ b/src/plugins/schedulers/tj/taskjuggler/Task.h @@ -1,595 +1,595 @@ /* * task.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 * Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _Task_h_ #define _Task_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" // #include #include #include #include "debug.h" #include "TaskList.h" #include "TaskScenario.h" #include "ShiftSelectionList.h" #include "LoopDetectorInfo.h" #include "TaskDependency.h" // #include "Journal.h" class QDomElement; class QDomDocument; namespace TJ { class Project; class Resource; // class Account; class Shift; class ShiftSelection; class TaskList; class Allocation; class Interval; /** * This class stores all task related information and provides methods to * manipulate them. It provides fundamental functions like the scheduler. * * @short The class that holds all task related information. * @see Resource * @see CoreAttributes * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT Task : public CoreAttributes +class PLANTJ_EXPORT Task : public CoreAttributes { friend int TaskList::compareItemsLevel(CoreAttributes*, CoreAttributes*, int); public: Task(Project* prj, const QString& id_, const QString& n, Task* p, const QString& f, int l); virtual ~Task(); virtual CAType getType() const { return CA_Task; } Task* getParent() const { return static_cast(parent); } TaskListIterator getSubListIterator() const { return TaskListIterator(*sub); } enum SchedulingInfo { ASAP, ALAP }; void inheritValues(); void setProjectId(const QString& i) { projectId = i; } const QString& getProjectId() const { return projectId; } void setNote(const QString& d) { note = d; } const QString& getNote() const { return note; } // void addJournalEntry(JournalEntry* entry); // bool hasJournal() const { return !journal.isEmpty(); } // Journal::Iterator getJournalIterator() const; void setReference(const QString& r, const QString& l) { ref = r; refLabel = l; } const QString& getReference() const { return ref; } const QString& getReferenceLabel() const { return refLabel; } void setScheduling(SchedulingInfo si) { scheduling = si; } SchedulingInfo getScheduling() const { return scheduling; } void setPriority(int p) { priority = p; } int getPriority() const { return priority; } void setResponsible(Resource* r) { responsible = r; } Resource* getResponsible() const { return responsible; } void setMilestone(bool ms = true) { milestone = ms; } bool isMilestone() const { return milestone; } // // // void setAccount(Account* a) { account = a; } // // // Account* getAccount() const { return account; } TaskDependency* addDepends(const QString& id); QList getDepends() const { return depends; } QListIterator getDependsIterator() const { return QListIterator(depends); } TaskDependency* addPrecedes(const QString& id); QList getPrecedes() const { return precedes; } QListIterator getPrecedesIterator() const { return QListIterator(precedes); } /// Add working time defined in @p shift for interval @p i bool addShift(const Interval& i, Shift* s); /// Return true if @p slot is defined as working time /// Falls back to project definitions if no shifts has been defined for this task bool isWorkingTime(const Interval &slot) const; void addAllocation(Allocation* a) { allocations.append(a); } void purgeAllocations() { allocations.clear(); } QListIterator getAllocationIterator() const { return QListIterator(allocations); } TaskListIterator getPreviousIterator() const { return TaskListIterator(previous); } bool hasPrevious() const { return !previous.isEmpty(); } TaskListIterator getFollowersIterator() const { return TaskListIterator(followers); } bool hasFollowers() const { return !followers.isEmpty(); } bool hasPrevious(const Task* t) { return previous.indexOf(const_cast(t)) != -1; } bool hasFollower(const Task* t) { return followers.indexOf(const_cast(t)) != -1; } // The following group of functions operates only on scenario variables. void setSpecifiedStart(int sc, time_t s) { scenarios[sc].specifiedStart = s; qDebug()<<"Task::setSpecifiedStart:"<(t)); } /** * @retval true if itself or one of its subtasks (recursively) is on the critical path * @retval false otherwise. */ bool isOrHasDescendantOnCriticalPath(int sc) const; bool isContainer() const { return !sub->isEmpty(); } bool xRef(QMap& hash); void implicitXRef(); void sortAllocations(); void saveSpecifiedBookedResources(); QString resolveId(QString relId); bool preScheduleOk(int sc); bool scheduleOk(int sc) const; /** * Checks for loops in task interdependencies starting with the current * task. * @param ckedTaskList The list of already checked tasks. Will be appended * to. * @retval true if a loop was detected. * @retval false otherwise. */ bool loopDetector(LDIList& chkedTaskList) const; bool checkDetermination(int sc) const; void computeBuffers(); time_t nextSlot(time_t slotDuration) const; bool isReadyForScheduling() const; bool schedule(int sc, time_t& reqStart, time_t duration); void propagateInitialValues(int sc); void setRunaway(); bool isRunaway() const; bool isSubTask(const Task* t) const; bool isSchedulingDone() const { return schedulingDone; } void errorMessage(const QString& msg) const; void warningMessage(const QString& msg) const; QDomElement xmlElement( QDomDocument& doc, bool absId = true ); TaskList getSuccessors() const { return successors; } TaskList getPredecessors() const { return predecessors; } bool hasAlapPredecessor() const; private: friend class Project; void propagateStart(int sc, time_t date); void propagateEnd(int sc, time_t date); /** * Checks for loops in task interdependencies starting with the current * task under ASAP or ALAP scheduling. * @param ckedTaskList The list of already checked tasks. Will be appended * to. * @retval true if a loop was detected. * @retval false otherwise. */ bool loopDetection(LDIList& list, LDIList& chkedTaskList, bool atEnd, bool fromOutside) const; bool checkPathForLoops(LDIList& list, bool atEnd) const; bool scheduleContainer(int sc); Task* subFirst() { return 0/*(Task*) sub->first()*/; } Task* subNext() { return 0/*(Task*) sub->next()*/; } /// Returns the availability of @p resource and its required resources (if any) int isAvailable(Allocation *allocation, Resource *resource, time_t slot) const; /// Book resource @p r if it (and its required resources) is available bool bookResource(Allocation *allocation, Resource* r, time_t day, time_t duration, int& slotsToLimit, int& availability); void bookResources(int sc, time_t day, time_t duration); void addBookedResource(Resource* r) { if (bookedResources.indexOf((CoreAttributes*) r) == -1) bookedResources.inSort((CoreAttributes*) r); } QList createCandidateList(int sc, time_t date, Allocation* a); time_t earliestStart(int sc) const; time_t latestEnd(int sc) const; bool startCanBeDetermined(LDIList& list, int sc) const; bool endCanBeDetermined(LDIList& list, int sc) const; bool hasStartDependency(int sc) const; bool hasEndDependency(int sc) const; bool hasStartDependency() const; bool hasEndDependency() const; bool analyzePath(int sc, double minSlack, time_t pathStart, long busyTime, long worstMinSlackTime, long& checked, long& found); void collectTransientFollowers(TaskList& list); bool countMilestones(int sc, time_t now, int& totalMilestones, int& completedMilestones, int& reportedCompletedMilestones); bool sumUpEffort(int sc, time_t now, double& totalEffort, double& completedEffort, double& reportedCompletedEffort); /// A longer description of the task. QString note; /// List of notes with a date attached. // Journal journal; /// A reference to an external document QString ref; /// A label used instead of the reference QString refLabel; /** * The dependencies of the task are stored twice. depends and precedes * store the information specified in the project file. For convenience we * also store the backward dependency together with the specified * dependencies in predecessors and successors. */ QList depends; /// @see depends QList precedes; /** * A list of tasks that must precede this task. */ TaskList predecessors; /** * A list of tasks that must follow this task. */ TaskList successors; /** * A list of all tasks that precede this task. It's the combination of * depends and predecessors. This is redundant information but stored for * convenience. Interdependent tasks are linked in a doubly linked list. */ TaskList previous; /** * A list of all tasks that follow this task. It's the combination of * precedes and successors. This is redundant information but stored for * convenience. Interdependent tasks are linked in a doubly linked list. */ TaskList followers; /** * The ID of the project this task belongs to. This is only * meaningful if multiple projects are joined to create a big * project. */ QString projectId; /// True if the task is a milestone. bool milestone; /** * The priority is used during scheduling. The higher the priority * the more likely the task will get the requested resources. */ int priority; /// The scheduling policy of the task. SchedulingInfo scheduling; /// ID of responsible resource. Resource* responsible; /// Tasks may only be worked on during the specified shifts. /// Also defines the working time of length tasks ShiftSelectionList shifts; /// List of resource allocations requested by the task QList allocations; /// Account where the credits of the task are credited to. // Account* account; TaskScenario* scenarios; /* The following group of variables store values generated during a * scheduler run. They might be initialized by other values and/or * they might contain results of the scheduling run. But they should * never be initialized directly or read out directly. They should have * corresponding scenario variables. The get/set interface functions * should only access the scenario variables. */ /// Day when the task should start time_t start; /// Day when the task should end time_t end; /// Length in working days double length; /// Effort (in man days) needed to complete the task double effort; /// Duration in calendar days double duration; /// The already completed effort in a scheduler run. double doneEffort; /// The already completed length in a scheduler run. double doneLength; /// The already completed duration in a scheduler run. double doneDuration; /** * Set to true when the first time slots have with resource usage * have been allocated. */ bool workStarted; /** * Since the full time slot might not be available we need to * store the tentative start of a task in a separate * variable. Storing the information in 'start' would mark the * task as fully scheduled which might not yet be the case. */ time_t tentativeStart; /** * Since the full time slot might not be available we need to * store the tentative end of a task in a separate * variable. Storing the information in 'end' would mark the task * as fully scheduled which might not yet be the case. */ time_t tentativeEnd; /** * Depending on the scheduling policy the tasks need to be scheduled * from one end the other in a continuous way. No timeslot may be * scheduled twice. This variable stores information about the last * allocation, so we can make sure the next slot is exactly adjacent * the previous one. */ time_t lastSlot; /// This variable is set to true when the task has been scheduled. bool schedulingDone; /** This flag is set when the task does not fit into the project time * frame. */ bool runAway; /// A list of all the resources booked for this task. ResourceList bookedResources; } ; } // namespace TJ -KPLATOTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Task* t ); -KPLATOTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Task& t ); +PLANTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Task* t ); +PLANTJ_EXPORT QDebug operator<<( QDebug dbg, const TJ::Task& t ); #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/TaskList.h b/src/plugins/schedulers/tj/taskjuggler/TaskList.h index e9e8bd12..614a13b7 100644 --- a/src/plugins/schedulers/tj/taskjuggler/TaskList.h +++ b/src/plugins/schedulers/tj/taskjuggler/TaskList.h @@ -1,79 +1,79 @@ /* * TaskList.h - TaskJuggler * * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _TaskList_h_ #define _TaskList_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #include "CoreAttributesList.h" class QString; namespace TJ { class Task; /** * @short The class stores a list of tasks. * @see Task * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT TaskList : public virtual CoreAttributesList +class PLANTJ_EXPORT TaskList : public virtual CoreAttributesList { public: TaskList() : CoreAttributesList(), sortScenario(0) { sorting[0] = CoreAttributesList::TreeMode; sorting[1] = CoreAttributesList::StartUp; sorting[2] = CoreAttributesList::EndUp; } TaskList(const TaskList& tl) : CoreAttributesList(tl), sortScenario(tl.sortScenario) { } virtual ~TaskList() { } Task* getTask(const QString& id) const; static bool isSupportedSortingCriteria(int sc); virtual int compareItemsLevel(CoreAttributes* c1, CoreAttributes* c2, int level); void setSortScenario(int sc) { sortScenario = sc; } protected: int sortScenario; } ; /** * @short Iterator class for TaskList objects. * @see TaskList * @author Chris Schlaeger */ -class KPLATOTJ_EXPORT TaskListIterator : public virtual CoreAttributesListIterator +class PLANTJ_EXPORT TaskListIterator : public virtual CoreAttributesListIterator { public: explicit TaskListIterator(const CoreAttributesList& l) : CoreAttributesListIterator(l) { } virtual ~TaskListIterator() { } Task* operator*(); } ; } // namespace TJ #endif diff --git a/src/plugins/schedulers/tj/taskjuggler/debug.h b/src/plugins/schedulers/tj/taskjuggler/debug.h index 91ee2bd7..6ad82d81 100644 --- a/src/plugins/schedulers/tj/taskjuggler/debug.h +++ b/src/plugins/schedulers/tj/taskjuggler/debug.h @@ -1,72 +1,72 @@ /* * debug.h - TaskJuggler * * Copyright (c) 2002 by Chris Schlaeger * Copyright (c) 2011 by Dag Andersen * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * $Id$ */ #ifndef _debug_h_ #define _debug_h_ -#include "kplatotj_export.h" +#include "plantj_export.h" #define DEBUGMODE DebugCtrl.getDebugMode() #define DEBUGLEVEL DebugCtrl.getDebugLevel() #define PFDEBUG 1 // Project File Reader #define PSDEBUG 2 // Project Scheduler #define TSDEBUG 4 // Task Scheduler #define RSDEBUG 8 // Resource Scheduler #define EXDEBUG 16 // Expression Tree Ev. #define MADEBUG 32 // Macro Expander #define XXDEBUG 64 // Unused #define PADEBUG 128 // Critical Path // Analyzer #define DEBUGPF(l) ((DEBUGMODE & 1) && DEBUGLEVEL >= l) // Project File Reader #define DEBUGPS(l) ((DEBUGMODE & 2) && DEBUGLEVEL >= l) // Project Scheduler #define DEBUGTS(l) ((DEBUGMODE & 4) && DEBUGLEVEL >= l) // Task Scheduler #define DEBUGRS(l) ((DEBUGMODE & 8) && DEBUGLEVEL >= l) // Resource Scheduler #define DEBUGEX(l) ((DEBUGMODE & 16) && DEBUGLEVEL >= l) // Expression Tree Ev. #define DEBUGMA(l) ((DEBUGMODE & 32) && DEBUGLEVEL >= l) // Macro Expander #define DEBUGXX(l) ((DEBUGMODE & 64) && DEBUGLEVEL >= l) // Unused #define DEBUGPA(l) ((DEBUGMODE & 128) && DEBUGLEVEL >= l) // Critical Path // Analyzer -class KPLATOTJ_EXPORT DebugController +class PLANTJ_EXPORT DebugController { public: DebugController() : debugLevel(0), debugMode(-1) { } ~DebugController() { } void setDebugLevel(int l) { debugLevel = l; } int getDebugLevel() const { return debugLevel; } void setDebugMode(int m) { debugMode = m; } int getDebugMode() const { return debugMode; } protected: int debugLevel; int debugMode; } ; -extern KPLATOTJ_EXPORT DebugController DebugCtrl; +extern PLANTJ_EXPORT DebugController DebugCtrl; #endif