-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
45 lines (30 loc) · 804 Bytes
/
test.cpp
File metadata and controls
45 lines (30 loc) · 804 Bytes
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
#include "channel.hpp"
#include "agent.hpp"
using namespace std;
using namespace CppAgent;
class TestAgent : public BaseAgent {
public:
class StopMessage {
};
void main () {
cout << "thread starting!\n";
anet << "hello world!";
StopMessage stop;
anet >> stop;
cout << "thread closing!\n";
}
};
int main () {
// TODO: try making TestAgent : public Agent <Test> hide Test as private to TestAgent s.t. only
// the thread main (which is a friend of the class) can access Test;
// thread main belongs to TestAgent, so Test can be any class at all (pre-existing)
TestAgent test;
AgentThread thread (test);
// tell agent to quit running
TestAgent::StopMessage stop;
anet << stop;
// get last message sent by agent
string str;
anet >> str;
cout << str << endl;
}