-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathCloudProcess.h
56 lines (44 loc) · 1.49 KB
/
CloudProcess.h
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
/*
This file is part of the ArduinoIoTCloud library.
Copyright (c) 2024 Arduino SA
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef ARDUINO_IOT_CLOUD_PROCESS
#define ARDUINO_IOT_CLOUD_PROCESS
/******************************************************************************
* INCLUDES
******************************************************************************/
#include <message/Commands.h>
#include <interfaces/MessageStream.h>
#include <assert.h>
#include <functional>
/******************************************************************************
* CLASS DECLARATION
******************************************************************************/
class CloudProcess {
public:
CloudProcess(MessageStream* stream): stream(stream) {}
/**
* Abstract method that is called whenever a message comes from Message stream
* @param m: the incoming message
*/
virtual void handleMessage(Message* m) = 0;
/**
* Abstract method that is called to update the FSM of the CloudProcess
*/
virtual void update() = 0;
protected:
/**
* Used by a derived class to send a message to the underlying messageStream
* @param msg: the message to send
*/
void deliver(Message* msg) {
assert(stream != nullptr);
stream->sendUpstream(msg);
}
private:
MessageStream* stream;
};
#endif /* ARDUINO_IOT_CLOUD_PROCESS */