summaryrefslogtreecommitdiffstats
path: root/src/uscxml/interpreter/ContentExecutorImpl.h
blob: 8221591fa86cd83698a5f649efa8531e0cd11893 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
 *  @file
 *  @author     2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
 *  @copyright  Simplified BSD
 *
 *  @cond
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the FreeBSD license as published by the FreeBSD
 *  project.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 *  You should have received a copy of the FreeBSD license along with this
 *  program. If not, see <http://www.opensource.org/licenses/bsd-license>.
 *  @endcond
 */

#ifndef CONTENTEXECUTORIMPL_H_3ABA8969
#define CONTENTEXECUTORIMPL_H_3ABA8969


#include "uscxml/Common.h"
#include "uscxml/messages/Event.h"
#include "uscxml/interpreter/InterpreterMonitor.h"
#include "uscxml/interpreter/Logging.h"
#include "uscxml/plugins/ExecutableContent.h"

#include <string>
#include <set>
#include <map>

namespace XERCESC_NS {
class DOMDocument;
class DOMNode;
}

namespace uscxml {

class X;

/**
 * @ingroup execcontent
 * @ingroup callback
 */
class USCXML_API ContentExecutorCallbacks {
public:
	virtual void enqueueInternal(const Event& event) = 0;
	virtual void enqueueExternal(const Event& event) = 0;
	virtual void enqueueExternalDelayed(const Event& event, size_t delayMs, const std::string& eventUUID) = 0;
	virtual void cancelDelayed(const std::string& eventId) = 0;

	virtual bool isTrue(const std::string& expr) = 0;
	virtual size_t getLength(const std::string& expr) = 0;

	virtual void setForeach(const std::string& item,
	                        const std::string& array,
	                        const std::string& index,
	                        uint32_t iteration) = 0;

	virtual Data evalAsData(const std::string& expr) = 0;
	virtual void eval(const std::string& expr) = 0;
	virtual Data getAsData(const std::string& expr) = 0;
	virtual bool isLegalDataValue(const std::string& expr) = 0;
	virtual void assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attrs) = 0;


	virtual std::string getInvokeId() = 0;
	virtual std::string getBaseURL() = 0;
	virtual bool checkValidSendType(const std::string& type, const std::string& target) = 0;
	virtual void enqueue(const std::string& type, const std::string& target, size_t delayMs, const Event& sendEvent) = 0;
	virtual void invoke(const std::string& type, const std::string& src, bool autoForward, XERCESC_NS::DOMElement* finalize, const Event& invokeEvent) = 0;
	virtual void uninvoke(const std::string& invokeId) = 0;

	virtual const Event& getCurrentEvent() = 0;

	/** Monitoring */
	virtual std::set<InterpreterMonitor*> getMonitors() = 0;
	virtual const std::string& getSessionId() = 0;
	virtual Logger getLogger() = 0;

	virtual ExecutableContent createExecutableContent(const std::string& localName, const std::string& nameSpace) = 0;

};

/**
 * @ingroup execcontent
 * @ingroup impl
 */
class USCXML_API ContentExecutorImpl {
public:
	ContentExecutorImpl(ContentExecutorCallbacks* callbacks) : _callbacks(callbacks) {}

	virtual std::shared_ptr<ContentExecutorImpl> create(ContentExecutorCallbacks* callbacks) = 0;

	virtual void process(XERCESC_NS::DOMElement* block) = 0;

	virtual void invoke(XERCESC_NS::DOMElement* invoke) = 0;
	virtual void uninvoke(XERCESC_NS::DOMElement* invoke) = 0;

	virtual void raiseDoneEvent(XERCESC_NS::DOMElement* state, XERCESC_NS::DOMElement* doneData) = 0;
	virtual Data elementAsData(XERCESC_NS::DOMElement* element, bool asExpression = false) = 0;

protected:
	ContentExecutorCallbacks* _callbacks;

};

}

#endif /* end of include guard: CONTENTEXECUTORIMPL_H_3ABA8969 */