2 * ModuleBase_Operation.h
4 * Created on: Apr 2, 2014
9 #ifndef ModuleBase_Operation_H
10 #define ModuleBase_Operation_H
12 #include <ModuleBase.h>
13 #include <ModuleBase_IOperation.h>
18 #include <boost/shared_ptr.hpp>
20 class ModelAPI_Feature;
21 class ModelAPI_Document;
24 \class ModuleBase_Operation
25 * \brief Base class for all operations
27 * Base class for all operations. If you perform an action it is reasonable to create
28 * operation intended for this. This is a base class for all operations which provides
29 * mechanism for correct starting operations, starting operations above already started
30 * ones, committing operations and so on. To create own operation it is reasonable to
31 * inherit it from this class and redefines virtual methods to provide own behavior
32 * Main virtual methods are
33 * - virtual bool isReadyToStart();
34 * - virtual void startOperation();
35 * - virtual void abortOperation();
36 * - virtual void commitOperation();
39 class MODULEBASE_EXPORT ModuleBase_Operation: public ModuleBase_IOperation
45 /// \param theId the operation identifier
46 /// \param theParent the QObject parent
47 ModuleBase_Operation(const QString& theId = "", QObject* theParent = 0);
49 virtual ~ModuleBase_Operation();
51 /// Returns the operation feature
52 /// \return the feature
53 boost::shared_ptr<ModelAPI_Feature> feature() const;
55 // Data model methods.
56 /// Stores a real value in model.
57 /// \param theValue - to store
58 void storeReal(double theValue);
59 /// Stores a custom value in model.
60 void storeCustomValue();
63 /// Virtual method called when operation started (see start() method for more description)
64 /// Default impl calls corresponding slot and commits immediately.
65 virtual void startOperation();
66 /// Virtual method called when operation stopped - committed or aborted.
67 virtual void stopOperation();
68 /// Virtual method called when operation aborted (see abort() method for more description)
69 virtual void abortOperation();
70 /// Virtual method called when operation committed (see commit() method for more description)
71 virtual void commitOperation();
73 /// Creates an operation new feature
74 /// \returns the created feature
75 virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
77 /// Returns the operation feature
78 /// \return the feature
79 void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
82 boost::shared_ptr<ModelAPI_Feature> myFeature; /// the operation feature to be handled