-
Notifications
You must be signed in to change notification settings - Fork 5
/
OLCB_Virtual_Node.h
62 lines (50 loc) · 1.27 KB
/
OLCB_Virtual_Node.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
57
58
59
60
61
62
#ifndef __OLCB_VIRTUAL_NODE_H__
#define __OLCB_VIRTUAL_NODE_H__
#if defined(__AVR__)
#include <stdlib.h>
#endif
#include <string.h>
#include "OLCB_Link.h"
#include "OLCB_NodeID.h"
#include "OLCB_Buffer.h"
class OLCB_Link;
//A class for representing a virtual node. A virtual node is a state machine for handling
// one or more application-level protocols. Each board must implement at least one virtual node.
// Generally, this class will not be subclassed directly, but rather through one of the intermediate
// abstract base classes Event_Handler, Datagram_Hander, or Stream_Handler, depending on the
// transport method used by the protocol.
class OLCB_Virtual_Node
{
public:
virtual void update(void) {}
bool isPermitted(void)
{
if(NID)
{
return NID->initialized;
}
else
{
return false;
}
}
void create(OLCB_Link *link, OLCB_NodeID *nid)
{
_link = link;
NID = nid;
}
virtual bool handleMessage(OLCB_Buffer *buffer)
{
return false;
}
//clears any pending communications between this node and nodeid
virtual void clearBuffer(OLCB_NodeID *nodeid)
{
//Serial.println("nothing");
return;
}
OLCB_Virtual_Node *next;
OLCB_Link *_link;
OLCB_NodeID *NID;
};
#endif