forked from TheUnity42/2551FinalProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemory.hpp
More file actions
60 lines (49 loc) · 1.5 KB
/
Copy pathMemory.hpp
File metadata and controls
60 lines (49 loc) · 1.5 KB
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
#ifndef Memory_hpp
#define Memory_hpp
#include "Contact.hpp"
#include "Message.hpp"
#define MAX_CONTACTS 10
#define MAX_MESSAGES 20
#define INIT_FLAG 0xC0FFEE
#define CONTACT_FLAG 0xFACE
#define MESSAGE_FLAG 0xCA11
#define INIT_START 0
#define CONTACT_FLAG_START 18
#define MESSAGE_FLAG_START 171
#define CONTACT_START 21
#define MESSAGE_START 174
#define NODE_IDENTIFIER 3
#define CONTACT_COUNTER 20
#define MESSAGE_COUNTER 173
#define CONTACT_SIZE sizeof(Contact)
#define MESSAGE_SIZE sizeof(Message)
class Memory {
public:
Memory();
Memory(Contact node);
unsigned char *getNodeUUID();
char *getNodeName();
unsigned short getNumberContacts();
unsigned short getNumberMessages();
Contact getContact(unsigned short index);
Message getMessage(unsigned short index);
bool saveContact(Contact contact);
void saveMessage(Message message);
void saveNodeInformation(Contact contact);
protected:
bool hasSchema();
void setSchema();
void clearMessages();
void clearContacts();
unsigned short getMessagePointerOffset();
public:
unsigned char read(unsigned int uiAddress);
void write(unsigned int uiAddress, unsigned char data);
Contact getContactFromMemory(unsigned short addr);
Message getMessageFromMemory(unsigned short addr);
unsigned char *getUUIDFromMemory(unsigned short addr);
void saveContactToMemory(Contact contact, unsigned short addr);
void saveMessageToMemory(Message message, unsigned short addr);
void saveUUIDToMemory(unsigned char *uuid, unsigned short addr);
};
#endif /* Memory_hpp */