|
1 /* |
|
2 * Copyright 2007 Intel Corporation |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #ifndef _SIMLOG_H_ |
|
18 #define _SIMLOG_H_ |
|
19 |
|
20 #include <oasys/io/FileIOClient.h> |
|
21 #include <oasys/util/Singleton.h> |
|
22 #include <oasys/util/StringBuffer.h> |
|
23 |
|
24 namespace dtn { |
|
25 class Bundle; |
|
26 } |
|
27 |
|
28 using namespace dtn; |
|
29 |
|
30 namespace dtnsim { |
|
31 |
|
32 class Node; |
|
33 |
|
34 /** |
|
35 * Class for more structured logging of bundle generation / reception. |
|
36 */ |
|
37 class SimLog : public oasys::Singleton<SimLog> { |
|
38 public: |
|
39 SimLog(); |
|
40 |
|
41 void log_gen(Node* n, Bundle* b) { log_entry("GEN", n, b); } |
|
42 void log_recv(Node* n, Bundle* b) { log_entry("RECV", n, b); } |
|
43 void log_xmit(Node* n, Bundle* b) { log_entry("XMIT", n, b); } |
|
44 void log_arrive(Node* n, Bundle* b) { log_entry("ARR", n, b); } |
|
45 void log_dup(Node* n, Bundle* b) { log_entry("DUP", n, b); } |
|
46 void log_expire(Node* n, Bundle* b) { log_entry("EXP", n, b); } |
|
47 void log_inqueue(Node* n, Bundle* b) { log_entry("INQ", n, b); } |
|
48 |
|
49 void flush(); |
|
50 |
|
51 protected: |
|
52 void log_entry(const char* what, Node* n, Bundle* b); |
|
53 |
|
54 oasys::FileIOClient* file_; |
|
55 oasys::StringBuffer buf_; |
|
56 }; |
|
57 |
|
58 } // namespace dtnsim |
|
59 |
|
60 #endif /* _SIMLOG_H_ */ |