1 #ifndef VIEW_TEXT_VIEWER_H_INCLUDED
2 #define VIEW_TEXT_VIEWER_H_INCLUDED
36 template <
typename Exporter,
typename GzExporter>
40 TextViewer(
const std::shared_ptr<SimShell::Ws::MergedPreferences>& p)
41 : m_preferences(prefs_type::Create(p)), m_dir_path(p->GetPath()) {}
43 TextViewer(
const std::shared_ptr<SimShell::Ws::MergedPreferences>& p,
const std::string& dir_path)
44 : m_preferences(prefs_type::Create(p)), m_dir_path(dir_path) {}
50 template <
typename EventType>
53 typename EventType::Source es = e.GetSource();
54 const int step = e.GetStep();
57 const bool check = (et == EventType::Type::Forced)
58 || (et == EventType::Type::Stepped &&
59 (m_preferences->m_stride != 0 && (step % m_preferences->m_stride == 0)))
60 || (et == EventType::Type::Done && m_preferences->m_stride == 0);
62 if (m_preferences->m_gzip)
63 GzExporter::Export(es, MakeLabeledFilepath(step));
65 Exporter::Export(es, MakeLabeledFilepath(step));
74 std::string MakeLabeledFilepath(
int simstep)
const
76 const std::string postfix = m_preferences->m_gzip
77 ? GzExporter::GetFileExtension() : Exporter::GetFileExtension();
78 std::stringstream file_path;
79 file_path << m_dir_path <<
'/' <<
"leaf_";
82 file_path << simstep <<
"." << postfix;
83 return file_path.str();
87 std::shared_ptr<prefs_type> m_preferences;
88 std::string m_dir_path;
93 #endif // end_of_include_guard
virtual ~TextViewer()
Destructor must be virtual.
Namespace for SimPT shell package.
Type
Enumerates the wall types.
Interface/Implementation for TextViewerPreferences.
Viewer that periodically exports mesh to a text file, opening writing and closing the file again duri...
Interface for MergedPreferences.
void Update(EventType const &e)
Check whether export should happen and then do so.
Listener for SimShell::Event::MergedPreferencesChanged events.