Artec 3D Scanning SDK  2.0
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 IJobObserver;
23 struct AlgorithmWorkset;
24 
25 extern "C"
26 {
27 
28 /// @brief Synchronously execute a job in several threads
29 /// @param job is an algorithm or a procedure,
30 /// and it should be created with appropriate function like createXXXAlgorithm()
31 /// or createXXXProcedure(). Use TRef to hold this pointer
32 /// and take care of the object's lifetime.
33 /// @param workset is a simple structure which can be
34 /// created on stack or in a dynamic memory. All its interface members,
35 /// such as in, out, progress (if any) or cancellation (if any), should live till
36 /// the end of the job processing. Please take care of that.
37 ErrorCode ABASESDK_LINK_SPEC executeJob( IJob* job, const AlgorithmWorkset * workset );
38 
39 /// @brief Asynchronously launch a job in several threads
40 /// @param job - is an algorithm or a procedure,
41 /// and it should be created with appropriate function like createXXXAlgorithm()
42 /// The lifetime of this object will be cared of as well.
43 ErrorCode ABASESDK_LINK_SPEC launchJob( IJob* job, const AlgorithmWorkset * workset, IJobObserver* jobObserver );
44 
45 }
46 
47 /// Interface that represents a basic multithreaded work item;
48 /// Used by executeJob and launchJob.
49 /// Base for scanning and algorithms.
50 /// @see executeJob, launchJob
51 class IJob : public IRef
52 {
53 public:
54  /// Returns short job name for debug purposes
55  virtual const char* getDebugName() const = 0;
56 
57  /// Returns the required number of threads
58  /// @retval 0 Any positive number of threads is applicable.
59  /// @retval >0 The returned number of threads is mandatory.
60  virtual unsigned int getThreadsRequired() const = 0;
61 
62  /// Sets the environment up, makes a processing schedule
63  /// @note It is called only for the first working thread
64  virtual ErrorCode start( const AlgorithmWorkset* runSet ) = 0;
65 
66  /// Executes the algorithm's processing
67  /// @note It's called for all working threads
68  virtual ErrorCode process( int threadIndex ) = 0;
69 
70  /// Sums everything up in the end
71  /// @note It's called only for the last working thread in case
72  /// everything went smoothly and without any abortion.
73  virtual ErrorCode finish() = 0;
74 
75  /// Cleans the environment up
76  /// @note The routine is called for the last working thread even if an error occurs
77  virtual ErrorCode reset() = 0;
78 };
79 
80 } } } // namespace artec::sdk::base
81 
82 #endif // _IJOB_H_
virtual const char * getDebugName() const =0
Returns short job name for debug purposes.
virtual ErrorCode process(int threadIndex)=0
Executes the algorithm's processing.
ErrorCode ABASESDK_LINK_SPEC executeJob(IJob *job, const AlgorithmWorkset *workset)
Synchronously execute a job in several threads.
Interface that represents a basic multithreaded work item; Used by executeJob and launchJob...
Definition: IJob.h:51
Workset for algorithm parameters.
virtual ErrorCode finish()=0
Sums everything up in the end.
ErrorCode ABASESDK_LINK_SPEC launchJob(IJob *job, const AlgorithmWorkset *workset, IJobObserver *jobObserver)
Asynchronously launch a job in several threads.
virtual unsigned int getThreadsRequired() const =0
Returns the required number of threads.
virtual ErrorCode reset()=0
Cleans the environment up.
#define ABASESDK_LINK_SPEC
Interface that implements reference counting and life-time management.
Definition: IRef.h:22
virtual ErrorCode start(const AlgorithmWorkset *runSet)=0
Sets the environment up, makes a processing schedule.