c++_api/inc/opals/IControlObject.hpp
1 #pragma once
2 
3 #include "opals/fwd.hpp"
4 #include "opals/String.hpp"
5 #include "opals/Vector.hpp"
6 #include "opals/LogLevel.hpp"
7 
8 namespace opals {
9 
10  /**
11  \class IControlObject
12  \brief Interface for retrieving status and progress information from a module run
13  \author jo
14  \date 06.09.2012
15 
16  \internal
17  An object that is derived from that interface can be applied to an opals module allows
18  retrieving status and progress information while executing the run function. Status information
19  is set synchronous by the modules. Attention: complex code within that the member functions (especially \see setSteps)
20  will slow down the processing performance. If the object is also accessed from a second thread, its the objects
21  responsibility to secure thread safety.
22 
23  A control object can be passed (by reference) to a OPALS module either while creating a new instance or using the
24  opals::IModuleBase::set_controlObject. It's the programmers responsibility to secure proper lifetime of the control
25  object (or use opals::IModuleBase::unset_controlObject to remove the internal link).
26 
27  To interrupt processing throw the opals::Exceptions::UserInterrupt within the overloaded member function (mainly relevant in setSteps).
28  */
29 
30  class OPALS_API IControlObject {
31  public:
32  virtual ~IControlObject() {}
33 
34  /// sets the descriptions of the stages (implicitly sets the number of stages. it will be set within the module's run function)
35  virtual void setStages(const Vector<String> &stageDescriptions) = 0;
36 
37  /// \brief sets the current stage (zero based index)
38  /// In rare situations no step information will be available for a certain stage. Usually those stages are processed quite quickly
39  virtual void setCurrStage(unsigned currentStage) = 0;
40 
41  /// \brief sets the number of steps for the current stage (will be called after the stage was set)
42  /// This function is always called before the first corresponding setCurrStep call.
43  virtual void setSteps(long long stepCount) = 0;
44 
45  /// \brief sets the current step
46  /// It is internally secured that for the last setCurrStep call currStep >= stepCount for the corresponding stage.
47  virtual void setCurrStep(long long currStep) = 0;
48 
49  /// retrieve log message
50  virtual void log(LogLevel level, unsigned threadId, const char* message) = 0;
51  };
52 
53 }
LogLevel
Enumerator defining different importance levels of log records.
Definition: LogLevel.hpp:8
Contains the public interface of OPALS.
Definition: AbsValueOrQuantile.hpp:8
Interface for retrieving status and progress information from a module run.
Definition: c++_api/inc/opals/IControlObject.hpp:30