-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.cpp.back
67 lines (51 loc) · 1.74 KB
/
test1.cpp.back
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
#include <string>
#include <ostream>
#include <iostream>
#include "Instance.h"
using std::cout;
using std::cerr;
using std::endl;
static void badInstanceManager();
static void badTruckTerminal();
static void badTruckSegment();
int main(int argc, char *argv[]) {
Ptr<Instance::Manager> manager = shippingInstanceManager();
if (manager == NULL) {
badInstanceManager();
return 1;
}
Ptr<Instance> a = manager->instanceNew("terminal1", "Truck terminal");
Ptr<Instance> a2 = manager->instanceNew("terminal2", "Truck terminal");
if (a == NULL) {
badTruckTerminal();
return 1;
}
Ptr<Instance> b = manager->instanceNew("seg1", "Truck segment");
Ptr<Instance> c = manager->instanceNew("seg2", "Truck segment");
if (b == NULL || c == NULL ) {
badTruckSegment();
return 1;
}
b->attributeIs("source", "terminal1");
c->attributeIs("source", "terminal2");
c->attributeIs("return segment", "seg1");
// cout << a->attribute("segment1") << endl;
// cout << a->attribute("segment2") << endl;
cout << b->attribute("return segment") << endl;
cout << "Done!" << endl;
cerr << "Now deleting the segment 2 from location" << endl;
b->attributeIs("return segment", "");
cout << b->attribute("return segment") << endl;
return 0;
}
static void badInstanceManager() {
cerr << "Unexpected Null pointer from shippingInstanceManager" << endl;
}
static void badTruckTerminal() {
cerr << "Unable to create terminal1" << endl;
}
static void badTruckSegment() {
cerr << "You need to update the "
"instanceNew() function to create all types " << endl <<
"of nodes and interfaces." << endl;
}