WSF
DSV_Output.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2017 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef DSV_OUTPUT_HPP
13#define DSV_OUTPUT_HPP
14
15#include <map>
16#include <unordered_map>
17
18#include "post_processor_lib_export.h"
19
20#include "Report.hpp"
21#include "UtMemory.hpp"
22
23class POST_PROCESSOR_LIB_EXPORT DSV_Output : public Report
24{
25 public:
26
27 struct EventData
28 {
29 std::string mBaseFileName;
30 bool mSetIndex = false;
31 size_t mIndex = 0;
32 };
33
34 using EventMap = std::unordered_map<std::string, EventData>;
35
36 DSV_Output() = delete;
37 explicit DSV_Output(const Options& aOptions);
38 ~DSV_Output() override = default;
39
40 bool CreateRequiredData(std::string& aOutputDir) override;
41 bool Filter(std::vector<std::string>& aLine) override;
42 void PrintReportHeader(std::ostream& aStream) override;
43 bool StreamIsOpen(size_t aIndex) const;
44 std::ofstream& StreamRef(size_t aIndex) { return *mFileStreams[aIndex]; }
45
46 private:
47
48 void PrintReport(std::istream& aInStream,
49 std::ostream& aOutStream) override;
52 void ProcessHeaders(std::istream& aStream) override;
53
54 void AddEvent(const std::string& aEventName,
55 const std::string& aBaseFilename = "");
56 bool OpenFile(const std::string& aFileName,
57 size_t aIndex);
58
59 void PrintData(std::ostream& aStream,
60 std::vector<std::string> aEventVec);
61 void PrintCount(std::ostream& aStream,
62 std::vector<std::string>& aEvent,
63 size_t& aIndex);
64
65 void PrintHeaderData(std::ostream& aStream,
66 std::vector<std::string> aEventVec);
67 void PrintHeaderCount(std::ostream& aStream,
68 std::vector<std::string>& aEvent,
69 size_t& aIndex);
70
71 void UpdateMaxCount(const std::vector<std::string>& aEventData);
72
73 EventMap mEventMap;
74
75 std::vector<std::string> mFileNames;
76 std::vector<std::unique_ptr<std::ofstream>> mFileStreams;
77 std::unordered_map<std::string, std::map<size_t, std::string>> mEventTagsByIndex;
78 std::unordered_map<std::string, bool> mHeaderPrinted;
79 std::map<std::string, std::map<size_t, std::vector<std::string>>> mCountHeader;
80 std::map<std::string, std::map<size_t, size_t>> mCountHeaderMax;
81};
82
83#endif
~DSV_Output() override=default
bool StreamIsOpen(size_t aIndex) const
Definition DSV_Output.cpp:500
DSV_Output()=delete
std::unordered_map< std::string, EventData > EventMap
Definition DSV_Output.hpp:34
std::ofstream & StreamRef(size_t aIndex)
Definition DSV_Output.hpp:44
bool PrintReport()
Definition Report.cpp:267
virtual void PrintReportHeader(std::ostream &aStream)
Definition Report.hpp:138
virtual void ProcessHeaders(std::istream &aStream)
Definition Report.cpp:569
virtual bool Filter(std::vector< std::string > &aLine)
Definition Report.hpp:139
Report()=delete
virtual bool CreateRequiredData(std::string &aOutputDir)
Definition Report.hpp:136
Definition DSV_Output.hpp:28
size_t mIndex
Definition DSV_Output.hpp:31
std::string mBaseFileName
Definition DSV_Output.hpp:29
bool mSetIndex
Definition DSV_Output.hpp:30
Definition Options.hpp:21
Copyrights Multiple, All Rights Reserved