Atlas-C++
PresentationBridge.h
1 /*
2  Copyright (C) 2013 Erik Ogenvik
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software Foundation,
16  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef PRESENTATIONBRIDGE_H_
20 #define PRESENTATIONBRIDGE_H_
21 
22 #include <sstream>
23 #include <string>
24 #include <stack>
25 #include <deque>
26 #include "Bridge.h"
27 
28 namespace Atlas
29 {
30 
36 {
37 public:
38  explicit PresentationBridge(std::stringstream& stream);
39  ~PresentationBridge() override = default;
40 
41  void streamBegin() override;
42  void streamMessage() override;
43  void streamEnd() override;
44 
45  void mapMapItem(std::string name) override;
46  void mapListItem(std::string name) override;
47  void mapIntItem(std::string name, long) override;
48  void mapFloatItem(std::string name, double) override;
49  void mapStringItem(std::string name, std::string) override;
50  void mapEnd() override;
51 
52  void listMapItem() override;
53  void listListItem() override;
54  void listIntItem(long) override;
55  void listFloatItem(double) override;
56  void listStringItem(std::string) override;
57  void listEnd() override;
58 
66  void setMaxItemsPerLevel(size_t maxItems);
67 
73  void setStartFilteringLevel(size_t startFilteringLevel);
74 
75 private:
76 
77  void addPadding();
78 
79  void removePadding();
80 
85  bool checkAndUpdateMaxItemCounter();
86 
87  std::string mPadding;
88 
89  std::stringstream& mStream;
90 
96  std::stack<int> mMapsInList;
97 
101  size_t mMaxItemsPerLevel;
102 
106  bool mIsSkipEntry;
107 
112  size_t mStartFilterLevel;
113 
117  std::deque<size_t> mEntriesPerLevelCounter;
118 };
119 
120 }
121 #endif /* PRESENTATIONBRIDGE_H_ */
void listFloatItem(double) override
Adds a float to the currently streamed list.
void mapListItem(std::string name) override
Starts a list object to the currently streamed map.
void mapStringItem(std::string name, std::string) override
Adds a string to the currently streamed map.
Atlas stream bridge.
Definition: Bridge.h:35
void mapEnd() override
Ends the currently streamed map.
void listMapItem() override
Starts a map object in the currently streamed list.
void setStartFilteringLevel(size_t startFilteringLevel)
Sets the level at which filtering, if setMaxItemsPerLevel() has been called, should occur...
void streamEnd() override
Ends the Atlas stream.
The Atlas namespace.
Definition: Bridge.h:20
void streamBegin() override
Begin an Atlas stream.
void mapMapItem(std::string name) override
Starts a map object to the currently streamed map.
void listEnd() override
Ends the currently streamed list.
void mapFloatItem(std::string name, double) override
Adds a float to the currently streamed map.
void streamMessage() override
Start a message in an Atlas stream.
void mapIntItem(std::string name, long) override
Adds an integer to the currently streames map.
A bridge which is meant to be used solely for presenting Element data.
Definition: PresentationBridge.h:35
void listStringItem(std::string) override
Adds a string to the currently streamed list.
void listListItem() override
Starts a list object in the currently streamed list.
void listIntItem(long) override
Adds an integer to the currently streames list.
void setMaxItemsPerLevel(size_t maxItems)
Sets the max number of items to print per level.

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.