M/c++_api/inc/DM/IControlObject.hpp
1 #ifndef DM_ICONTROL_OBJECT_HPP_INCLUDED
2 #define DM_ICONTROL_OBJECT_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 #include "DM/config.hpp"
9 #include "DM/Handle.hpp"
10 #include "DM/ObjectBase.hpp"
11 
12 DM_NAMESPACE_BEGIN
13 
14 /// \brief Control object are used to get status information of extensive processing step and/or to interrupt those processing steps
15 class DM_API IControlObject : public ObjectBase
16 {
17 public:
18  /// creates an control object for the standard output
19  static IControlObject* NewStdOut(bool clearAfterFinish = false, int updatePrecision = 0);
20  /// creates an control object for the standard output with callbacks
21  static IControlObject* NewStdOut(void *callbackObj, bool (*isInterrupted)(void *), void (*setStepCount)(void *, long long), void (*setCurrStep)(void *, long long), bool clearAfterFinish = false, int updatePrecision = 0);
22 
23  /// creates an 'silent' control object which doesn't make any output
24  static IControlObject* NewSilent();
25  /// creates an 'silent' control object which doesn't make any output but with callbacks
26  static IControlObject* NewSilent(void *callbackObj, bool (*isInterrupted)(void *), void (*setStepCount)(void *, long long), void (*setCurrStep)(void *, long long));
27 
28 protected:
29  virtual ~IControlObject() {}
30 
31 public:
32  virtual IControlObject *clone() const = 0;
33 
34  /// set overall step count
35  virtual void stepCount( int64_t stepCount ) = 0;
36  /// get overall step count
37  virtual int64_t stepCount() const = 0;
38 
39  /// set current step
40  virtual void currentStep( int64_t currStep ) = 0;
41  /// increase current step
42  virtual void increaseCurrentStep( int64_t incCount = 1 ) = 0;
43  /// get current step
44  virtual int64_t currentStep() const = 0;
45  /// returns current step in [%]
46  virtual double currentStepPercentage() const = 0;
47 
48  /// set the interrupt flag
49  virtual void interrupt( bool flag ) = 0;
50  /// returns the interrupt flag
51  virtual bool interrupted() const = 0;
52 
53  /// set the finished flag
54  virtual void finish( bool flag ) = 0;
55  /// returns the finished flag
56  virtual bool finished() const = 0;
57 };
58 
59 
61 
62 DM_NAMESPACE_END
63 
64 #endif //DM_IPROCESSOR_HPP_INCLUDED