Add Freescale Nexus decoder implementation
[babeltrace.git] / converter / nexus / Application.h
1 /*
2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
21 */
22
23 #ifndef APPLICATION_H
24 #define APPLICATION_H
25
26 #include <inttypes.h>
27 #include <string>
28 #include <map>
29 #include <vector>
30
31 #include "NxMessageDecoder.h"
32
33 using std::string;
34 using std::map;
35 using std::vector;
36
37 class NxMessageVisitor;
38
39 /*!
40 The Application is the top level driver delivering from a file
41 a stream of Nexus encoded 32bit words to the NexusDecoder.
42 The output will be the decoded Nexus messages.
43 */
44 class Application
45 {
46 public:
47 Application();
48 ~Application();
49
50 /*!
51 @abstract Set the verbosity on or off for the Application
52 @param verbose Set true or false
53 */
54 void verbose(bool verbose)
55 {
56 verbose_ = verbose;
57 decoder_.verbose(verbose_);
58 }
59
60 /*!
61 @abstract Set the summary on or off for the Application
62 @param summary Set true or false
63 */
64 void summary(bool summary)
65 {
66 summary_ = summary;
67 }
68
69 /*!
70 @abstract Enable the Full Address Log for the Application
71 */
72 void enableFullAddrLog();
73
74 /*!
75 @abstract Enable the FMan Detail Log for the Application
76 */
77 void enableFmanLog();
78
79 /*!
80 @abstract Open the named file and process the Nexus data
81 @param fn filename containing data
82 @return true if no errors
83 */
84 bool process(const string &fn);
85
86 /*!
87 @abstract output a summary report on number of messages by type
88 */
89 void summarize();
90
91 private:
92
93 /*!
94 @abstract Determine if the name file contains binary formatted data
95 @param fn filename containing data
96 @return true if binary formatted file
97 */
98 bool isBinFile_(const string &fn) const;
99 /*!
100 @abstract Open the named text file and process the Nexus data
101 @param fn filename containing data
102 @return true if no errors
103 */
104 bool processTextFile_(const string &fn);
105
106 /*!
107 @abstract Open the named text file and process the Nexus data
108 @param fn filename containing data
109 @return true if no errors
110 */
111 bool processBinFile_(const string &fn);
112
113 /*!
114 @abstract Process the Nexus data
115 @param data value
116 @return true if no errors
117 */
118 bool process_(const uint32_t data);
119
120 /*! @var verbose_ Holds the verbosity state */
121 bool verbose_;
122
123 /*! @var summary_ Holds state of summary count of all Messages */
124 bool summary_;
125
126 /*! @var decoder_ Provides the decoder */
127 NxMessageDecoder decoder_;
128
129 /* count of all data words */
130 uint32_t data_counter_;
131
132 /* count of all messages */
133 uint32_t msg_counter_;
134
135 /*! @var msg_count_ A count of messages by type */
136 map<string, uint32_t> msg_count_;
137
138 // List of Visitors to handle the messages
139 vector<NxMessageVisitor*> visitors_;
140 };
141
142 #endif // APPLICATION_H
This page took 0.043563 seconds and 4 git commands to generate.