1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "nel/misc/types_nl.h"
21 #include "nel/misc/debug.h"
22 #include "nel/misc/smart_ptr.h"
23 #include "game_share/singleton_registry.h"
25 class CJobManager
: public IServiceSingleton
28 static CJobManager
* getInstance();
31 class IJob
: public NLMISC::CRefCount
37 // return true if the job is finished -> the job object can be deleted
38 virtual bool finished()=0;
40 // return a status string that can be displayed in an update variable
41 virtual std::string
getShortStatus()=0;
43 // get a detailed status string for display in a job list etc
44 virtual std::string
getStatus()=0;
46 // display the details of the job... eg the list of files being processed with related info
47 virtual void display(NLMISC::CLog
* log
=NLMISC::InfoLog
)=0;
49 // run the job's update to do a bit of work
50 virtual void update()=0;
54 // add a job to the job vector and assign it a new id
55 uint32
addJob(NLMISC::CSmartPtr
<IJob
> job
);
57 // move a job to the front of the queue - treat it as the active job
58 void promoteJob(uint32 idx
);
60 // the update method used to call job updates
63 // do nothing during the service updates until 'resume()'
66 // resume after a 'pause()'
69 // accessors for the number of job updates per call to serviceUpdate()
70 void setJobUpdatesPerUpdate(uint32 count
);
71 uint32
getJobUpdatesPerUpdate();
73 // get the 'pause'/'resume' state, the number of jobsUpdatesPerUpdate and the status of the active job
74 std::string
getStatus();
76 // list the status of all jobs that are not finished
77 void listJobs(NLMISC::CLog
* log
=NLMISC::InfoLog
);
79 // list the status of all jobs including those that are finished
80 void listJobHistory(NLMISC::CLog
* log
=NLMISC::InfoLog
);
82 // call the currently active job's 'display' method
83 void displayCurrentJob(NLMISC::CLog
* log
=NLMISC::InfoLog
);
85 // call the given job's 'display' method
86 void displayJob(uint32 jobId
,NLMISC::CLog
* log
=NLMISC::InfoLog
);
91 typedef std::list
<uint32
> TUnfinishedJobs
;
92 typedef std::vector
<NLMISC::CSmartPtr
<IJob
> > TJobs
;
95 uint32 _JobUpdatesPerUpdate
;
97 TUnfinishedJobs _UnfinishedJobs
;