IJob.h
Go to the documentation of this file.
1 /********************************************************************
2 *
3 * Project Artec 3D Scanning SDK
4 *
5 * Purpose: Job interface.
6 *
7 * Copyright: Artec Group
8 *
9 ********************************************************************/
10 
11 #ifndef _IJOB_H_
12 #define _IJOB_H_
13 
15 #include <artec/sdk/base/IRef.h>
16 #include <artec/sdk/base/Errors.h>
17 
18 namespace artec { namespace sdk { namespace base
19 {
20 
21 class IJob;
22 class IJobObsever;
23 struct AlgorithmWorkset;
24 
25 extern "C"
26 {
27 /*
28 * Synchronously execute a job in several threads
29 * @param job - this parameter is an algorithm or a procedure,
30 * and it should be created with appropriate function like createXXXAlgorithm()
31 * or createXXXProcedure(). TRef should be used to hold this pointer,
32 * so the lifetime of the object will be cared of accordingly.
33 * @param workset - this parameter is a simple structure which can be
34 * created on stack or in dynamic memory. All his interface members,
35 * such in, out, progress (if any) or cancellation (if any) should live till
36 * the end of the job processing so please take care of that.
37 */
39  executeJob( IJob* job, const AlgorithmWorkset * workset );
40 
41 /*
42 * Asynchronously launch a job in several threads
43 * @param job - this parameter is an algorithm or a procedure,
44 * and it should be created with appropriate function like createXXXAlgorithm()
45 * or createXXXProcedure(). TRef should be used to hold this pointer,
46 * so the lifetime of the object will be cared of accordingly.
47 * @param workset - this parameter is a simple structure which can be
48 * created on stack or in dynamic memory. All his interface members,
49 * such in, out, progress (if any) or cancellation (if any) should live till
50 * the end of the job processing so please take care of that.
51 * @param jobObsever - this parameter is intended to receive notifications
52 * about job completeness. The particular class inheriting JobObseverBase should be defined and
53 * implemented by user, and TRef should be used to hold this pointer.
54 * The lifetime of this object will be cared of as well.
55 */
57  launchJob( IJob* job, const AlgorithmWorkset * workset, IJobObsever* jobObsever );
58 }
59 
60 /* Job Interface.
61 * Used by executeJob and launchJob
62 * Base for algorithms family and scanning
63 */
64 ///@see executeJob, launchJob
65 class IJob : public IRef
66 {
67 public:
68  /// Returns short job name for debug purposes
69  virtual const char* getDebugName() const = 0;
70 
71  ///< Returns the required number of threads
72  ///<@retval 0 Any positive number of threads is applicable.
73  ///<@retval >0 The returned number of threads is mandatory.
74  virtual unsigned int getThreadsRequired() const = 0;
75 
76  ///< Sets up the environment, makes a processing schedule
77  ///< @note It's called only for the first working thread
78  virtual ErrorCode start( const AlgorithmWorkset* runSet ) = 0;
79 
80  ///< Executes the algorithm's processing
81  ///< @note It's called for all working threads
82  virtual ErrorCode process( int threadIndex ) = 0;
83 
84  ///< Sums everything up in the end
85  ///< @note It's called only for the last working thread in case
86  ///< everything went ok and with no abortions
87  virtual ErrorCode finish() = 0;
88 
89  ///< Cleans up the environment
90  ///< @note The routine is called for the last working thread even if an error occurs
91  virtual ErrorCode reset() = 0;
92 };
93 
94 } } } // namespace artec::sdk::base
95 
96 #endif // _IJOB_H_
virtual ErrorCode process(int threadIndex)=0
ErrorCode ABASESDK_LINK_SPEC executeJob(IJob *job, const AlgorithmWorkset *workset)
virtual ErrorCode finish()=0
virtual unsigned int getThreadsRequired() const =0
virtual ErrorCode reset()=0
ErrorCode ABASESDK_LINK_SPEC launchJob(IJob *job, const AlgorithmWorkset *workset, IJobObsever *jobObsever)
virtual const char * getDebugName() const =0
Returns short job name for debug purposes.
#define ABASESDK_LINK_SPEC
Definition: BaseSdkDefines.h:7
virtual ErrorCode start(const AlgorithmWorkset *runSet)=0