Atlas-C++
tutorial/example/DebugBridge.h
1 #ifndef DEBUG_BRIDGE_H
2 #define DEBUG_BRIDGE_H
3 
4 #include <iostream>
5 #include <string>
6 #include <Atlas/Bridge.h>
7 
8 class DebugBridge : public Atlas::Bridge
9 {
10 public:
11 
12  DebugBridge()
13  {
14  padding = "";
15  }
16 
17  virtual ~DebugBridge() { }
18 
19  virtual void streamBegin() {
20  std::cout << padding << "streamBegin" << std::endl;
21  addPadding();
22  }
23  virtual void streamMessage() {
24  std::cout << padding << "New Map" << std::endl;
25  addPadding();
26  }
27  virtual void streamEnd() {
28  removePadding();
29  std::cout << padding << "streamEnd" << std::endl;
30  }
31 
32  virtual void mapMapItem(const std::string& name)
33  {
34  std::cout << padding << name << " -> New Map" << std::endl;
35  addPadding();
36  }
37  virtual void mapListItem(const std::string& name)
38  {
39  std::cout << padding << name << " -> New List" << std::endl;
40  addPadding();
41  }
42  virtual void mapIntItem(const std::string& name, long i)
43  {
44  std::cout << padding << name << " -> Int: " << i << std::endl;
45  }
46  virtual void mapFloatItem(const std::string& name, double d)
47  {
48  std::cout << padding << name << " -> Float: " << d << std::endl;
49  }
50  virtual void mapStringItem(const std::string& name, const std::string& s)
51  {
52  std::cout << padding << name << " -> String: " << s << std::endl;
53  }
54  virtual void mapEnd()
55  {
56  removePadding();
57  std::cout << padding << "mapEnd" << std::endl;
58  }
59 
60  virtual void listMapItem()
61  {
62  std::cout << padding << "New Map" << std::endl;
63  addPadding();
64  }
65  virtual void listListItem()
66  {
67  std::cout << padding << "New List" << std::endl;
68  addPadding();
69  }
70  virtual void listIntItem(long i)
71  {
72  std::cout << padding << "Int: " << i << std::endl;
73  }
74  virtual void listFloatItem(double d)
75  {
76  std::cout << padding << "Float: " << d << std::endl;
77  }
78  virtual void listStringItem(const std::string& s)
79  {
80  std::cout << padding << "String: " << s << std::endl;
81  }
82  virtual void listEnd()
83  {
84  removePadding();
85  std::cout << padding << "listEnd" << std::endl;
86  }
87 
88 protected:
89  virtual void addPadding()
90  {
91  padding += " ";
92  }
93 
94  virtual void removePadding()
95  {
96  padding.erase(padding.end() - 2, padding.end());
97  }
98 
99  std::string padding;
100 };
101 
102 #endif // DEBUG_BRIDGE_H
DebugBridge::listMapItem
virtual void listMapItem()
Starts a map object in the currently streamed list.
Definition: tutorial/example/DebugBridge.h:60
Atlas::Bridge
Atlas stream bridge.
Definition: Bridge.h:35
DebugBridge::listFloatItem
virtual void listFloatItem(double d)
Adds a float to the currently streamed list.
Definition: tutorial/example/DebugBridge.h:74
DebugBridge::mapIntItem
virtual void mapIntItem(const std::string &name, long i)
Adds an integer to the currently streames map.
Definition: tutorial/example/DebugBridge.h:42
DebugBridge::mapStringItem
virtual void mapStringItem(const std::string &name, const std::string &s)
Adds a string to the currently streamed map.
Definition: tutorial/example/DebugBridge.h:50
DebugBridge::listStringItem
virtual void listStringItem(const std::string &s)
Adds a string to the currently streamed list.
Definition: tutorial/example/DebugBridge.h:78
DebugBridge
Definition: tests/Objects/DebugBridge.h:6
DebugBridge::mapMapItem
virtual void mapMapItem(const std::string &name)
Starts a map object to the currently streamed map.
Definition: tutorial/example/DebugBridge.h:32
DebugBridge::listIntItem
virtual void listIntItem(long i)
Adds an integer to the currently streames list.
Definition: tutorial/example/DebugBridge.h:70
DebugBridge::mapFloatItem
virtual void mapFloatItem(const std::string &name, double d)
Adds a float to the currently streamed map.
Definition: tutorial/example/DebugBridge.h:46
DebugBridge::listListItem
virtual void listListItem()
Starts a list object in the currently streamed list.
Definition: tutorial/example/DebugBridge.h:65
DebugBridge::mapEnd
virtual void mapEnd()
Ends the currently streamed map.
Definition: tutorial/example/DebugBridge.h:54
DebugBridge::streamMessage
virtual void streamMessage()
Start a message in an Atlas stream.
Definition: tutorial/example/DebugBridge.h:23
DebugBridge::listEnd
virtual void listEnd()
Ends the currently streamed list.
Definition: tutorial/example/DebugBridge.h:82
DebugBridge::streamEnd
virtual void streamEnd()
Ends the Atlas stream.
Definition: tutorial/example/DebugBridge.h:27
DebugBridge::mapListItem
virtual void mapListItem(const std::string &name)
Starts a list object to the currently streamed map.
Definition: tutorial/example/DebugBridge.h:37
DebugBridge::streamBegin
virtual void streamBegin()
Begin an Atlas stream.
Definition: tutorial/example/DebugBridge.h:19

Copyright 2000-2004 the respective authors.

This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.