-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (54 loc) · 1.41 KB
/
main.cpp
File metadata and controls
74 lines (54 loc) · 1.41 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Created by Vladislav Molodtsov on 2019-03-31.
//
#include<iostream>
/*
* You should to copy these to your module
*/
/* ------ begin ---- - */
#include"Channels.h"
#include"Custom.h"
#include"Message.h"
using namespace message;
/* ------ end ---- - */
/*
*
* This main demostrates work with Message
*
*/
int main(int argc, char *argv[])
{
// It this case message types are scanning from console
int receiveType;
int sendType;
if(argc != 3)
{
std::cout << "Arg error" << std::endl;
return 1;
}
else
{
// The first argument is receive type, the second one -send type
receiveType = atoi(argv[1]);
sendType = atoi(argv[2]);
std::cout << "types: " << receiveType << " " << sendType << std::endl;
}
// Create and init object of Message class
Message<MessageType<Send>, MessageType<Receive>> com(receiveType, sendType);
com.InitMsg();
// Create MessageType objects with templates
// These templates are your own classes (see custom.h)
MessageType<Send> m;
MessageType<Receive> r;
// Your own method for Write (see custom.cpp)
m.data.Write(3.14, 6.5);
// Your own method for Print (see custom.cpp)
m.data.Print();
// You can send message using the following method:
com.SendMessage(m);
// You can receive message using the following method:
r = com.ReceiveMessage();
// Your own method for Print (see custom.cpp)
r.data.Print();
return 0;
}