InterpreterMonitor.h
Go to the documentation of this file.
1 
20 #ifndef INTERPRETERMONITOR_H_D3F21429
21 #define INTERPRETERMONITOR_H_D3F21429
22 
23 #include "uscxml/Common.h"
24 #include "uscxml/messages/Event.h"
26 
27 #include <mutex>
28 
29 #define USCXML_MONITOR_CATCH(callback) \
30 catch (Event e) { LOG(ERROR) << "Syntax error when calling " #callback " on monitors: " << std::endl << e << std::endl; } \
31 catch (std::bad_weak_ptr e) { LOG(ERROR) << "Unclean shutdown " << std::endl; } \
32 catch (...) { LOG(ERROR) << "An exception occurred when calling " #callback " on monitors"; } \
33 if (_state == USCXML_DESTROYED) { throw std::bad_weak_ptr(); }
34 
35 #define USCXML_MONITOR_CALLBACK(callback, function) \
36 if (callback) { callback->function(); }
37 
38 #define USCXML_MONITOR_CALLBACK1(callback, function, arg1) \
39 if (callback) { callback->function(arg1); }
40 
41 #define USCXML_MONITOR_CALLBACK2(callback, function, arg1, arg2) \
42 if (callback) { callback->function(arg1, arg2); }
43 
44 namespace uscxml {
45 
46 class USCXML_API InterpreterMonitor {
47 public:
48  InterpreterMonitor() : _copyToInvokers(false) {}
49  virtual ~InterpreterMonitor() {}
50 
51  virtual void beforeProcessingEvent(const Event& event) {}
52  virtual void beforeMicroStep() {}
53 
54  virtual void beforeExitingState(const XERCESC_NS::DOMElement* state) {}
55  virtual void afterExitingState(const XERCESC_NS::DOMElement* state) {}
56 
57  virtual void beforeExecutingContent(const XERCESC_NS::DOMElement* execContent) {}
58  virtual void afterExecutingContent(const XERCESC_NS::DOMElement* execContent) {}
59 
60  virtual void beforeUninvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {}
61  virtual void afterUninvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {}
62 
63  virtual void beforeTakingTransition(const XERCESC_NS::DOMElement* transition) {}
64  virtual void afterTakingTransition(const XERCESC_NS::DOMElement* transition) {}
65 
66  virtual void beforeEnteringState(const XERCESC_NS::DOMElement* state) {}
67  virtual void afterEnteringState(const XERCESC_NS::DOMElement* state) {}
68 
69  virtual void beforeInvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {}
70  virtual void afterInvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {}
71 
72  virtual void afterMicroStep() {}
73  virtual void onStableConfiguration() {}
74 
75  virtual void beforeCompletion() {}
76  virtual void afterCompletion() {}
77 
78  virtual void reportIssue(const InterpreterIssue& issue) {}
79 
80  void copyToInvokers(bool copy) {
81  _copyToInvokers = copy;
82  }
83 
84  bool copyToInvokers() {
85  return _copyToInvokers;
86  }
87 
88 protected:
89  bool _copyToInvokers;
90 
91 };
92 
94 public:
96  virtual ~StateTransitionMonitor() {}
97 
98  virtual void beforeTakingTransition(const XERCESC_NS::DOMElement* transition);
99  virtual void beforeExecutingContent(const XERCESC_NS::DOMElement* element);
100  virtual void onStableConfiguration();
101  virtual void beforeProcessingEvent(const uscxml::Event& event);
102  virtual void beforeExitingState(const XERCESC_NS::DOMElement* state);
103  virtual void beforeEnteringState(const XERCESC_NS::DOMElement* state);
104  virtual void beforeMicroStep();
105 
106 protected:
107  static std::recursive_mutex _mutex;
108 };
109 
110 }
111 
112 #endif /* end of include guard: INTERPRETERMONITOR_H_D3F21429 */
Definition: InterpreterIssue.cpp:33
Definition: InterpreterMonitor.h:46
Identify and report syntactic and semantic problems with a SCXML state-charts.
Definition: InterpreterIssue.h:43
Identifies some common problems with SCXML documents.
Definition: Event.h:84
Definition: InterpreterMonitor.h:93